I am having a hard time with sending SOAP / .NET "complex" structures. If I send the following response, my .NET (well, .NET WebServiceStudio) does not recognize the response -- it comes back with a "null" as the value of the string.

<?xml version="1.0" encoding="utf-16"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x +mlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="h +ttp://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.x +mlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soa +p/envelope/"> <soap:Body> <Test1Response xmlns="urn:TESTServices"> <OutData xsi:type="typens:MyStringType" xmlns:typens="urn:TESTSe +rvices"> <MyStringType xsi:type="xsd:string">Hi There</MyStringType> </OutData> </Test1Response> </soap:Body> </soap:Envelope>

If I hardcode the return string to the above, I get the same response. However, if I change the attributes on the "Test1Response" tag above to be <namesp1:Test1Response xmlns:namesp1="urn:TESTServices">, all works fine.

<?xml version="1.0" encoding="utf-16"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x +mlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="h +ttp://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.x +mlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soa +p/envelope/"> <soap:Body> <namesp1:Test1Response xmlns:namesp1="urn:TESTServices"> <OutData xsi:type="typens:MyStringType" xmlns:typens="urn:TESTSe +rvices"> <MyStringType xsi:type="xsd:string">Hi There</MyStringType> </OutData> </namesp1:Test1Response> </soap:Body> </soap:Envelope>

My function in my handler is:

sub Test1 { my $self = shift; my $envelope = pop; my $indata = $envelope->valueof('/Envelope/Body/*/InData'); my $d= ( SOAP::Data ->name( 'OutData' => \SOAP::Data ->value( SOAP::Data->name('MyStringType' => 'Hi There') ) ) ->attr({ 'xmlns:typens' => 'urn:TESTServices', 'xsi:type' => 'typens:MyStringType', }, ) ); return $d; }

Does anyone have a good example of how to add the explicit namespace tag to the service name (the first child of the Body tag) using SOAP::Lite? I am not specifying the tag, I think it is supplied by SOAP::Lite.

Thanks,

update: Missed name space on closing tag.

--MidLifeXis


In reply to SOAP::Lite, .NET, and complex structures by MidLifeXis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.