Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to suppress methodName element in soap:Body of envelope with SOAP::Lite

Reply
Thread Tools

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

 
 
droesler
Guest
Posts: n/a
 
      08-29-2010
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

 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      08-30-2010
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.
 
Reply With Quote
 
 
 
 
droesler
Guest
Posts: n/a
 
      08-31-2010
On Aug 30, 2:53*pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
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:ata->name('WrapperTagForQuery' => $query)-
>prefix('ns');

my $method = SOAP:ata->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>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
SAXException: Attribute "xmlns:env" was already specified for element "env:Envelope' Ankit Mehta Java 1 09-29-2006 09:24 PM
Unable to create envelope from given source because the root element is not named Envelope cxc Java 0 05-20-2005 10:02 PM
SOAPHeaderElement element = envelope.getHeaderByName plork123 Java 1 05-06-2005 08:09 PM
interface.methodname style declarations Timo Nentwig Java 11 11-10-2003 06:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57