SOAP::Lite: error reporting and encoding of arguments

Andrew Pimlott <[email protected]> Sun, 29 Feb 2004 19:29:50 -0500
Newsgroups gmane.comp.windows.devel.soap.general
Message-ID <[email protected]>
--dDRMvlgZJXvWKvBx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I just started using SOAP::Lite and have run into two problems that seem
quite fundamental, so I'm hoping I've just made some beginner mistake.

My code (to talk to Microsoft Project Data Services) is adapted from an
example in Microsoft's documentation, and based on the examples in the
SOAP::Lite documentation:

    my $soap = SOAP::Lite->service($soap_url);
    my $result = $soap->SoapXMLRequest($cookie,'<Request><PDSInfo/></Request>');

I've double-checked that I have the WSDL url, method name, and arguments
right.  The WSDL file is attached for reference.  The first problem is
that $result is undef, and there is no indication of what went wrong.  I
found something in the documentation about an on_fault handler, so I
added to the file

   use SOAP::Lite on_fault => sub { die @_ };

but this made no difference.  I would have expected some sort of
diagnostic by default.

Lacking that, I investigated the problem using strace.  I saw that IIS
was returning "500 Internal Server Error".  How is it that SOAP::Lite
swallowed this error?  Looking at the body of the reply, I saw a
complaint about a missing semicolon.  Then, I looked at the request sent
by SOAP::Lite and found that it wasn't even valid XML!  Specifically,
the $cookie argument I passed contains an '&' character, which was not
not encoded in the construction of the SOAP request.  The server saw an
'&' followed by some letters not followed by ';', and correctly threw an
error.  The full SOAP request (with minor anonymization) is attached.

Can someone tell me what I should have done to avoid these problems?

I initially used SOAP::Lite 0.55, packaged for Debian GNU/Linux
"testing".  I then downloaded 0.60a from CPAN, with no better results.

Andrew

--dDRMvlgZJXvWKvBx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="PDS.wsdl"

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated 11/15/01 by Microsoft SOAP Toolkit WSDL File Generator, Version 1.02.813.0 -->
<definitions name="PDS" targetNamespace="http://tempuri.org/wsdl/" xmlns:wsdlns="http://tempuri.org/wsdl/" xmlns:typens="http://tempuri.org/type" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-extension" xmlns="http://schemas.xmlsoap.org/wsdl/">
        <types>
                <schema targetNamespace="http://tempuri.org/type" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified">
                </schema>
        </types>
        <message name="CMain.SoapXMLRequest">
                <part name="sCookie" type="xsd:string"/>
                <part name="sXML" type="xsd:string"/>
        </message>
        <message name="CMain.SoapXMLRequestResponse">
                <part name="Result" type="xsd:string"/>
        </message>
        <portType name="CMainSoapPort">
                <operation name="SoapXMLRequest" parameterOrder="sCookie sXML">
                        <input message="wsdlns:CMain.SoapXMLRequest"/>
                        <output message="wsdlns:CMain.SoapXMLRequestResponse"/>
                </operation>
        </portType>
        <binding name="CMainSoapBinding" type="wsdlns:CMainSoapPort">
                <stk:binding preferredEncoding="UTF-8"/>
                <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
                <operation name="SoapXMLRequest">
                        <soap:operation soapAction="http://tempuri.org/action/CMain.SoapXMLRequest"/>
                        <input>
                                <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                        </input>
                        <output>
                                <soap:body use="encoded" namespace="http://tempuri.org/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                        </output>
                </operation>
        </binding>
        <service name="PDS">
                <port name="CMainSoapPort" binding="wsdlns:CMainSoapBinding">
                        <soap:address location="http://localhost/ProjectServer/PDS.WSDL"/>
                </port>
        </service>
</definitions>

--dDRMvlgZJXvWKvBx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=req

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><namesp3:SoapXMLRequest xmlns:namesp3="http://tempuri.org/message/"><sCookie xsi:type="xsd:string">svc={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}&session={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}&prxy={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}&org=xxxxxx</sCookie><sXML xsi:type="xsd:string"><Request><PDSInfo/></Request></sXML></namesp3:SoapXMLRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>

--dDRMvlgZJXvWKvBx--