You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by John Baker <jb...@sasami.atomised.org> on 2005/07/13 11:23:26 UTC

Basic SOAP Understanding Question

Hi,

If I have a webservice with the method signature:

public boolean doSomething(String s);

I am wondering what the format of a SOAP request should be. I appreciate the
SOAP request is crafted from the WSDL, but I'm looking at some other calls
and I'm trying to figure out which part of the SOAP request tells the server
to call doSomething. For example, an Axis client sends this in a POST
request to a SOAP server:

SOAPAction: "http://wwww.blah.com/something/else/doSomething"

Which suggests to me that the method that the SOAP message is relevant for
is passed in the HTTP header. Would it be valid to then have a SOAP message:

<soapenv:Body>
  <ns1:s>Some string</ns1:s>
</soapenv:Body>

I.e. so no reference is made to the method that the client wishes to call?



John



Re: Basic SOAP Understanding Question

Posted by Anne Thomas Manes <at...@gmail.com>.
Per the SOAP spec (and clarified in the WS-I Basic Profile), the SOAP
processor is supposed to determine how to process an incoming request
based on the "signature" of the incoming message. The "signature" is
defined as the QName of the child element of the SOAP Body. The WS-I
Basic Profile defines a rule that all service operations must have a
unique signature (disallowing overloaded methods). The SOAPAction
header, which is used only with HTTP, can be used as a "hint" for
dispatching, but the SOAP processor should not rely on the SOAPAction
for definitive dispatching information.

When using RPC style for your method signature:

        public boolean doSomething(String s);

the QName of the child element of the SOAP Body will be
<ns1:doSomething> where "ns1" is the namespace specified in the
<soap:body> definition in the WSDL file. The
<wsdl:message> will look something like this:

  <wsdl:message name="doSomethingRequest">
     <wsdl:part name="s" type="xsd:string"/>
  </wsdl:message>

And it will produce a SOAP message something like this:

  <soapenv:Body xmlns:soapenv="...">
    <ns1:doSomething xmlns:ns1="some-uri">
       <s>Some string</s>
    </ns1:doSomething>
  </soapenv:Body>

When using Document style, the QName of the child element of the SOAP
Body will be the QName of the element referenced in the <wsdl:part>
definition in the input message for the operation. If you use the
"wrapped" convention, then the child element will have the same local
name as the operation name, and therefore it's easy to match the
message signature to the method signature. e.g., the <wsdl:message> 
description will look something like this:

  <wsdl:message name="doSomethingRequest">
     <wsdl:part name="parameters" element="ns1:doSomething"/>
  </wsdl:message>

where "ns1:doSomething" is defined in the <types> section like this:

  <xsd:element name="doSomething">
    <xsd:complexType>
      <xsd:sequence>
         <xsd:element name="s" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

and the SOAP message looks something like this:

  <soapenv:Body xmlns:soapenv="...">
    <ns1:doSomething xmlns:ns1="some-uri">
       <s>Some string</s>
    </ns1:doSomething>
  </soapenv:Body>

Things get trickier is you used the "unwrapped" convention. In that
case you might have a <wsdl:message> defined like this:

  <wsdl:message name="doSomethingRequest">
     <wsdl:part name="body" element="ns1:s"/>
  </wsdl:message>

And "ns1:s" defined thus:

    <xsd:element name="s" type="xsd:string"/>

producing a SOAP message like this: 

   <soapenv:Body xmlns:soapenv="...">
     <ns1:s xmlns:ns1="some-uri">Some string</ns1:s>
   </soapenv:Body>

Now, obviously this message doesn't indicate the method name,
therefore you must define an <operation> definition in your WSDD that
tells Axis how to map the "ns1:s" QName to the doSomething method:

   <deployment xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <service name="doSomethingService" 
             provider="java:RPC"
             xmlns:ns1="some-uri">
        <operation qname="ns1:s"
             name="doSomething" />
    </service>
</deployment>

But as a general rule, I always recommend using the "wrapped" convention.

Anne

On 7/13/05, John Baker <jb...@sasami.atomised.org> wrote:
> Hi,
> 
> If I have a webservice with the method signature:
> 
> public boolean doSomething(String s);
> 
> I am wondering what the format of a SOAP request should be. I appreciate the
> SOAP request is crafted from the WSDL, but I'm looking at some other calls
> and I'm trying to figure out which part of the SOAP request tells the server
> to call doSomething. For example, an Axis client sends this in a POST
> request to a SOAP server:
> 
> SOAPAction: "http://wwww.blah.com/something/else/doSomething"
> 
> Which suggests to me that the method that the SOAP message is relevant for
> is passed in the HTTP header. Would it be valid to then have a SOAP message:
> 
> <soapenv:Body>
>   <ns1:s>Some string</ns1:s>
> </soapenv:Body>
> 
> I.e. so no reference is made to the method that the client wishes to call?
> 
> 
> 
> John
> 
> 
>