【问题标题】:Making a SOAP REQUEST in PHP在 PHP 中发出 SOAP 请求
【发布时间】:2017-12-14 15:57:06
【问题描述】:

我正在尝试使用我的代码传递我的 AgentCodeAgentUserAgentPasswdAgentSignature 变量。请帮忙,因为我是 SOAP 新手。

这是 XML 结构。

<soapenv:Header/>
   <soapenv:Body>
      <urn:GetLocationsList soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <HeaderInfo xsi:type="urn:THeaderInfo" xmlns:urn="urn:testsrvIntf">
            <AgentCode xsi:type="xsd:string">xxxx</AgentCode>
            <AgentUser xsi:type="xsd:string">xxxx</AgentUser>
            <AgentPasswd xsi:type="xsd:string">xxxx</AgentPasswd>
            <AgentSignature xsi:type="xsd:string">xxxx</AgentSignature>
         </HeaderInfo>
      </urn:GetLocationsList>
   </soapenv:Body>
</soapenv:Envelope>

这是我的 PHP 代码:

require_once('lib/nusoap.php');
$wsdl = "http://webservices.xxxxxx.xxxxx";

$client = new nusoap_client($wsdl);
$parameters= array('HeaderInfo' => array('AgentCode'      => 'xxxx',
                                              'AgentUser'      => 'xxxx',
                                              'AgentPasswd'    => 'xxxx',
                                              'AgentSignature' => 'xxxx'));
$value = $client->GetLocationsList($parameters);

echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

【问题讨论】:

  • 有什么问题?
  • 我从未使用过该库,但这是设置身份验证的正确方法吗?不是$client-&gt;setCredentials(..)吗?
  • 我很困惑如何通过身份验证传递请求。
  • 我收到此错误:PHP 致命错误:调用未定义的方法 nusoap_client::GetLocationsList()
  • 有人可以告诉我我应该如何提出这个请求:

标签: php soap nusoap


【解决方案1】:

如果你要使用它,你需要阅读 nusoap 库的文档。

https://github.com/econea/nusoap

看起来正确的打电话方式是:

$result = $client->call($action, $data);

您所做的就是 PHP SOAP 客户端的工作方式。

http://php.net/manual/en/class.soapclient.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多