我需要有這個節點,我的SOAP請求(使用1.1):如何定義SoapVar命名空間?
<CredentialsHeader xmlns="http://www.url.com/Services/P24ListingService11"
<EMail>[email protected]</EMail>
<Password>password</Password>
</CredentialsHeader>
所以我有以下的PHP:
$client = new SoapClient("https://exdev.www.example.com/Services/example.asmx?WSDL",
array(
"trace" => 1,
"exceptions" => 0,
"cache_wsdl" => 0,
'soap_version' => SOAP_1_1
)
);
$CredentialObject = new SoapVar(array('EMail' => '[email protected]', 'Password' => 'password'), SOAP_ENC_OBJECT);
產生:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.example.com/Services/Example">
<SOAP-ENV:Header>
<ns1:CredentialsHeader>
<EMail>[email protected]</EMail>
<Password>password</Password>
</ns1:CredentialsHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:EchoAuthenticated/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
所有我需要做的就是防止它使用ns1
,並在節點實際上定義了xmlns
像這樣:
<CredentialsHeader xmlns="http://www.example.com/Services/Example">
<EMail>[email protected]</EMail>
<Password>password</Password>
</CredentialsHeader>
我已經測試在Firefox海報,知道一個事實,即改變解決了這個問題。
不是最漂亮的,但它的工作!謝謝 – rickyduck