我正忙着编写一个 SOAP 脚本,该脚本大部分工作正常,但是有一个请求无法正常工作,并且主机公司要求更改请求 XML 的格式,我陷入了困境...
目前我的 XML 请求如下所示...
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://www.???.com/???/">
<env:Body>
<ns1:GetTransactions>
<ns1:Filter>
<ns1:CardId>1234</ns1:CardId>
</ns1:Filter>
<ns1:Range>
<ns1:FirstRow/>
<ns1:LastRow/>
</ns1:Range>
</ns1:GetTransactions>
</env:Body>
</env:Envelope>
Run Code Online (Sandbox Code Playgroud)
但主办公司要求它看起来像这样......
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<GetTransactions xmlns="http://www.???.com/???/">
<Filter>
<CardId>1234</CardId>
</Filter>
<Range>
<FirstRow/>
<LastRow/>
</Range>
</GetTransactions>
</env:Body>
</env:Envelope>
Run Code Online (Sandbox Code Playgroud)
我的形成请求的 PHP 如下......
$wsdl = 'http://???.com/???/???.asmx?WSDL';
$endpoint = 'http://???.com/???/???.asp';
$soap_client = new SoapClient( $wsdl, array(
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 0,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'location' => $endpoint
) );
$get_transactions = $soap_client->GetTransactions( array(
'Filter' …Run Code Online (Sandbox Code Playgroud)