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 Grzegorz Chwajol <gc...@gmail.com> on 2006/07/07 12:55:05 UTC

wrapped document/literal style - a few questions

Hi all,

I have a few questions concerning wrapped document/literal style (they
are not directly related to Axis, but I hope someone can help).

First concerns oneway messages.
On IBM developerworks site I found something like this:

at <types> part:

<element name="myMethodResponse">
            <complexType/>
</element>

and message:

<message name="empty">
    <part name="parameters" element="myMethodResponse"/>
</message>

and finally operation at porttype:

<operation name="myMethod">
        <input message="myMethodRequest"/>
        <output message="empty"/>
</operation>

Does it mean that in the wrapped style I just must not leave
<output message="empty"/> in oneway message?

If so, what if I have several oneway operations - does each of them
have to have its own element in <types> with empty complextype and
corresponding <message>? Or can I reuse the same "empty" <message> for
all oneway messages?

And, at the end, what if I have a few operations which reuse the same
type for parameter or/and returning value, eg.:
void setAgentName(String agentName)
String getAgentName()
Will it be enough to put:
<element name="AgentName">
      <complexType>
            <sequence>
                 <element name="name" type="xsd:string"/>
            </sequence>
      </complexType>
</element>

and corresponding messages:
<message name="setAgentNameRequest">
    <part name="parameters" element="AgentName"/>
</message>

<message name="getAgentNameResponse">
    <part name="parameters" element="AgentName"/>
</message>

or should each operation have separate element in <types>?


Thanks in advance,
cheers
-- 
Grzegorz Chwajoł

Re: wrapped document/literal style - a few questions

Posted by Anne Thomas Manes <at...@gmail.com>.
Yes -- this is correct.

On 7/7/06, Grzegorz Chwajol <gc...@gmail.com> wrote:
> Thank you very much, Anne, for your deep explanation, it helped me a lot.
> However, I have a question yet:
>
> > My preference is to define a
> > complexType called "void" and to define specific return message
> > elements which are of type "void". For example:
> >
> >     <s:complexType name="void">
> >          <s:sequence/>
> >     </s:complexType>
> >
> >     <s:element name="MyMethodReturn" type="tns:void"/>
> >
> >     <w:message name="MyMessageResponse">
> >         <w:part name="parameters" element="MyMethodReturn"/>
> >     </w:message>
>
> For to be sure:
> may I apply this in a similar way into input messages for several
> operations with no input parameters?
> For example:
> String myFirstMethod();
> String mySecondMethod();
>
>
> <s:complexType name="void">
>     <s:sequence/>
> </s:complexType>
>
> <s:element name="myFirstMethod" type="tns:void"/>
> <s:element name="mySecondMethod" type="tns:void"/>
>
> <w:message name="myFirstMethodRequest">
>   <w:part name="parameters" element="myFirstMethod"/>
> </w:message>
>
> <w:message name="mySecondMethodRequest">
>   <w:part name="parameters" element="mySecondMethod"/>
> </w:message>
>
> Is this correct and is this a proper way of doing to assure interoperability?
>
> Regards,
> --
> Grzegorz Chwajoł
>

Re: wrapped document/literal style - a few questions

Posted by Grzegorz Chwajol <gc...@gmail.com>.
Thank you very much, Anne, for your deep explanation, it helped me a lot.
However, I have a question yet:

> My preference is to define a
> complexType called "void" and to define specific return message
> elements which are of type "void". For example:
>
>     <s:complexType name="void">
>          <s:sequence/>
>     </s:complexType>
>
>     <s:element name="MyMethodReturn" type="tns:void"/>
>
>     <w:message name="MyMessageResponse">
>         <w:part name="parameters" element="MyMethodReturn"/>
>     </w:message>

For to be sure:
may I apply this in a similar way into input messages for several
operations with no input parameters?
For example:
String myFirstMethod();
String mySecondMethod();


<s:complexType name="void">
    <s:sequence/>
</s:complexType>

<s:element name="myFirstMethod" type="tns:void"/>
<s:element name="mySecondMethod" type="tns:void"/>

<w:message name="myFirstMethodRequest">
  <w:part name="parameters" element="myFirstMethod"/>
</w:message>

<w:message name="mySecondMethodRequest">
  <w:part name="parameters" element="mySecondMethod"/>
</w:message>

Is this correct and is this a proper way of doing to assure interoperability?

Regards,
-- 
Grzegorz Chwajoł

Re: wrapped document/literal style - a few questions

Posted by Anne Thomas Manes <at...@gmail.com>.
On 7/7/06, Grzegorz Chwajol <gc...@gmail.com> wrote:
> Hi all,
>
> I have a few questions concerning wrapped document/literal style (they
> are not directly related to Axis, but I hope someone can help).

Answers inline...

>
> First concerns oneway messages.
> On IBM developerworks site I found something like this:
>
> at <types> part:
>
> <element name="myMethodResponse">
>             <complexType/>
> </element>
>
> and message:
>
> <message name="empty">
>     <part name="parameters" element="myMethodResponse"/>
> </message>
>
> and finally operation at porttype:
>
> <operation name="myMethod">
>         <input message="myMethodRequest"/>
>         <output message="empty"/>
> </operation>
>
> Does it mean that in the wrapped style I just must not leave
> <output message="empty"/> in oneway message?

If you have a response message (even if it's empty), then the
operation's message exchange pattern (MEP) is request/response, not
one-way. The purpose of the wrapped convention is to simulate RPC
style from a programming perspective when actually using document
style. In other words, the service interface accepts a sequence of
parameters (rather than a single input object) and returns a return
value. Therefore the wrapped convention applies only to
request/response messages. If you want to send a true one-way message,
then you must design your interface to accept an object rather than a
set of parameters (i.e., the element referenced by "myMethodRequest"),
and your operation must not specify an output message.

Note that when using one-way messages in SOAP 1.1, you have no way to
return a SOAP Fault. By defining the interface to return an empty
message, you can also return a Fault. You can think of the empty
message as simply an acknowledgement that the message was accepted --
but it is a request/response MEP, not a one-way MEP.

> If so, what if I have several oneway operations - does each of them
> have to have its own element in <types> with empty complextype and
> corresponding <message>? Or can I reuse the same "empty" <message> for
> all oneway messages?

Each operation must have a unique input message signature, but you can
reuse the empty message as output. My preference is to define a
complexType called "void" and to define specific return message
elements which are of type "void". For example:

    <s:complexType name="void">
         <s:sequence/>
    </s:complexType>

    <s:element name="MyMethodReturn" type="tns:void"/>

    <w:message name="MyMessageResponse">
        <w:part name="parameters" element="MyMethodReturn"/>
    </w:message>

>
> And, at the end, what if I have a few operations which reuse the same
> type for parameter or/and returning value, eg.:
> void setAgentName(String agentName)
> String getAgentName()
> Will it be enough to put:
> <element name="AgentName">
>       <complexType>
>             <sequence>
>                  <element name="name" type="xsd:string"/>
>             </sequence>
>       </complexType>
> </element>
>
> and corresponding messages:
> <message name="setAgentNameRequest">
>     <part name="parameters" element="AgentName"/>
> </message>
>
> <message name="getAgentNameResponse">
>     <part name="parameters" element="AgentName"/>
> </message>
>
> or should each operation have separate element in <types>?
>

Each operation must have a unique input message signature. The
signature is defined as the QName of the child of the SOAP Body --
which, in Document style, is the QName of the element referenced by
the input message part.

When using the wrapped convention, the element referenced by the input
message part must have the same local name as the operation -- it is a
"wrapper" element for the input parameters (hence the name of the
convention). For example, for an operation called "SetAgentName", the
message definition would look like this:

     <w:message name="SetAgentNameRequest">
         <w:part name="parameters" element="tns:SetAgentName"/>
     </w:message>

And the SetAgentName element would look something like this:

    <s:element name="SetAgentName">
       <s:complexType>
         <s:sequence>
           <element name="NewAgentName" type="tns:agentNameType"/>
         </s:sequence>
       </s:complexType>
    </s:element>

Alternatively, you might define it like this:

    <s:element name="SetAgentName">
       <s:complexType>
         <s:sequence>
           <element ref="tns:AgentName"/>
         </s:sequence>
       </s:complexType>
    </s:element>

In both cases, "SetAgentName" is a "wrapper" element. It must be
defined as a complexType composing a sequence of elements. The wrapper
element may not contain attributes.

Often you will use the same schema construct in multiple messages
(e.g., AgentName). Note that you can define the AgentName element only
once within a namespace, so if you use the *element* in multiple
structures, you must reference a global element definition
(ref="tns:AgentName") rather than redefine it.

My preference is to use types for reuse rather than elements (as I did
in the first example). But if you do so, you must give each instance
of the type a unique name within your namespace.

The wrapped convention is less strict about the format of return
messages, but typically your return messages are also wrapped, e.g.,

     <w:message name="GetAgentNameResponse">
         <w:part name="parameters" element="tns:GetAgentNameResponse"/>
     </w:message>

And the GetAgentNameResponse element would look something like this:

    <s:element name="GetAgentNameResponse">
       <s:complexType>
         <s:sequence>
           <element name="GetAgentNameReturn" type="tns:agentNameType"/>
         </s:sequence>
       </s:complexType>
    </s:element>

>
> Thanks in advance,
> cheers
> --
> Grzegorz Chwajoł
>