我有一个带有位置的wsdl文件,我想通过soap发送请求值,我正在尝试下面的场景。但是它没有调用wsdl函数。请告诉我如何发送soap请求参数。
<xs:complexType name="wsNotification">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="notificationList" nillable="true" type="tns:notificationsParam"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="notificationsParam">
<xs:sequence>
<xs:element minOccurs="0" name="email" type="xs:string"/>
<xs:element minOccurs="0" name="phone" type="xs:string"/>
</xs:sequence>
</xs:complexType>
下面的代码我在php中使用soap函数调用wsdl
$client = new SoapClient("http://192.100.1.8:8080/getAPI/ws/WSNotification?wsdl",
array('email' => "test@gmail.com",
'phone' => "97122555")
);
echo "Response:'n" . $client->__getLastResponse() . "<br>";
当我调用上面的soap函数时,我没有得到wsdl的任何响应。请帮助我如何从php发送参数到soap。
不确定你是否已经有了答案。但以前我使用的是nussoap工具包来实现这一点。
- 下载包并将文件放入项目文件夹
-
在你的代码中包含这个库
require_once (lib/nusoap.php);
-
写代码
看看你的xml,这可以达到目的
$client=new nusoap_client('http://192.100.1.8:8080/getAPI/ws/WSNotification?wsdl', 'wsdl');
$login=array('email'=>'test@gmail.com', 'phone'=>'97122555');
$response= $client->call('notificationsParam', array('parameters' => $login));
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($response);
echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
print_r($response);
}
}