Dale1990 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to write a very simple client to a web service. There is one service I need to call that accepts 4 input strings and returns one. From the wsdl of the service:
- <complexType name="submitToRemedyForm"> - <sequence> <element name="String_1" nillable="true" type="string" /> <element name="String_2" nillable="true" type="string" /> <element name="String_3" nillable="true" type="string" /> <element name="String_4" nillable="true" type="string" /> </sequence> </complexType>
I am using this code:
use SOAP::Lite +trace => debug; my $service = SOAP::Lite->service('https://remabsintcert/remedyAbstrac +tService/remedyAbstractService_1_0?wsdl'); print $service->submitToRemedyForm( SOAP::Data->name(String_1 => 'login'), SOAP::Data->name(String_2 => 'password'), SOAP::Data->name(String_3 => 'form'), SOAP::Data->name(String_4 => 'xxxxxxx'), );
According to the debug output, the SOAP xml is missing the String_1 value and adding some other tag. Here is the output cleaned up a little.
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:ns2="http://xxx.com/remedyAbstractService_1_0/typ +es" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xm +lns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="h +ttp://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.or +g/2001/XMLSchema-instance" xmlns:tns="http://xxx.com/remedyAbstractSe +rvice_1_0/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <tns:submitToRemedyForm> <submitToRemedyForm xsi:nil="true" xsi:type="tns:submitToRemedyFor +m" /> <String_2 xsi:type="xsd:string">password</String_2> <String_3 xsi:type="xsd:string">form</String_3> <String_4 xsi:type="xsd:string">xxxxxxx</String_4> </tns:submitToRemedyForm> </soap:Body></soap:Envelope>
I'm getting a client error when I try to run the code. I was able to submit the request from a different app (soapUI) and it returns the expected response so I know the service is working properly. Soap::Lite seems to be doing things to the formatting and structure to cause errors. A working request looks like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:typ="http://xxx/remedyAbstractService_1_0/types"> <soapenv:Header/> <soapenv:Body> <typ:submitToRemedyForm> <String_1>login</String_1> <String_2>password</String_2> <String_3>form</String_3> <String_4>xxxxxx</String_4> </typ:submitToRemedyForm> </soapenv:Body> </soapenv:Envelope>
What do I have to do to Soap::Lite to get it to create a request that looks like the working one? Thanks!

Replies are listed 'Best First'.
Re: Confusing results from Soap Lite
by Anonymous Monk on Nov 06, 2008 at 02:25 UTC
    It seems to work fine, but maybe I'd get different results with a WSDL.

    perl soap-data-swallow2.pl |xml_pp

    #!/usr/bin/perl -- use strict; use warnings; use SOAP::Lite; use SOAP::Lite 0.65 +trace => 'debug'; my $soap = SOAP::Lite ->proxy( 'http://localhost/blah/DummyService' ); print $soap->serializer()->envelope( method => 'submitToRemedyForm', SOAP::Data->name(String_1 => 'login'), SOAP::Data->name(String_2 => 'password'), SOAP::Data->name(String_3 => 'form'), SOAP::Data->name(String_4 => 'xxxxxxx'), ); __END__ <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http:/ +/www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSche +ma-instance"> <soap:Body> <submitToRemedyForm> <String_1 xsi:type="xsd:string">login</String_1> <String_2 xsi:type="xsd:string">password</String_2> <String_3 xsi:type="xsd:string">form</String_3> <String_4 xsi:type="xsd:string">xxxxxxx</String_4> </submitToRemedyForm> </soap:Body> </soap:Envelope>
    SOAP::Lite 0.710.08