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

I'm running Perl v5.8.0 built for i386-linux-thread-multi under Linux 2.4.21-57.ELsmp. Our SOAP::Lite is at v0.710.08. We're dealing with a picky SOAP client and have set up the following CGI dispatch file (use statements ommitted for brevity):

SOAP::Transport::HTTP::CGI ->dispatch_with({'http://echo.nasa.gov/v9/order/fulfillment' => 'OrderFulfillmentService'}) ->handle;

exit 0;

package OrderFulfillmentService;

sub Submit {return (SOAP::Data->name('SubmitResponse')->type('xml') ->value(ECHODataOrder::DataOrderRequest(@_)));}

Because of the way the SOAP client calls our Submit service, we have to use the dispatch_with() syntax. We successfully receive and process their communication and respond with something like this:

<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SubmitResponse xmlns="http://echo.nasa.gov/v9/order/fulfillment">
...
</SubmitResponse>
</soap:Body>
</soap:Envelope>

For some reason, SOAP::Lite automatically inserts the xmlns="http://echo.nasa.gov/v9/order/fulfillment" in the SubmitResponse tag. In any case, the SOAP client rejects our response. The authors of the SOAP client believe that we need to modify our SubmitResponse such that a prefix is added like this:

<order:SubmitResponse xmlns:order="http://echo.nasa.gov/v9/order/fulfillment">
...
</order:SubmitResponse>

I have tried adding various elements to our "{return (SOAP::Data->" statement like "->prefix('order')" and "->attr({prefix => 'order'}), but everything seems to be ignored. How can I specify the prefix of my SubmitResponse message/tag? Many thanks!
  • Comment on Setting the Prefix for a SOAP Response via SOAP::Data

Replies are listed 'Best First'.
Re: Setting the Prefix for a SOAP Response via SOAP::Data
by Anonymous Monk on Sep 17, 2008 at 07:33 UTC
    soap-lite xmlns:order -> Registering namespaces with SOAP::Lite

    So I would try
    sub Submit {return (SOAP::Data->name('SubmitResponse')->type('xml') -> +attr({'xmlns:order'="http://echo.nasa.gov/v9/order/fulfillment"})->va +lue(ECHODataOrder::DataOrderRequest(@_)));}
    Of course I would run it through perltidy first
    sub Submit { return ( SOAP::Data->name('SubmitResponse')->type('xml')->attr( { 'xmlns:order' = "http://echo.nasa.gov/v9/order/fulfillme +nt" } )->value( ECHODataOrder::DataOrderRequest(@_) ) ); }
    I don't know much about XML/SOAP, but I don't think the part you're interested in ('xmlns:order') is called a prefix :)