我不知道该怎么做,但我应该发送一个SOAP请求,格式如下:
<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' => '60123456789',
'sClientPassword' => '123456789',
'sProductID' => '1',
'dProductPrice' => '10',
'sClientTxID' => $txn_id,
'sCustomerAccountNumber' => '60166527234',
'sCustomerMobileNumber' => '60166527234',
'sEncKey' => 'sample_enc',
)
);
echo $client->__getLastRequest();
现在,问题是这会以正确的格式生成xml,但用&#34; ns1&#34; 替换所有&#34; tem&#34; STRONG>。我很抱歉这样说,但我甚至不知道这两者之间的区别,谷歌搜索并没有多大帮助。
如果我用&#34; ns1&#34;请求xml,这会有什么不同吗? ?或者我应该将其改为&#34; tem&#34;作为客户端期望吗?请帮忙。
答案 0 :(得分:1)
不应该。命名空间前缀仅引用实际命名空间(xmlns:*
命名空间定义节点中的值)。前缀对于元素节点是可选的,并且可以在每个元素节点上更改。因此tem:RequestTopup
实际上应该被视为{http://tempuri.org/}RequestTopup
。以下是3个示例,这些示例全部解析为名称空间http://tempuri.org/
中具有本地名称RequestTopup
<tem:RequestTopup xmlns:tem="http://tempuri.org/"/>
<ns1:RequestTopup xmlns:ns1="http://tempuri.org/"/>
<RequestTopup xmlns="http://tempuri.org/"/>
然而,我已经看到了更多错误的实现,然后我想。它们通常依赖于特定的名称空间前缀,并忽略实际的名称空间。