How to suppress methodName element in soap:Body of envelope with SOAP::Lite

Discussion in 'Perl Misc' started by droesler, Aug 29, 2010.

  1. droesler

    droesler Guest

    Hi,

    Is there a way to suppress the surrounding methodName element of the
    soap:Body section of the SOAP envelope?

    The web service sends a fault back saying there is an unknown part
    (the methodName element) in the request. This web service is
    implemented as a doc/literal type if that makes a difference.

    I looked at SOAP::Serializer but it wasn't clear to me how to apply
    that to the SOAP object being sent with the methodName call.

    It doesn't make any difference if I use the wsdl method or the lower
    level uri/proxy method.

    #/usr/bin/per
    use strict;
    use warnings;
    use SOAP::Lite;

    my $svc = SOAP::Lite ->service(q{,,,wsdl location ...});
    my $result = $svc->methodName( <method params> );

    or

    my $soap = SOAP::Lite ->uri(...) ->on_action( sub{...}) ->proxy(...);
    my $result = $soap->methodName(<method params>);

    I thought using the wsdl method would construct the required soap:Body
    part, but testing the web service in a tool such as soapUI it doesn't
    wrap the soap:Body contents with a methodName element.

    Thanks

    Dennis
     
    droesler, Aug 29, 2010
    #1
    1. Advertising

  2. droesler

    J. Gleixner Guest

    Re: How to suppress methodName element in soap:Body of envelope with

    droesler wrote:
    > Hi,
    >
    > Is there a way to suppress the surrounding methodName element of the
    > soap:Body section of the SOAP envelope?


    No idea what that means. Soap:Envelope and Soap:Body should be
    the first two elements in the request, the method should be within
    the Soap:Body element. How is the Web service supposed to know what
    method to run, if it's not sent in the request? Maybe the Web Service is
    poorly designed? Maybe it's a namespace issue? Who knows...

    At least show some of the XML in question.
    Show what's expected by the service and what's being sent by
    your client.

    If the service is in .NET, you have to do more work in Soap::Lite.
    Look around the Internet for steps to take.

    Also, to help you debug things, you can see what's sent/received,
    be enabling trace:

    use SOAP::Lite +trace;

    If all else fails, you might be able to take the expected XML
    request, modify it to suit your needs, and POST it.
     
    J. Gleixner, Aug 30, 2010
    #2
    1. Advertising

  3. droesler

    droesler Guest

    On Aug 30, 2:53 pm, "J. Gleixner" <>
    wrote:
    > droesler wrote:
    > > Is there a way to suppress the surrounding methodName element of the
    > > soap:Body section of the SOAP envelope?

    >
    > No idea what that means. Soap:Envelope and Soap:Body should be
    > the first two elements in the request, the method should be within
    > the Soap:Body element.


    For simplification and ignoring namespaces for now... if the payload
    gets serialized to

    <el1>
    <el2>some value</el2>
    </el1>

    and the method is myMethod then Soap:Body will be

    <myMethod>
    <el1>
    <el2>some value</el2>
    </el1>
    </myMethod>


    >How is the Web service supposed to know what
    > method to run, if it's not sent in the request?


    From what I can determine it is based on the soapAction header value.
    But this may be dependent on whether it is a rpc/literal or doc/
    literal WS.
    Also, from what I can determine is that doc/literal is not necessarily
    expecting the <myMethod><payload/></myMethod> construct in Soap:Body,
    but I could certainly be way off on this understanding.

    > Maybe the Web Service is poorly designed?


    Could be, but it's from a major software company - but could still be
    poorly designed.


    > At least show some of the XML in question.
    > Show what's expected by the service and what's being sent by
    > your client.


    Their supplied .wsdl says it is expecting

    <topLevelTag> <!-- this is not the method name -->
    <Wrapper>
    <el1>
    <el2>some value</el2>
    </el1>
    </Wrapper>
    </topLevelTag>

    > If the service is in .NET, you have to do more work in Soap::Lite.


    It is and I used the recommended on_action method.

    > Look around the Internet for steps to take.


    I did that as well. From what I can tell this seems to be a rpc/
    [encoded|literal] vs. doc/literal issue.
    Which from what I find on the Internet is something that SOAP::Lite
    doesn't deal with well.

    > Also, to help you debug things, you can see what's sent/received, by enabling trace:
    >
    > use SOAP::Lite +trace;


    Done this as well. The vendor's WS responds with <methodName> is an
    unknown part of the Soap:Body

    >
    > If all else fails, you might be able to take the expected XML
    > request, modify it to suit your needs, and POST it.


    Interestingly enough if I construct a SOAP client and call it as shown
    below this satisfies their .wsdl and works.
    As you can see there is no mention of the method except in the
    on_action method.

    #!/usr/bin/perl

    use strict;
    use warnings;
    use SOAP::Lite (+trace => all, maptype => {});

    my $query = qq{<ns:el1> <ns:el2>some value</ns:el2> </ns:el1>};
    my $server = q{http://server.example.com};
    my $pathInfo = q{?really/long/pathInfo/for/ws};

    my $url = qq{$server$pathInfo};

    my $svc = SOAP::Lite
    -> uri("http://example.com/ns/")
    -> on_action( sub{ return q{"document/http://example.com/
    ns/:MethodName"} } )
    -> proxy($url)
    -> autotype(0)
    -> readable(1)
    -> ns('http://example.com/ns/', 'ns');

    my $arg1 = SOAP::Data->name('WrapperTagForQuery' => $query)-
    >prefix('ns');

    my $method = SOAP::Data->name('SpoofMethodName')->prefix('ns');
    my $som = $svc->call($method => $arg1);

    This will generate a Soap:Body section like

    <ns:SpoofMethodName>
    <ns:WrapperTagForQuery>
    <ns:el1>
    <ns:el2>some value</ns:el2>
    </ns:el1>
    </ns:WrapperTagForQuery>
    </ns:SpoofMethodName>
     
    droesler, Aug 31, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Nentwig
    Replies:
    11
    Views:
    667
    Dale King
    Nov 10, 2003
  2. plork123
    Replies:
    1
    Views:
    969
  3. cxc
    Replies:
    0
    Views:
    6,467
  4. Aaron Brady

    SQL, lite lite lite

    Aaron Brady, Dec 29, 2008, in forum: Python
    Replies:
    15
    Views:
    772
    Aaron Brady
    Jan 1, 2009
  5. doug
    Replies:
    2
    Views:
    267
Loading...

Share This Page