简体   繁体   中英

Calling a wsdl in php over https using Zend Soap Client

When I'm trying to connect to a webservice I always get the next fault

SoapFault exception: [s:Sender] An error occurred when verifying security for the message

I also have to use a security header, full soap request is send:

<env:Envelope>
<env:Header>
<ns2:Action env:mustUnderstand="1">
http://ws.agiv.be/crabtools/ICRABTools/GetAddressLocation
</ns2:Action>
<ns2:MessageID>urn:uuid:10000001blsd-ghfs</ns2:MessageID>
<ns2:ReplyTo>
<ns2:Address>
http://www.w3.org/2005/08/addressing/anonymous                      
</ns2:Address>
</ns2:ReplyTo>
<ns2:To>https://grab.beta.agiv.be/Tools/CRABTools.svc</ns2:To>
<o:Security env:mustUnderstand="1">
<wsu:Timestamp env:mustUnderstand="1">
<wsu:Created>2010-06-09T13:44:19Z</wsu:Created>
<wsu:Expires>2010-06-09T13:49:19Z</wsu:Expires>
</wsu:Timestamp>
<o:UsernameToken>
<o:Username>myUsername</o:Username>
<o:Password>myPassword</o:Password>
</o:UsernameToken>
</o:Security>
</env:Header>
<env:Body>
<ns1:GetAddressLocation>
<ns1:houseNumberId>2306852</ns1:houseNumberId>
</ns1:GetAddressLocation>
</env:Body>
</env:Envelope>

My username and password are correct, I have allready tried to change the expiration date later but that doesn't solve it.

What else could be the reason for this fault?

Maybe I have to configure more things in my php-code.

I created a class that overrides Zend_Soap_Client

public function __soapCall($function_name, $arguments, $options=null, $input_headers=null, $output_headers=null) {
        $inputheaders = array($this->wsactionheader(),$this->unencryptedSecurityHeader());
        $result = parent::__soapCall($this->functionname, $arguments, $options, $inputheaders);
        return $result;
    }

It might help if you tell us what kind of server you are trying to connect to. Also please provide the request headers in here. Use code like this

echo "REQUEST HEADERS:\n" . $client->getLastRequestHeaders() . "\n";
echo "REQUEST:\n" . $client->getLastRequest() . "\n";

What you can do is:

1) Make sure you have specified the wsdl in your soap client.

2) It may be the "namespacing" problem. Make sure that your SOAP requests are using the same "envelope" format as your server (specified in WSDL), ie check namespace attributes like

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:env="http://www.w3.org/2003/05/soap-envelope"

If the namespace is different from the one in your wsdl try to avoid explicitly specifying 'soap_version' in built-in PHP SoapClient which is wrapped in Zend_Soap_Client. The former always does specify the 'soap_version', this results in xmlns:env="http://www.w3.org/2003/05/soap-envelope"

3) Ask for working request XML examples and/or full HTTP trace and compare (diff) them with yours.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM