[英]SOAP error using PHP SoapClient
I am trying to connect to a Soap Webservice using PHP's SoapClient and I am getting an error below 我正在尝试使用PHP的SoapClient连接到Soap Web服务,并且在下面出现错误
The SOAP action specified on the message, '', does not match the HTTP SOAP Action, ' http://tempuri.org/IInDirect/AddProduct '.
消息“”上指定的SOAP操作与HTTP SOAP操作“ http://tempuri.org/IInDirect/AddProduct ”不匹配。
Below is my PHP code to connect to the server. 下面是我连接到服务器的PHP代码。
$requestParams = array(
'Password' => 'XXXXXX',
'Username' => 'XXXXXXX',
'AddressLine1' => '52 TEST DRIVE',
'City' => 'JOHANNESBURG',
'DateOfBirth' => '1960-02-10T00:00:00',
'Forename1' => 'Eva',
'Gender' => 'Unknown',
'Province' => 'GAUTENG',
'SouthAfricanID' => '45454545454',
'ProductCode' => '12345'
);
try {
$options = array(
'soap_version' => SOAP_1_2,
'cache_wsdl'=>WSDL_CACHE_NONE,
'connection_timeout' => 15,
'trace' => true,
'encoding' => 'UTF-8',
'exceptions' => true,
);
$client = new \SoapClient('https://soap.url.com/test.svc?wsdl', $options);
$actionHeader = new \SoapHeader('http://www.w3.org/2005/08/addressing',
'Action',
'http://tempuri.org/IInDirect/AddProduct');
$client->__setSoapHeaders($actionHeader);
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
$response = $client->AddProduct($requestParams);
print_r($response);
Below is the xml 下面是xml
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tusa="http://schemas.datacontract.org/2004/07/Tusa.Services.ConsumerConnect" xmlns:tem="http://tempuri.org/">
<soap:Header>
<AuthenticationCredentials>
<tusa:Password>Password</tusa:Password>
<tusa:Username>Username</tusa:Username>
</AuthenticationCredentials>
</soap:Header>
<soap:Body>
<tem:AddProduct>
<tem:CustomerDetail>
<tusa:AddressLine1>AddressLine1</tusa:AddressLine1>
<tusa:City>City</tusa:City>
<tusa:DateOfBirth>DateOfBirth</tusa:DateOfBirth>
<tusa:Forename1>Forename1</tusa:Forename1>
<tusa:Gender>Gender</tusa:Gender>
<tusa:MaritalStatus>MaritalStatus</tusa:MaritalStatus>
<tusa:Province>Province</tusa:Province>
<tusa:SouthAfricanID>SouthAfricanID</tusa:SouthAfricanID>
<tusa:Suburb>Suburb</tusa:Suburb>
<tusa:Surname>Surname</tusa:Surname>
</tem:CustomerDetail>
<tem:ProductCode>ProductCode</tem:ProductCode>
</tem:AddProduct>
</soap:Body>
</soap:Envelope>
How would i get this to work? 我将如何使其工作?
This error message may be caused by missing Action SOAP header. 可能由于缺少操作SOAP标头而导致此错误消息。
$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing',
'Action',
'http://tempuri.org/IInDirect/AddProduct');
$client->__setSoapHeaders($actionHeader);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.