大家好,任何人都可以知道如何在php中创建此请求。我正在调用.net soap web-service。
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<confirmCustomerReq xmlns="http://www.nrs.eskom.co.za/xmlvend/revenue/2.1/schema">
<clientID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<terminalID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<msgID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" dateTime="xx" uniqueNumber="xx" />
<authCred xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema">
<opName>xxx</opName>
<password>xxx@#1</password>
</authCred>
<idMethod xmlns:q1="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="q1:VendIDMethod">
<q1:meterIdentifier xsi:type="q1:MeterNumber" msno="xx" />
</idMethod>
</confirmCustomerReq>
</soap:Body>
</soap:Envelope>
我尝试使用SoapClient类和curl,但仍然无法获得下面的确切xml是我的代码片段。下面是使用SoapClient类
array( 'ConfirmCustomerReq'=>array(
'ClientID' =>array('xsi:type'=>"EANDeviceID", 'ean'=>"xxxx"),
'terminalID'=>array('xsi:type'=>"EANDeviceID", 'ean'=>"xxx"),
'authCred' => array(
'opName' => "$this->username",
'password' => "$this->pass"
),
'msgID' => array('dateTime'=>"xxx" ,'uniqueNumber'=>"xxx" ),
'idMethod' => array('xsi:type'=>"q1:VendIDMethod",
'meterIdentifier' =>array( 'xsi:type'=>"q1:MeterNumber" ,'msno'=>"xxx")
)
)
);
和卷曲
function main(){
$xml ='<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<confirmCustomerReq xmlns="http://www.nrs.eskom.co.za/xmlvend/revenue/2.1/schema">
<clientID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<terminalID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<msgID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" dateTime="xx" uniqueNumber="xx" />
<authCred xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema">
<opName>xxx</opName>
<password>xxx@#1</password>
</authCred>
<idMethod xmlns:q1="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="q1:VendIDMethod">
<q1:meterIdentifier xsi:type="q1:MeterNumber" msno="xx" />
</idMethod>
</confirmCustomerReq>
</soap:Body>
</soap:Envelope>';
try{
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "https://www.utilitiesworld.co.za/SecureThirdPartyInterface/VendingService.asmx" );
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($soap_do, CURLOPT_CAINFO, 'XXXXXXXXXXXXXX');
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml);
//curl_setopt($soap_do, CURLOPT_HEADER, false);
$xml_result = curl_exec($soap_do);
echo curl_error($soap_do);
//$result=parse_str($xml_result);
//var_dump($xml_result);
curl_close($soap_do);
}