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 Bill Keese <bi...@tech.beacon-it.co.jp> on 2005/01/12 10:41:24 UTC

wrapped/literal: complex return value

I have a few questions about return values from a method in a
wrapped/literal server.

(1) My getUser() method returns a structure:

User getUser(String id);

I know that for wrapped/literal the input message should be
<soapenv:Body>
<getUser>
<id>jsmith</id>
</getUser>
</soapenv:Body>

What should the response be, such that a client's generated stubs (for
wrapped/literal mode) don't contain any unnecessary structures? IE, if
this is the return value:

<soapenv:Body>
<getUserResponse>
<user>
<name>John Smith</name>
<address>10 Main St.</address>
</user>
</getUser>
</soapenv:Body>

Will .NET generate a function stub like this?
User getUser(String id)

or will it generate a stub like this?

GetUserResponse getUser(String id);

where GetUserResponse is a dummy wrapper class like this:

class GetUserResponse { User user; }

(2) Has anyone gotten this to work with Axis? I hand-wrote my WSDL file,
and then used WSDL2Java to generate the deploy.wsdd file. I see two
problems in my testing but I wonder if anyone can confirm or deny.
a) Axis seems to want to print 2 nested tags
<soapenv:Body>
<getUserResponse>
<getUserResult>
...
</getUserResult>
</getUserResponse
I think <getUserResponse> is parallel to the <getUser> (wrapper tag),
and <getUserResult> is possibly to differentiate between the return
value and output parameters.

b) The <user> tag itself is not printed; only the fields inside of the
User class are printed. It's as though Axis is assuming the User class
is a wrapper class that contains a list of output values

Can anyone comment on these things? Thanks!
Bill

Re: wrapped/literal: complex return value

Posted by Anne Thomas Manes <at...@gmail.com>.
<soap:Body> cannot contain text content, so the response must be
returned as a child element of the <soap:Body>. Also, when using
wrapped or document, the message part must reference an element, not a
type.

So what I'm saying is that wrapped/literal is doc/literal. Elements
that you define as your request and response message parts are what
will be sent as the child element of the <soap:Body>. e.g.:

<wsdl:message name="getUserRequest">
 <wsdl:part name="parameters" element="tns:getUser"/>
</wsdl:message>

results in:

<soapenv:Body>
   <tns:getUser xmlns:tns="..." />
</soapenv:Body>
 
and 

<wsdl:message name="getUserResponse">
 <wsdl:part name="parameters" element="tns:user"/>
</wsdl:message>

results in 

<soapenv:Body>
   <tns:user xmlns:tns="..." />
</soapenv:Body>


Whether using wrapped or document style, the <soap:Body> must contain
at most one direct child element. (i.e., at most one body part). When
using wrapped, the convention is that the request message body part
element has the same name as the operation name. There's no specific
convention for the return message, but it should map to the return
value for the operation.

When using document, the request message body part doesn't have the
same name as the operation, but it still must contain at most one
part.

-Anne

On Thu, 13 Jan 2005 12:43:03 +0900, Bill Keese
<bi...@tech.beacon-it.co.jp> wrote:
> Cool, thanks!   Are you implying that document/literal and wrapped/literal
> are the same w.r.t. the return value?  The difference is only for the
> request?
> 
> Also, does your answer implay that a scalar return value can be represented
> simply like this?
> 
> <soapenv:Body>
>   Hello World!
> </soapenv:Body>
> 
> And the WSDL would be this?
> <wsdl:message name="getUserResponse">
 <wsdl:part name="parameters"
> type="xsd:string"/>
</wsdl:message>
Bill
> 
> 
> Anne Thomas Manes wrote: 
> If you want your return value to be a User object, then that should be
your
> return structure, not getUserResponse.
> i.e.,

<soapenv:Body>
<user>
<name>John Smith</name>
<address>10 Main
> St.</address>
</user>
</soapenv:Body>


The output message should be defined
> so:

<wsdl:message name="getUserResponse">
 <wsdl:part name="parameters"
> element="tns:user"/>
</wsdl:message>

- Anne

On Wed, 12 Jan 2005 18:41:24
> +0900, Bill Keese
<bi...@tech.beacon-it.co.jp> wrote:
 
> I have a few questions about return values from a method in
> a
wrapped/literal server.

(1) My getUser() method returns a
> structure:

User getUser(String id);

I know that for wrapped/literal the
> input message should
> be
<soapenv:Body>
<getUser>
<id>jsmith</id>
</getUser>
</soapenv:Body>

What
> should the response be, such that a client's generated stubs
> (for
wrapped/literal mode) don't contain any unnecessary structures? IE,
> if
this is the return
> value:

<soapenv:Body>
<getUserResponse>
<user>
<name>John
> Smith</name>
<address>10 Main
> St.</address>
</user>
</getUser>
</soapenv:Body>

Will .NET generate a
> function stub like this?
User getUser(String id)

or will it generate a stub
> like this?

GetUserResponse getUser(String id);

where GetUserResponse is a
> dummy wrapper class like this:

class GetUserResponse { User user; }

(2)
> Has anyone gotten this to work with Axis? I hand-wrote my WSDL file,
and
> then used WSDL2Java to generate the deploy.wsdd file. I see two
problems in
> my testing but I wonder if anyone can confirm or deny.
a) Axis seems to want
> to print 2 nested
> tags
<soapenv:Body>
<getUserResponse>
<getUserResult>
...
</getUserResult>
</getUserResponse
I
> think <getUserResponse> is parallel to the <getUser> (wrapper tag),
and
> <getUserResult> is possibly to differentiate between the return
value and
> output parameters.

b) The <user> tag itself is not printed; only the fields
> inside of the
User class are printed. It's as though Axis is assuming the
> User class
is a wrapper class that contains a list of output values

Can
> anyone comment on these things? Thanks!
Bill

Re: wrapped/literal: complex return value

Posted by Anne Thomas Manes <at...@gmail.com>.
If you want your return value to be a User object, then that should be
your return structure, not getUserResponse. i.e.,

<soapenv:Body>
<user>
<name>John Smith</name>
<address>10 Main St.</address>
</user>
</soapenv:Body>


The output message should be defined so:

<wsdl:message name="getUserResponse">
 <wsdl:part name="parameters" element="tns:user"/>
</wsdl:message>

- Anne

On Wed, 12 Jan 2005 18:41:24 +0900, Bill Keese
<bi...@tech.beacon-it.co.jp> wrote:
> I have a few questions about return values from a method in a
> wrapped/literal server.
> 
> (1) My getUser() method returns a structure:
> 
> User getUser(String id);
> 
> I know that for wrapped/literal the input message should be
> <soapenv:Body>
> <getUser>
> <id>jsmith</id>
> </getUser>
> </soapenv:Body>
> 
> What should the response be, such that a client's generated stubs (for
> wrapped/literal mode) don't contain any unnecessary structures? IE, if
> this is the return value:
> 
> <soapenv:Body>
> <getUserResponse>
> <user>
> <name>John Smith</name>
> <address>10 Main St.</address>
> </user>
> </getUser>
> </soapenv:Body>
> 
> Will .NET generate a function stub like this?
> User getUser(String id)
> 
> or will it generate a stub like this?
> 
> GetUserResponse getUser(String id);
> 
> where GetUserResponse is a dummy wrapper class like this:
> 
> class GetUserResponse { User user; }
> 
> (2) Has anyone gotten this to work with Axis? I hand-wrote my WSDL file,
> and then used WSDL2Java to generate the deploy.wsdd file. I see two
> problems in my testing but I wonder if anyone can confirm or deny.
> a) Axis seems to want to print 2 nested tags
> <soapenv:Body>
> <getUserResponse>
> <getUserResult>
> ...
> </getUserResult>
> </getUserResponse
> I think <getUserResponse> is parallel to the <getUser> (wrapper tag),
> and <getUserResult> is possibly to differentiate between the return
> value and output parameters.
> 
> b) The <user> tag itself is not printed; only the fields inside of the
> User class are printed. It's as though Axis is assuming the User class
> is a wrapper class that contains a list of output values
> 
> Can anyone comment on these things? Thanks!
> Bill
>