You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Heck, Timo" <T....@d-nb.de> on 2010/11/01 10:23:15 UTC

AW: jaxws customization parameter renaming not working

Thanks Daniel,

I filed the issue:
https://issues.apache.org/jira/browse/CXF-3105

I'll see what I can do to provide more information.

Timo

-- 

Timo Heck
Deutsche Nationalbibliothek
Informationstechnik
Adickesallee 1
D-60322 Frankfurt am Main
Tel.: +49-69-1525-1792
Fax: +49-69-1525-1799
mailto:t.heck@d-nb.de
http://www.d-nb.de
>-----Ursprüngliche Nachricht-----
>Von: Daniel Kulp [mailto:dkulp@apache.org]
>Gesendet: Freitag, 29. Oktober 2010 21:55
>An: users@cxf.apache.org
>Cc: Heck, Timo
>Betreff: Re: jaxws customization parameter renaming not working
>
>
>This definitley looks like a bug.   Can you log a JIRA issue and attach a test
>case?
>
>If you would like to try debugging and fixing it, the bug is likely someplace
>in
>org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ParameterProcessor.
>
>There are a couple calls to JAXWSParameter.getElementName in there that may
>not be working correctly.   It sound like it's not matching the message names
>up correctly (or at all) or similar.  Not 100% sure though.  That would be the
>place to look though.
>
>Dan
>
>
>On Friday 29 October 2010 10:50:44 am heck wrote:
>> Hi,
>>
>> I am working on this for a couple of days now with actually finding a
>> solution. I am building a ws client from wsdl with CXF wsdl2Java version
>> 2.2.11.
>>
>> The problem is an element naming issue in the wsdl. As far as I do
>> understand I have three choices:
>> 1. disable wrapper style
>> 2. use autoNameResolution feature
>> 3. write my own customization and rename the parameters
>>
>> I verified options 1 and 2. Both solves the problem. But I'd like to have
>> more control over the generated interface so I'd like to explicitly set the
>> parameter names.
>>
>> This is how it looks like:
>> Wsdl describes a webservice with a method called login().
>> This is how request and response definitions look like.
>>
>> <xsd:element name="login">
>>             <xsd:complexType>
>>             	<xsd:sequence>
>>             		<xsd:element name="login" type="fc:flowloginrequest"/>
>>             		<xsd:element name="switchusergroup" type="xsd:int"
>> maxOccurs="1" minOccurs="0"/>
>>             	</xsd:sequence>
>>             </xsd:complexType>
>>             </xsd:element>
>>
>>             <xsd:element name="loginResponse">
>>             	<xsd:complexType>
>>             		<xsd:sequence>
>>             			<xsd:element name="login"
>type="fc:flowloginresponse"/>
>>             			<xsd:element name="password_temp"
>type="xsd:string"/>
>>             			<xsd:element name="usergrouplist"
>> type="fc:flowidnamepairs"/> <xsd:element name="permissions"
>> type="xsd:string"/> <xsd:element name="usertype" type="xsd:string"/>
>>             			<xsd:element name="usertypeid"
>type="xsd:string"/>
>>             		</xsd:sequence>
>>             	</xsd:complexType>
>>             </xsd:element>
>>
>> Request and response both hold a local element called login. This is
>> causing the trouble I have and if I try to generate code with wrapper
>> style enabled this is what I get:
>> WSDLToJava Error: Element login has the same name with different types
>>
>> If I rename the two local elements to loginRequest (fc:flowloginrequest)
>> and loginResponse (fc:flowloginresponse) everything runs just fine. Since
>> I can't actually adjust the schema (it's not mine) I have to write my own
>> customization file.
>>
>> To solve the problem I wanted to rename the method parameter for both
>> elements. This is what found by examining JAX-WS spec.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <jaxws:bindings wsdlLocation="flowcenter.wsdl"
>>           xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>>           xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
>>           xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>>           xmlns:fc="http://www.flowworks.de/flowworks/"
>>           xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb
>> http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
>>           	http://java.sun.com/xml/ns/jaxws
>> http://java.sun.com/xml/ns/jaxws/wsdl_customizationschema_2_0.xsd">
>>
>>   <!-- rename method parameters-->
>>   <jaxws:bindings
>> node="wsdl:definitions/wsdl:portType[@name='flowcenter']/wsdl:operation[@na
>> me='login']"> <jaxws:parameter
>>
>part="wsdl:definitions/wsdl:message[@name='loginRequest']/wsdl:part[@name='
>> parameters']" childElementName="login" name="loginRequest"/>
>>   	<jaxws:parameter
>>
>part="wsdl:definitions/wsdl:message[@name='loginResponse']/wsdl:part[@name=
>> 'parameters']" childElementName="login" name="loginResponse"/>
>>   </jaxws:bindings>
>> </jaxws:bindings>
>>
>> I thought this would do the trick but it doesn't. Even more confusing is
>> that if I run the tool with -autoNameResolution and check the code the
>> service interface does show part of my declared names above. It looks like
>> this.
>>
>> login( Flowloginrequest loginResponse,
>>         Integer switchusergroup,
>>         Holder<Flowloginresponse> login,
>>         Holder<java.lang.String> passwordTemp,
>>         Holder<Flowidnamepairs> usergrouplist,
>>         Holder<java.lang.String> permissions,
>>         Holder<java.lang.String> usertype,
>>         Holder<java.lang.String> usertypeid
>>     )
>>
>> Note the login parameter from request is renamed to loginResponse and
>> response parameter name is ignored. To make this a little more interesting
>> I changed the binding declaration to this:
>>
>> <!-- rename method parameters-->
>>   <jaxws:bindings
>> node="wsdl:definitions/wsdl:portType[@name='flowcenter']/wsdl:operation[@na
>> me='login']"> <jaxws:parameter
>>
>part="wsdl:definitions/wsdl:message[@name='loginRequest']/wsdl:part[@name='
>> parameters']" childElementName="login" name="loginRequest"/>
>>   </jaxws:bindings>
>> <jaxws:bindings
>> node="wsdl:definitions/wsdl:portType[@name='flowcenter']/wsdl:operation[@na
>> me='login']"> <jaxws:parameter
>>
>part="wsdl:definitions/wsdl:message[@name='loginResponse']/wsdl:part[@name=
>> 'parameters']" childElementName="login" name="loginResponse"/>
>>   </jaxws:bindings>
>>
>> This is what the method signature looks like:
>>
>> login( Flowloginrequest loginRequest,
>>         Integer switchusergroup,
>>         Holder<Flowloginresponse> login,
>>         Holder<java.lang.String> passwordTemp,
>>         Holder<Flowidnamepairs> usergrouplist,
>>         Holder<java.lang.String> permissions,
>>         Holder<java.lang.String> usertype,
>>         Holder<java.lang.String> usertypeid
>>     )
>>
>> So I think I am not completely wrong trying to solve this issue by applying
>> a customization file but something is not working right. Can somebody help
>> me to figure out what's actually happening?
>>
>> Timo
>
>--
>Daniel Kulp
>dkulp@apache.org
>http://dankulp.com/blog