Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3105

jaxws customization parameter renaming not working

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.11
    • 2.2.12, 2.3.1
    • None
    • None

    Description

      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[@name='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[@name='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[@name='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.
      I'll try to provide a test case and patch here too.

      Timo

      Attachments

        1. ParameterProcessor.java.patch
          4 kB
          Timo Heck
        2. ws-binding.xml
          2 kB
          Timo Heck
        3. flowcenter.wsdl
          7 kB
          Timo Heck

        Activity

          People

            dkulp Daniel Kulp
            heck Timo Heck
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: