Re: SoapClient not sending proper SOAP requests -- how do I correct this?



On Aug 31, 9:54 am, Joshua Beall <joshbe...@xxxxxxxxx> wrote:
Hi All,

I've got the following PHP code:

$service = new SoapClient("http://www.webservicex.net/length.asmx?
wsdl");
$result = $service->ChangeLengthUnit(10,"Inches","Centimeters");
var_dump($result);

It returns:

object(stdClass)#2 (1) {
["ChangeLengthUnitResult"]=>
float(0)

}

If you manually go tohttp://www.webservicex.net/length.asmx?op=ChangeLengthUnit
and try the operation yourself, you'll see that it returns 2.54.

I used Wireshark to see what SOAP request was actually being sent, and
here's what I found:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:ns1="http://www.webserviceX.NET/";>
<SOAP-ENV:Body>
<ns1:ChangeLengthUnit/>
<param1>Inches</param1>
<param2>Centimeters</param2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This isn't right! Here's what the request *should* look like. The XML
namespaces are different, but that's ok; the problem is the content of
the Body element.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://
schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ChangeLengthUnit xmlns="http://www.webserviceX.NET/";>
<LengthValue>1</LengthValue>
<fromLengthUnit>Inches</fromLengthUnit>
<toLengthUnit>Centimeters/ChangeLengthUnit>
</soap:Body>
</soap:Envelope>

Windows XP Pro, IIS 5.1, and PHP 5.2.1 -- is there a bug that was
resolved in later versions of PHP? Or am I missing something?

-Josh

Are you pointing to the correct WSDL for your request? It looks like
it isn't receiving the correct format the is expected by the server.

.



Relevant Pages

  • Re: Securing an Email script
    ... request to our sales office. ... Since you do ZERO checking on the values it's nothing BUT security ... very powerful PHP function to validate form fields and other ...
    (comp.lang.php)
  • Re: Object Oriented Content System - the idea
    ... >I expected php to be smarter then that. ... >form like bytecode in memory for the next request. ... each action added some stuff to a "response" XML document. ... that map/object/data and formats it for HTML display using an includeed PHP ...
    (comp.lang.php)
  • Re: Securing an Email script
    ... request to our sales office. ... Since you do ZERO checking on the values it's nothing BUT security issues. ... very powerful PHP function to validate form fields and other strings - ...
    (comp.lang.php)
  • Re: Modular PHP
    ... How can I catch an event in PHP. ... Everything is done with XML, so you will want to be familiar with XSLT ... the function itentified by the Handler attribute in the above XML, ... It's also worth noting that all the XML parsing for the request map ...
    (comp.lang.php)
  • Re: JSP script riddled with errors - cant resolve them - please help
    ... As far as declarations are concerned, in PHP we don't often do ... >> I do not possess the ability to translate PHP into JSP, ... >> function getPage() { ... > and request is not understood there. ...
    (comp.lang.java.help)