如何从 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 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)