如何从php soap客户端调用重载的wsdl webservice方法

时间:2016-07-03 12:48:59

标签: php web-services soap wsdl

网络服务http://webservices.dishtv.in/Services/Mobile/Trade/TradeSubscriberInfo.asmx 重载方法是GetSubscriberInfoV2 MessageName =" GetSubscriberInfoVCLogV2" 我的PHP代码是,

<?php
$mobileno="01523833622";
$url="http://webservices.dishtv.in/Services/Mobile/Trade/TradeSubscriberInfo.asmx?wsdl";
$client = new SoapClient($url);
$soapHeader = array('UserID' => '47','Password' => 'zZa@#286#@');
$header = new SOAPHeader('http://tempuri.org/', 'AuthenticationHeader', $soapHeader);        
$client ->__setSoapHeaders($header); 
try
{
        $res = $client->GetSubscriberInfoVCLogV2(array('vcNo' => $mobileno, 'mobileNo' => '', 'BizOps' => '1', 'UserID' => '555300', 'UserType' => 'DL' ));
} 
catch(SoapFault $e)
{   
        echo "Invalid No";
        print_r($e);         
}
print_r($res);
?>

它给出错误找不到GetSubscriberInfoVCLogV2。我需要得到GetSubscriberInfoVCLogV2的响应。任何人都可以帮我找到解决方案。

1 个答案:

答案 0 :(得分:0)

唯一的方法是手动编写XML请求并通过方法SoapClient::__doRequest发送。

会是这样的:

$request = <<<'EOT'
  <?xml version="1.0" encoding="utf-8"?>
  <SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns1="http://tempuri.org/">
    <SOAP-ENV:Body>
      <ns1:TheMessageNameGoesHere>
        <ns1:param1>$param1</ns1:param1>
        <ns1:param2>$param2</ns1:param2>
        <ns1:param3>$param3</ns1:param3>
      </ns1:TheMessageNameGoesHere>
    </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>
EOT;

$response = $soapClient->__doRequest(
  $request,
  "http://www.exemple.com/path/to/WebService.asmx",
  "http://tempuri.org/TheMessageNameGoesHere",
  SOAP_1_1
);

更改在WebService描述页面中找到的MessageName的“ TheMessageNameGoesHere”。

单击功能时,也可以在WebService描述页面中找到XML结构。

方法__doRequest的第三个参数是SOAP操作,可以在WSDL文件中作为标记<soap:operation>的属性找到