![](/img/trans.png)
[英]Getting Exception “Method Not Allowed” after making SOAP request using SoapCall function in PHP
[英]Incorrect SOAP request format for the message body using __soapcall() PHP
我已经使用 __soapcall() 发送了一个肥皂请求。
$parameters = array(
'ID' => '0001',
'TimeStamp' => '2016-06-20T17:03:27Z',
'SenderID' => 'B2eww8',
);
$URL = 'https://example.com';
$client = new \SoapClient(null, array(
'location' => $URL,
'uri' => "http://example.com/SOAP/WSDL/abc.xsd",
'trace' => 1
));
$return = $client->__soapCall("TestSoapRequest", $parameters);
var_dump($return);
然后请求看起来像。
<SOAP-ENV:Body>
<ns1:TestSoapRequest>
<param0 xsi:type="xsd:string">0001</param2>
<param1 xsi:type="xsd:string">2016-06-20T17:03:27Z</param3>
<param2 xsi:type="xsd:string">B2eww8</param4>
</ns1:TestSoapRequest>
</SOAP-ENV:Body>
但所需的格式是,
<soapenv:Body>
<ns1:TestSoapRequest xmlns:ns1="http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd">
<ID>0001</ID>
<TimeStamp>2014-05-22T17:03:27Z</TimeStamp>
<SenderID>B2eww8</SenderID>
</ns1:TestSoapRequest>
</soapenv:Body>
我怎样才能做到这一点。
在http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd 中没有TestSoapRequest
定义,所以如果你想准备没有它的请求,那么你应该使用这里描述的SoapParam
类http://php.net /manual/en/soapparam.soapparam.php
PHP Soap non-WSDL 调用这里已经描述了类似的问题:你如何传递参数?
几个月前,我遇到了同样的问题,正在使用 XML 文档。 我创建了一个生成器文件,它创建了一个结构更正的 XML 文档。
$XMLDocument = new DOMDocument('1.0', 'UTF-8');
$Body = $XMLDocument->createElement('soapenv:Body', null);
$Body->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:ns1', "http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd");
$TestSoapRequest = $XMLDocument->createElement('TestSoapRequest', null);
$element = $XMLDocument->createElement('ID', '0001');
$TestSoapRequest->appendChild($grossWeightElement);
$element = $XMLDocument->createElement('TimeStamp', '2014-05-22T17:03:27Z');
$TestSoapRequest->appendChild($grossWeightElement);
$element = $XMLDocument->createElement('SenderID', 'B2eww8');
$TestSoapRequest->appendChild($grossWeightElement);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.