3
我不知道如何把這個,但我本來是要發送帶有以下格式的SOAP請求:是否在SOAP請求NS1和TEM的不匹配影響的要求?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:RequestTopup>
<tem:sClientUserName>?</tem:sClientUserName>
<tem:sClientPassword>?</tem:sClientPassword>
<tem:sClientTxID>?</tem:sClientTxID>
<tem:sProductID>?</tem:sProductID>
<tem:dProductPrice>?</tem:dProductPrice>
<tem:sCustomerAccountNumber>?</tem:sCustomerAccountNumber>
<tem:sCustomerMobileNumber>?</tem:sCustomerMobileNumber>
<tem:sEncKey>?</tem:sEncKey>
</tem:RequestTopup>
</soapenv:Body>
</soapenv:Envelope>
我的PHP代碼是象下面這樣:
$opts = array(
'ssl' => array('ciphers' => 'RC4-SHA', 'verify_peer' => false, 'verify_peer_name' => false)
);
$params = array(
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'trace' => 1, 'exceptions' => 1,
"connection_timeout" => 180,
'stream_context' => stream_context_create($opts)
);
$client = new SoapClient("http://xmpl/connect.asmx?WSDL", $params);
$txn_id = "2017021234567";
$result = $client->RequestTopup(
array(
'sClientUserName' => '6',
'sClientPassword' => '123456789',
'sProductID' => '1',
'dProductPrice' => '10',
'sClientTxID' => $txn_id,
'sCustomerAccountNumber' => '60166527234',
'sCustomerMobileNumber' => '60166527234',
'sEncKey' => 'sample_enc',
)
);
echo $client->__getLastRequest();
現在的問題這是否會生成正確格式的xml,但會將「tem」替換爲「ns1」。我很抱歉地說,但我甚至不知道這兩者之間的區別和谷歌搜索沒有多大幫助。
這會不會使任何區別,如果我要求與「NS1」的XML?或者我應該改變它爲「tem」,因爲客戶端期望它?請幫忙。
非常感謝..你讓一切變得清晰..然而,有沒有什麼辦法,用tem替換那些ns1? –
你將不得不重新創建XML節點。我在FluentDOM中實現了一個可用於執行此操作的優化器:https://github.com/FluentDOM/FluentDOM/blob/master/examples/Transformer/Namespaces/optimize.php – ThW