You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Marcel Stör <ma...@frightanic.com> on 2012/08/18 13:44:42 UTC

Confused about OUT parameters vs. return types

WSDL and its mapping to Java never fail to puzzle me. Just don't see 
through...

Currently I'm confused about OUT parameters vs. return types.

The CXF example[1] explains that "If there is more than one output 
parameter, the second and subsequent output parameters map to method 
arguments (moreover, the values of these arguments must be passed using 
Holder types)."

That much seems clear. Then why is the mapping different for the two 
below scenarios?

<wsdl:operation name="method">
   <wsdl:output message="methodResponse" />

[Return type]
This WSDL/XSD produces a Java method that has a return type because the 
WSDL output message /references/ a complex type rather than declaring it 
"inline"?
<xs:element name="methodResponse">
   <xs:complexType>
     <xs:sequence>
       <xs:element ref="nsType"/>
       <xs:element ref="msType"/>
     </xs:sequence>
   </xs:complexType>
</xs:element>
<xs:complexType name="nsType">
   <xs:sequence>
     <xs:element ref="someType" minOccurs="0" maxOccurs="unbounded"/>
   </xs:sequence>
</xs:complexType>
<xs:complexType name="msType">
   <xs:sequence>
     <xs:element ref="someType" minOccurs="0" maxOccurs="unbounded"/>
   </xs:sequence>
</xs:complexType>

[OUT parameter]
This WSDL/XSD produces a Java method with those terrible Holders as OUT 
parameters.
<xs:element name="methodResponse">
   <xs:complexType>
     <xs:sequence>
       <xs:element name="nsType" minOccurs="1" maxOccurs="1">
         <xs:complexType>
           <xs:sequence>
             <xs:element ref="someType" minOccurs="0" 
maxOccurs="unbounded"/>
           </xs:sequence>
         </xs:complexType>
       </xs:element>


I found similar questions in the archive[2][3] but I still don't get it.

Cheers,
Marcel

[1] 
http://cxf.apache.org/docs/developing-a-consumer.html#DevelopingaConsumer-Example3
[2] 
http://cxf.547215.n5.nabble.com/How-to-avoid-that-multiple-WebParam-Mode-OUT-params-are-generated-td4587065.html
[3] 
http://cxf.547215.n5.nabble.com/wsdl2java-avoiding-INOUT-parameters-in-wrapper-style-td2827683.html 


-- 
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

Re: Confused about OUT parameters vs. return types

Posted by Daniel Kulp <dk...@apache.org>.
It definitely is fairly confusing, and I bet if you used the wsimport tool that comes with the JDK, you would get the holders for for both forms.   The refs:

>  <xs:element ref="nsType"/>

are interpreted a bit differently between CXF and the RI.   CXF (by default, there is the -allowElementRefs flag to wsdl2java) doesn't consider them as unwrappable and thus will put the operation in BARE mode when it encounters them.   The RI does consider them unwrappable and will generate the holders.

If you don't like the holders, the "official" way around it is to create a jaxws binding file that forces BARE mode on everything.   With CXF, the easier method is to just pass -bareMethods to wsdl2java.


Dan



On Aug 18, 2012, at 7:44 AM, Marcel Stör <ma...@frightanic.com> wrote:

> WSDL and its mapping to Java never fail to puzzle me. Just don't see through...
> 
> Currently I'm confused about OUT parameters vs. return types.
> 
> The CXF example[1] explains that "If there is more than one output parameter, the second and subsequent output parameters map to method arguments (moreover, the values of these arguments must be passed using Holder types)."
> 
> That much seems clear. Then why is the mapping different for the two below scenarios?
> 
> <wsdl:operation name="method">
>  <wsdl:output message="methodResponse" />
> 
> [Return type]
> This WSDL/XSD produces a Java method that has a return type because the WSDL output message /references/ a complex type rather than declaring it "inline"?
> <xs:element name="methodResponse">
>  <xs:complexType>
>    <xs:sequence>
>      <xs:element ref="nsType"/>
>      <xs:element ref="msType"/>
>    </xs:sequence>
>  </xs:complexType>
> </xs:element>
> <xs:complexType name="nsType">
>  <xs:sequence>
>    <xs:element ref="someType" minOccurs="0" maxOccurs="unbounded"/>
>  </xs:sequence>
> </xs:complexType>
> <xs:complexType name="msType">
>  <xs:sequence>
>    <xs:element ref="someType" minOccurs="0" maxOccurs="unbounded"/>
>  </xs:sequence>
> </xs:complexType>
> 
> [OUT parameter]
> This WSDL/XSD produces a Java method with those terrible Holders as OUT parameters.
> <xs:element name="methodResponse">
>  <xs:complexType>
>    <xs:sequence>
>      <xs:element name="nsType" minOccurs="1" maxOccurs="1">
>        <xs:complexType>
>          <xs:sequence>
>            <xs:element ref="someType" minOccurs="0" maxOccurs="unbounded"/>
>          </xs:sequence>
>        </xs:complexType>
>      </xs:element>
> 
> 
> I found similar questions in the archive[2][3] but I still don't get it.
> 
> Cheers,
> Marcel
> 
> [1] http://cxf.apache.org/docs/developing-a-consumer.html#DevelopingaConsumer-Example3
> [2] http://cxf.547215.n5.nabble.com/How-to-avoid-that-multiple-WebParam-Mode-OUT-params-are-generated-td4587065.html
> [3] http://cxf.547215.n5.nabble.com/wsdl2java-avoiding-INOUT-parameters-in-wrapper-style-td2827683.html 
> 
> -- 
> Marcel Stör, http://www.frightanic.com
> Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
> O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Confused about OUT parameters vs. return types

Posted by Glen Mazza <gm...@talend.com>.
It's been awhile since I've seen the holder types, but IIRC switching to 
non-wrapper style ( 
http://cxf.apache.org/docs/wsdl-to-java.html#WSDLtoJava-wrapperstyle) 
should get rid of the need for them.

Glen

On 08/18/2012 07:44 AM, Marcel Stör wrote:
> WSDL and its mapping to Java never fail to puzzle me. Just don't see 
> through...
>
> Currently I'm confused about OUT parameters vs. return types.
>
> The CXF example[1] explains that "If there is more than one output 
> parameter, the second and subsequent output parameters map to method 
> arguments (moreover, the values of these arguments must be passed 
> using Holder types)."
>
> That much seems clear. Then why is the mapping different for the two 
> below scenarios?
>
> <wsdl:operation name="method">
>   <wsdl:output message="methodResponse" />
>
> [Return type]
> This WSDL/XSD produces a Java method that has a return type because 
> the WSDL output message /references/ a complex type rather than 
> declaring it "inline"?
> <xs:element name="methodResponse">
>   <xs:complexType>
>     <xs:sequence>
>       <xs:element ref="nsType"/>
>       <xs:element ref="msType"/>
>     </xs:sequence>
>   </xs:complexType>
> </xs:element>
> <xs:complexType name="nsType">
>   <xs:sequence>
>     <xs:element ref="someType" minOccurs="0" maxOccurs="unbounded"/>
>   </xs:sequence>
> </xs:complexType>
> <xs:complexType name="msType">
>   <xs:sequence>
>     <xs:element ref="someType" minOccurs="0" maxOccurs="unbounded"/>
>   </xs:sequence>
> </xs:complexType>
>
> [OUT parameter]
> This WSDL/XSD produces a Java method with those terrible Holders as 
> OUT parameters.
> <xs:element name="methodResponse">
>   <xs:complexType>
>     <xs:sequence>
>       <xs:element name="nsType" minOccurs="1" maxOccurs="1">
>         <xs:complexType>
>           <xs:sequence>
>             <xs:element ref="someType" minOccurs="0" 
> maxOccurs="unbounded"/>
>           </xs:sequence>
>         </xs:complexType>
>       </xs:element>
>
>
> I found similar questions in the archive[2][3] but I still don't get it.
>
> Cheers,
> Marcel
>
> [1] 
> http://cxf.apache.org/docs/developing-a-consumer.html#DevelopingaConsumer-Example3
> [2] 
> http://cxf.547215.n5.nabble.com/How-to-avoid-that-multiple-WebParam-Mode-OUT-params-are-generated-td4587065.html
> [3] 
> http://cxf.547215.n5.nabble.com/wsdl2java-avoiding-INOUT-parameters-in-wrapper-style-td2827683.html 
>
>