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

I'm attempting to construct a SOAP request with SOAP::Lite and running into a problem. The request should look like this when it arrives at the server:

<?xml version="1.0" encoding="UTF-8" ?> - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/env +elope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http: +//www.w3.org/2001/XMLSchema-instance"> - <soapenv:Body> - <ns1:edfSubmit soapenv:encodingStyle="http://schemas.xmlsoap.org/soa +p/encoding/" xmlns:ns1="http://www.n-able.com/schemas/EDF/1.0"> <arg1 xsi:type="xsd:string">ABCDEFG1234</arg1> - <arg2 xsi:type="soapenc:Array" soapenc:arrayType="xsd:anyType[1]" xm +lns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <item href="#id0" /> </arg2> </ns1:edfSubmit> - <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://sc +hemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:T_EDFData" xmlns:soap +enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://Def +aultNamespace"> <delayToSend xsi:type="xsd:int">10</delayToSend> <errorMessage xsi:type="xsd:string" /> <jobID xsi:type="xsd:string">2</jobID> - <values xsi:type="soapenc:Array" soapenc:arrayType="xsd:anyType[3]"> <item href="#id1" /> <item href="#id2" /> <item href="#id3" /> </values> </multiRef> - <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://sc +hemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:T_EDFValues" xmlns:ns +3="http://DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org +/soap/encoding/"> <scanDetail xsi:type="xsd:string">detail2</scanDetail> <value xsi:type="xsd:string">value2</value> </multiRef> - <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://sc +hemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:T_EDFValues" xmlns:ns +4="http://DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org +/soap/encoding/"> <scanDetail xsi:type="xsd:string">detail1</scanDetail> <value xsi:type="xsd:string">value1</value> </multiRef> - <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://sc +hemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:T_EDFValues" xmlns:ns +5="http://DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org +/soap/encoding/"> <scanDetail xsi:type="xsd:string">detail3</scanDetail> <value xsi:type="xsd:string">value3</value> </multiRef> </soapenv:Body> </soapenv:Envelope>

Not all of this is important, only the fact that edfSubmit and multiRef are separate body parts in this request. I am attempting to use the following code to construct the request:

my $sl = SOAP::Lite ->uri("http://backup.united-systems.com") ->proxy("http://backup.united-systems.com/rpctest.pl"); my @headers = (SOAP::Data->name('edfSubmit')->attr({'ns1' => 'http://w +ww.n-able.com/schemas/EDF/1.0'})); my @data = (SOAP::Data->name('multiRef')->type('ns2:T_EDFData')); $sl->call('edfSubmit', @headers, @data);

Using the above code makes multiRef a child of edfSubmit. Is there any way to get around this using SOAP::Lite, or do I need to use some other SOAP class to properly construct this?

Replies are listed 'Best First'.
Re: Constructing a SOAP request
by Anonymous Monk on Nov 03, 2009 at 19:18 UTC