How to call overloaded wsdl webservice method from php soap client

喜欢而已 提交于 2019-12-29 09:32:48

问题


Webservice : http://webservices.dishtv.in/Services/Mobile/Trade/TradeSubscriberInfo.asmx Overloaded method is GetSubscriberInfoV2 MessageName="GetSubscriberInfoVCLogV2" My php code is,

<?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);
?>

It gives error GetSubscriberInfoVCLogV2 is not found. I need to get the response of GetSubscriberInfoVCLogV2. Can anyone help me to find the solution.


回答1:


The only way to do this is writing the XML request manually and sending it through the method SoapClient::__doRequest.

It would be something like this:

$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
);

Change "TheMessageNameGoesHere" for the MessageName found in the WebService description page.

The XML structure can also be found in the WebService description page, when you click in the function.

The third parameter of the method __doRequest is the SOAP action, and can be found in the WSDL file as an attribute of the tag <soap:operation>



来源:https://stackoverflow.com/questions/38170101/how-to-call-overloaded-wsdl-webservice-method-from-php-soap-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!