Different Soap Envelopes - One Works, The Other Fails
I'm making an identical SOAP Request, one using the Zend Framework and the other not. The Zend one is not working and the only difference seems to be the envelope namespace.
How is the envelope set and why would one of them fail?
Zend Soap Call
开发者_JAVA技巧<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://wsapi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
<env:Body>
<ns1:incomingRequest env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<username xsi:type="xsd:string">myuser</username>
<password xsi:type="xsd:string">mypass</password>
<request xsi:type="xsd:string">&lt;incoming-requests&gt;&lt;request description="getEmailMessageStatus"&gt;&lt;incoming-data&gt;&lt;email-message messageID="messageID"/&gt;&lt;/incoming-data&gt;&lt;/request&gt;&lt;/incoming-requests&gt;</request>
</ns1:incomingRequest>
</env:Body>
</env:Envelope>
PHP Soap Call
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://wsapi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:incomingRequest>
<username xsi:type="xsd:string">myuser</username>
<password xsi:type="xsd:string">mypass</password>
<request xsi:type="xsd:string"><incoming-requests><request description="getEmailMessageStatus"><incoming-data><email-message messageID="messageID"/></incoming-data></request></incoming-requests></request>
</ns1:incomingRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I've figured this out.
It turns out, the Soap server is only compatible with SOAP version 1.1.
In Zend, you can specify the version like so:
$client = new Zend_Soap_Client('wsdl url', array('soap_version' => SOAP_1_1));
This changed the envelope and the Soap server began responding as it should.
精彩评论