如何在php中使用soap将参数发送到wsdl文件

问题描述:

我有一个带有位置的wsdl文件,我想通过soap发送请求值,我正在尝试以下方案。但它没有调用wsdl函数。请帮助我如何发送肥皂请求参数。如何在php中使用soap将参数发送到wsdl文件

<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中使用肥皂功能

$client = new SoapClient("http://192.100.1.8:8080/getAPI/ws/WSNotification?wsdl", 
           array('email'  => "[email protected]", 
             'phone'  => "97122555") 
         ); 
echo "Response:\n" . $client->__getLastResponse() . "<br>"; 

我没有得到从WSDL任何回应时,我调用上面肥皂函数调用WSDL。请帮助我如何发送参数从PHP到肥皂。

不知道你是否已经有了这个答案。但之前我使用nusoap toolkit来实现这一点。

  1. 下载包并把文件在项目文件夹
  2. 包括库在你的代码

    require_once( '的lib/nusoap.php');

  3. 编写代码

看你的XML,这可能做的伎俩

$client=new nusoap_client('http://192.100.1.8:8080/getAPI/ws/WSNotification?wsdl', 'wsdl'); 

$login=array('email'=>'[email protected]', '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); 

} 
}