如何創建php soap請求,看起來像這樣。我無法在Php curl中獲得回覆。但是小提琴手的網絡調試器在代碼上工作得很好。在Php中使用CURL不起作用的肥皂客戶端請求
這裏是原始請求:
POST http://195.230.180.189:8280/services/TopupService?wsdl HTTP/0.9 主機: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>
在PHP捲曲請求:
$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);
http://php.net/manual/en/class.soapclient.php –