PHP SOAP发送信封到WSDL
我真的希望我能为这篇文章写下正确的标题。基本上,我需要连接以向特定url发出soap请求,并从那个里检索数据 这是我需要发送的请求:PHP SOAP发送信封到WSDL,php,curl,soap,wsdl,soap-client,Php,Curl,Soap,Wsdl,Soap Client,我真的希望我能为这篇文章写下正确的标题。基本上,我需要连接以向特定url发出soap请求,并从那个里检索数据 这是我需要发送的请求: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:rad="http://schemas.datacontract.org/2004/07/Radixx.ConnectPoint.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:rad="http://schemas.datacontract.org/2004/07/Radixx.ConnectPoint.Request" xmlns:rad1="http://schemas.datacontract.org/2004/07/Radixx.ConnectPoint.Security.Request">
<soapenv:Header/>
<soapenv:Body>
<tem:RetrieveSecurityToken>
<!--Optional:-->
<tem:RetrieveSecurityTokenRequest>
<rad:CarrierCodes>
<!--Zero or more repetitions:-->
<rad:CarrierCode>
<rad:AccessibleCarrierCode>FZ</rad:AccessibleCarrierCode>
</rad:CarrierCode>
</rad:CarrierCodes>
<rad1:LogonID>xxx</rad1:LogonID>
<rad1:Password>xxxx</rad1:Password>
</tem:RetrieveSecurityTokenRequest>
</tem:RetrieveSecurityToken>
</soapenv:Body>
</soapenv:Envelope>
和请求错误
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RetrieveSecurityToken'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 162. in J:\WORK\web\flyDubai\index.php:25 Stack trace: #0 J:\WORK\web\flyDubai\index.php(25): SoapClient->__soapCall('RetrieveSecurit...', Array) #1 {main} thrown in J:\WORK\web\flyDubai\index.php on line 25`
当我调用uu getTypes()时,我得到(除其他外):
我猜我发出的这个请求是不正确的(也许我应该发送转换为数组的整个xml),但我不知道如何发送正确的请求?您调用的方法需要
RetrieveSecurityTokenRequest
类型的参数RetrieveSecurityToken
,该参数在包含的函数中定义。在这里,您可以看到它是从CarrierInfo
扩展而来的,添加了LogonID
和Password
属性
基本类型CarrierInfo
在其他中定义。它有一个类型为ArrayOfCarrierCode
的单个属性CarrierCodes
,该属性是CarrierCode
对象的数组,每个对象都有一个AccessibleCarrierCode
字符串属性
在WSDL中,CarrierInfo
被指定为nillable(允许
),并且可以是空数组(允许
),但在这些情况下,服务会以错误进行响应
因此,这就是为什么您可能应该按照您在问题中发布的示例XML创建请求,至少有一个运营商代码:
$code=新的StdClass;
$code->AccessibleCarrierCode=“FZ”;
$data=新的StdClass;
$data->CarrierCodes=数组($code);
$data->LogonID=“xxxxx”;
$data->Password=“xxxxx”;
$client=新的SoapClient($url);
$response=$client->RetrieveSecurityToken(数组(“RetrieveSecurityTokenRequest”=>$data));
var_dump($response);
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RetrieveSecurityToken'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 162. in J:\WORK\web\flyDubai\index.php:25 Stack trace: #0 J:\WORK\web\flyDubai\index.php(25): SoapClient->__soapCall('RetrieveSecurit...', Array) #1 {main} thrown in J:\WORK\web\flyDubai\index.php on line 25`
struct RetrieveSecurityToken {
string LogonID;
string Password;
}