How can I create php soap request to look like this. I am unable to get the response in Php curl. But fiddler web debugger is working really well with the code.
Here is the raw request:
POST http://195.230.180.189:8280/services/TopupService?wsdl HTTP/0.9 Host: 195.230.180.189:8280 Content-Length: 691
<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:top="http://www.inew-cs.com/mvno/integration/TopupService/">
<soapenv:Header/>
<soapenv:Body>
<top:TopupRequest>
<amount>1</amount>
<amountUnitRelation>1</amountUnitRelation>
<subscriber>
<msisdn>8801701340002</msisdn>
</subscriber>
<source>
<distributorId>PayWell</distributorId>
</source>
<referenceId>12345</referenceId>
<transactionId>09876543</transactionId>
</top:TopupRequest>
</soapenv:Body>
</soapenv:Envelope>
In Php curl request:
$url="http://195.230.180.189:8280/services/TopupService?wsdl";
$xml='<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:top="http://www.inew-cs.com/mvno/integration/TopupService/">
<soapenv:Header/>
<soapenv:Body>
<top:TopupRequest>
<amount>1</amount>
<amountUnitRelation>1</amountUnitRelation>
<subscriber>
<msisdn>8801701340002</msisdn>
</subscriber>
<source>
<distributorId>100</distributorId>
</source>
<referenceId>12345</referenceId>
<transactionId>09876543</transactionId>
</top:TopupRequest>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array(
"Content-type: text/xml",
"Content-length: " . strlen($xml),
"Connection: close"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
echo $result = curl_exec($ch);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
//echo 'Operation completed without any errors';
}
// Close handle
curl_close($ch);