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

How to call overloaded wsdl webservice method from php soap client(如何从 php soap 客户端调用重载的 wsdl webservice 方法)
本文介绍了如何从 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 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Subtract time in PHP(在 PHP 中减去时间)
Limit execution time of an function or command PHP(限制函数或命令 PHP 的执行时间)
How to sum N number of time (HH:MM Format)?(如何求和 N 次(HH:MM 格式)?)
How to get current time in milliseconds in PHP?(如何在 PHP 中以毫秒为单位获取当前时间?)
How to check if time is between two times in PHP(如何检查时间是否在 PHP 中的两次之间)
Convert number of minutes into hours amp; minutes using PHP(将分钟数转换为小时数分钟使用 PHP)