我需要发送这个SOAP请求(从SoapUI NG获取它,它在哪里工作):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:data="http://example.com/rp/data">
<soapenv:Header>
<data:AuthorizationHeader soapenv:mustUnderstand="1">
<data:login>?</data:login>
<data:password>?</data:password>
</data:AuthorizationHeader>
</soapenv:Header>
<soapenv:Body>
<data:OperationHistoryRequest>
<data:Barcode>?</data:Barcode>
<data:MessageType>?</data:MessageType>
<data:Language>?</data:Language>
</data:OperationHistoryRequest>
</soapenv:Body>
</soapenv:Envelope>
尝试使用此代码:
<?php
$rp_soap_endpoint = "http://example.com/OperationHistory?wsdl";
$client_params = array(
'soap_version' => SOAP_1_2,
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
'encoding' => 'UTF-8',
'trace' => 1,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
);
$client = new SoapClient($rp_soap_endpoint, $client_params);
$header = new SoapHeader(
"http://example.com/rp/data",
"AuthorizationHeader",
array(
new SoapVar($rp_user, XSD_STRING, null, null, "login", "data"),
new SoapVar($rp_password, XSD_STRING, null, null, "password", "data")
),
true);
$client->__setSoapHeaders($header);
$body = '<data:OperationHistoryRequest>
<data:Barcode>?</data:Barcode>
<data:MessageType>?</data:MessageType>
<data:Language>?</data:Language>
</data:OperationHistoryRequest>';
$result = $client->GetOperationHistory(new SoapVar($body, XSD_ANYXML));
echo $result;
但收到错误:
Fatal error: Uncaught SoapFault exception: [Sender] SOAP-ERROR: Encoding: object has no 'login' property
修复此代码需要什么?还有:
答案 0 :(得分:0)
将版本更改为SOAP_1_1
和:
array(
new SoapVar($rp_user, XSD_STRING, null, null, "login", "data"),
new SoapVar($rp_password, XSD_STRING, null, null, "password", "data")
)
到
array(
'login' => $rp_user,
'password' => $rp_password
)
现在对我有用。