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

时间:2023-02-11
本文介绍了如何从 php soap 客户端调用重载的 wsdl webservice 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

 '47','Password' => 'zZa@#286#@');$header = new SOAPHeader('http://tempuri.org/', 'AuthenticationHeader', $soapHeader);$client ->__setSoapHeaders($header);尝试{$res = $client->GetSubscriberInfoVCLogV2(array('vcNo' => $mobileno, 'mobileNo' => '', 'BizOps' => '1', 'UserID' => '555300','用户类型' => 'DL' ));}抓住(SoapFault $e){echo "无效否";打印_r($e);}打印_r($res);?>

它给出了错误 GetSubscriberInfoVCLogV2 is not found.我需要得到 GetSubscriberInfoVCLogV2 的响应.谁能帮我找到解决方案.

解决方案

做到这一点的唯一方法是手动编写 XML 请求并通过方法 SoapClient::__doRequest 发送它.

应该是这样的:

$request = <<<'EOT'<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:信封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($请求,"http://www.exemple.com/path/to/WebService.asmx","http://tempuri.org/TheMessageNameGoesHere",肥皂_1_1);

为 WebService 描述页面中的 MessageName 更改TheMessageNameGoesHere".

XML 结构也可以在 WebService 描述页面中找到,当您在函数中单击时.

方法__doRequest的第三个参数是SOAP动作,可以在WSDL文件中作为标签<的属性找到/p>

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.

解决方案

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>

这篇关于如何从 php soap 客户端调用重载的 wsdl webservice 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:无法在 Yii2 中将肥皂响应字符串转换为 xml 下一篇:Webservice SOAP 请求 - 发送的数据类型错误

相关文章

最新文章