2016-06-28 23 views
0

Ich versuche, eine Soap Webservice mit PHP Soapclient und ich erhalte eine Fehlermeldung unterSOAP Fehler mit PHP Soapclient

Die SOAP-Aktion angegeben auf die Nachricht, ‚‘ zu verbinden, nicht mit dem HTTP SOAP-Aktion, 'http://tempuri.org/IInDirect/AddProduct'.

Unten ist mein PHP-Code zum Herstellen einer Verbindung mit dem Server.

$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); 

Unten ist die 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> 

Wie würde ich dies funktioniert?

Antwort

1

Diese Fehlermeldung kann durch den fehlenden Action SOAP-Header verursacht werden.

$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing', 
           'Action', 
           'http://tempuri.org/IInDirect/AddProduct'); 
$client->__setSoapHeaders($actionHeader); 
+0

Können Sie bitte erklären, woher Sie die 3 Parameter erhalten haben? – jaahvicky