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

D

droesler

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
 
J

J. Gleixner

droesler said:
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.
 
D

droesler

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>
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
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>
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;


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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top