[MOBY-dev] SOAP::Lite claims support for document/literal

Edward Kawas edward.kawas at gmail.com
Mon Sep 8 15:16:08 UTC 2008


Hi Jason,

One of the problems that I have with soap lite and trying to perform doc/lit
requests/responses is the inability to use attributes in the request. 

Since that statement doesn't make too much sense (to some it might have ;-),
I will provide an example:

I modified the wsdl that you sent to include an attribute in the givenName
element, so that a request now looks like:

<q0:sayHello>
  <name>Joe Blow</name> 
  <givenName middlename="Windy">Joe</givenName> 
</q0:sayHello>

The server side code is simply: 

sub sayHello {
  SOAP::Data->name('sayHelloResult')->value(  Dumper(\@_) );
}

So all that I am doing is dumping whatever is sent to the server.

The response is 

<sayHelloResponse xmlns="urn:HelloWorld">
  <sayHelloResult xsi:type="xsd:string">$VAR1 = [ 'HelloWorld', 'Joe Blow',
'Joe' ];</sayHelloResult> 
</sayHelloResponse>

I do believe that this is one of the biggest stumbling blocks so far.
Because numerous Moby api calls use attributes. One such example is the
retrieveService call.

My dispatcher code is below!

Eddie

------ CODE START -----
#!/usr/bin/perl -w
# _________________________________________________________________


use SOAP::Transport::HTTP;

if ($ENV{REQUEST_METHOD} eq "GET") {
 if (lc($ENV{QUERY_STRING} || "") eq "wsdl") {
   require CGI;
   my $q = CGI->new();
   my $wsdl = HelloWorld::wsdl();
   my $c = length($wsdl);
   print $q->header(-type=>'application/xml',-Content-length=>$c);
   print "$wsdl";
 } 
} else {
 my $x = new SOAP::Transport::HTTP::CGI;
 $x->dispatch_to('/var/www/cgi-bin', 'HelloWorld');
 $x->handle;
}

package HelloWorld;
use Data::Dumper;

sub sayHello {
SOAP::Data->name('sayHelloResult')->value(  Dumper(\@_) );
}

sub wsdl {

return <<EOF;
<?xml version="1.0" encoding="UTF-8" ?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:HelloWorld"
	targetNamespace="urn:HelloWorld"
	xmlns="http://schemas.xmlsoap.org/wsdl/">
	<types>
		<s:schema targetNamespace="urn:HelloWorld">
			<s:element name="sayHello">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0"
maxOccurs="1"
							name="name"
type="s:string" />
						<s:element minOccurs="0"
maxOccurs="1"
							name="givenName"
nillable="1">
							<s:complexType>
	
<s:simpleContent>
	
<s:extension base="s:string">
	
<s:attribute name="middlename"
	
use="required" type="s:string">
	
</s:attribute>
	
</s:extension>
	
</s:simpleContent>
							</s:complexType>
						</s:element>
					</s:sequence>
				</s:complexType>
			</s:element>

			<s:element name="sayHelloResponse">
				<s:complexType>
					<s:sequence>
						<s:element minOccurs="0"
maxOccurs="1"
	
name="sayHelloResult" type="s:string" />
					</s:sequence>
				</s:complexType>
			</s:element>
		</s:schema>
	</types>
	<message name="sayHelloSoapIn">
		<part name="parameters" element="s0:sayHello" />
	</message>
	<message name="sayHelloSoapOut">
		<part name="parameters" element="s0:sayHelloResponse" />
	</message>

	<portType name="Service1Soap">
		<operation name="sayHello">
			<input message="s0:sayHelloSoapIn" />
			<output message="s0:sayHelloSoapOut" />
		</operation>
	</portType>

	<binding name="Service1Soap" type="s0:Service1Soap">
		<soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
			style="document" />
		<operation name="sayHello">
			<soap:operation soapAction="urn:HelloWorld#sayHello"
/>
			<input>
				<soap:body use="literal" />
			</input>
			<output>
				<soap:body use="literal" />
			</output>
		</operation>
	</binding>
	<service name="HelloWorld">
		<port name="HelloWorldSoap" binding="s0:Service1Soap">
			<soap:address
	
location="http://ubuntu.localhost/cgi-bin/doc-lit.pl" />
		</port>
	</service>
</definitions>
EOF

}
1;
------ CODE END  ------




-----Original Message-----
From: moby-dev-bounces at lists.open-bio.org
[mailto:moby-dev-bounces at lists.open-bio.org] On Behalf Of Jason Stewart
Sent: September-08-08 4:07 AM
To: Core developer announcements
Subject: [MOBY-dev] SOAP::Lite claims support for document/literal

Hey Moby-devs,

The version of SOAP::Lite in CVS claims to support Document/literal
encoding - I need help determing if this support is sufficient. Can
you look this over?

=head3 DOCUMENT/LITERAL

SOAP web services using the document/literal message encoding are usually
described by some Web Service Definition. Our web service has the following
WSDL description:

 <?xml version="1.0" encoding="UTF-8"?>
 <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:s="http://www.w3.org/2001/XMLSchema"
   xmlns:s0="urn:HelloWorld"
   targetNamespace="urn:HelloWorld"
   xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <s:schema targetNamespace="urn:HelloWorld">
      <s:element name="sayHello">
        <s:complexType>
          <s:sequence>
             <s:element minOccurs="0" maxOccurs="1" name="name"
type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="givenName"
type="s:string" nillable="1" />
          </s:sequence>
         </s:complexType>
       </s:element>

       <s:element name="sayHelloResponse">
         <s:complexType>
           <s:sequence>
             <s:element minOccurs="0" maxOccurs="1"
name="sayHelloResult" type="s:string" />
           </s:sequence>
       </s:complexType>
     </s:element>
   </types>
   <message name="sayHelloSoapIn">
     <part name="parameters" element="s0:sayHello" />
   </message>
   <message name="sayHelloSoapOut">
     <part name="parameters" element="s0:sayHelloResponse" />
   </message>

   <portType name="Service1Soap">
     <operation name="sayHello">
       <input message="s0:sayHelloSoapIn" />
       <output message="s0:sayHelloSoapOut" />
     </operation>
   </portType>

   <binding name="Service1Soap" type="s0:Service1Soap">
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
         style="document" />
     <operation name="sayHello">
       <soap:operation soapAction="urn:HelloWorld#sayHello"/>
       <input>
         <soap:body use="literal" />
       </input>
       <output>
         <soap:body use="literal" />
       </output>
     </operation>
   </binding>
   <service name="HelloWorld">
     <port name="HelloWorldSoap" binding="s0:Service1Soap">
       <soap:address location="http://localhost:80//helloworld.pl" />
     </port>
   </service>
 </definitions>

The XML message (inside the SOAP Envelope) look like this:

 <sayHello xmlns="urn:HelloWorld">
  <name>Kutter</name>
  <givenName>Martin</givenName>
 </sayHello>

 <sayHelloResponse>
  <sayHelloResult>Hello Martin Kutter!</sayHelloResult>
 </sayHelloResponse>

You can call this web service with the following client code:

 use SOAP::Lite;
 my $soap = SOAP::Lite->new( proxy => 'http://localhost:80/helloworld.pl');

 $soap->on_action( sub { "urn:HelloWorld#sayHello" });
 $soap->autotype(0);
 $soap->default_ns('urn:HelloWorld');

 my $som = $soap->call("sayHello",
   SOAP::Data->name('name')->value( 'Kutter' ),
   SOAP::Data->name('givenName')->value('Martin'),
);

 die $som->fault->{ faultstring } if ($som->fault);
 print $som->result, "\n";

=head2 Differences between the implementations

You may have noticed that there's no between the rpc/literal
and the document/literal example's implementation. In fact, from
SOAP::Lite's
point of view, the only differences between rpc/literal and document/literal
that parameters are always named.

In our example, the rpc/literal variant already used named parameters (by
using a single complexType only as positional parameter), so there's no
difference at all.

The differences would have been bigger if the rpc/literal example had used
more than one positional parameter, but this is quite unlikely to happen in
the future: Current interoperability standards (like the WS-I basic profile)
mandate the use of a single complexType as only parameter in rpc/literal
calls.

-- snip --

Help me on this one - is this valid? Is it sufficient for what MOBY
and the rest of the Perl world needs? I suggest that I test this claim
against:
* perl SOAP::Lite client = axis Java server
* java client = perl SOAP::Lite server

I could use some suggestions for how to make these tests useful.

Cheers, jas.
_______________________________________________
MOBY-dev mailing list
MOBY-dev at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/moby-dev




More information about the MOBY-dev mailing list