2 Replies Latest reply: Jan 17, 2013 11:49 AM by r035198x RSS

    Is it possible to rename a property when generate web service proxy?

    91703
      We have issue to generate client proxy because of following schema:

      <xs:complexType name="Provider">
      <xs:sequence>
      <xs:element minOccurs="0" name="SSN" nillable="true" type="xs:string"/>
      <xs:element minOccurs="0" name="Ssn" nillable="true" type="xs:string"/>
      </xs:sequence>
      </xs:complexType>

      This is from our vendor's wsdl file. Two "ssn" with different case are intentionally kept for backward compatibility. Is there a way to get around the issue? Here is the error message:

      Caused by: java.lang.IllegalArgumentException: trying to create the same field twice: ssn
           at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:419)
           at com.sun.codemodel.JDefinedClass.field(JDefinedClass.java:390)
           at com.sun.tools.xjc.generator.bean.field.AbstractFieldWithVar.createField(AbstractFieldWithVar.java:72)
           at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField.java:89)
           at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField.java:76)
           at sun.reflect.GeneratedConstructorAccessor175.newInstance(Unknown Source)
           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
           at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
           at com.sun.tools.xjc.generator.bean.field.GenericFieldRenderer.generate(GenericFieldRenderer.java:64)
           at com.sun.tools.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFieldRenderer.java:79)
           at com.sun.tools.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.java:754)
           at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.java:542)
           at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:242)
           at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:182)
           at com.sun.tools.xjc.model.Model.generateCode(Model.java:286)
           at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:252)
           at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:85)
           at com.sun.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:134)
           at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2255)
           at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:194)
           at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:140)
           at com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:261)
           at oracle.jdevimpl.webservices.tools.weblogic.JDevWsimportTool.buildWsdlModel(JDevWsimportTool.java:381)
           at oracle.jdevimpl.webservices.tools.weblogic.JDevWsimportTool.buildWsdlModel(JDevWsimportTool.java:344)
           at oracle.jdevimpl.webservices.tools.weblogic.JDevWsimportTool.access$000(JDevWsimportTool.java:91)
           at oracle.jdevimpl.webservices.tools.weblogic.JDevWsimportTool$1.derrive(JDevWsimportTool.java:161)
           at oracle.jdevimpl.webservices.tools.weblogic.JDevWsimportTool$1.derrive(JDevWsimportTool.java:157)
           at oracle.javatools.util.deferred.DerivedCache$CachedResource.get(DerivedCache.java:144)
        • 1. Re: Is it possible to rename a property when generate web service proxy?
          91703
          I tried to add a binding file to change one of the ssn to ssn1. Now The error message changed to "[ERROR] Two declarations cause a collision in the ObjectFactory class." We noticed if we generate the client proxy with default setting. It works fine (for other web services). Once we start to customize the generated code by changing package name or in this particular case change property name, Jdeveloper starts to complain the name collision. Does anyone know how to solve this? We prefer not to rename those names since there are too many name collisions. Besides the generated code will deviate from document too much if we try to rename those names with conflict.
          • 2. Re: Is it possible to rename a property when generate web service proxy?
            r035198x
            Worst case you should be able to add xjc extensions to override some of the names in the xsd so that the generated property names do not clash