I don't know how to put this, but I was supposed to send a SOAP request with following format:
<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>
My php code was like below:
$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();
Now, the problem is this generates the xml in correct format alright, but replaces all the "tem" with "ns1". I'm sorry to say this, but I do not even know the difference between the two and googling didn't help much.
Will this make any difference if I request the xml with "ns1" ? Or should I change it to "tem" as the client end expects it ? Please help.
It should not. Namespace prefixes only reference the actual namespace (The value in the xmlns:*
namespace definition node). Prefixes are optional for element nodes and can change on each element node. So tem:RequestTopup
should be actually read as {http://tempuri.org/}RequestTopup
. Here are 3 examples that all resolve to a node in the namespace http://tempuri.org/
with the local name RequestTopup
<tem:RequestTopup xmlns:tem="http://tempuri.org/"/>
<ns1:RequestTopup xmlns:ns1="http://tempuri.org/"/>
<RequestTopup xmlns="http://tempuri.org/"/>
However, I have seen a lot more faulty implementations then I would like. They often rely on specific namespace prefixes and ignore the actual namespace.