Search code examples
web-servicescxfwsdl2java

Apache CXF wsdl2java InternalError: unresolved reference


I'm trying to generate Java sources for a Web Service with Apache CXF wsdl2java executable (I've tried 2.7.8 and 3.2.0 versions).

My wsdl file come from an external agency (TMDD), so I assume is well generated

When I tried to generate files first time, a "Non-unique body parts" error occur:

org.apache.cxf.tools.common.ToolException: Non-unique body parts! In a port, operations must have unique operation signatures on the wire for successful dispatching. In port {http://www.tmdd.org/303/dialogs}tmddOCSoapHttpServicePort, operations "{http://www.tmdd.org/303/dialogs}dlVideoSwitchStatusRequest" and "{http://www.tmdd.org/303/dialogs}dlIntersectionSignalStatusRequest" have the same request body block {http://www.tmdd.org/303/messages}deviceInformationRequestMsg

    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.validate(WSDLToJavaContainer.java:735)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:276)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:185)

I solved it creating a new input message type in dlVideoSwitchStatusRequest operation to avoid this. My steps were:

  1. Create a new message type

    <message name="MSG_VideoSwitchStatusRequest"> <part name="message" element="tmdd:videoSwitchStatusRequestMsg"/> </message>

  2. Declare videoSwitchStatusRequestMsg

    <xs:element name="videoSwitchStatusRequestMsg" type="VideoSwitchStatusRequest"> <xs:annotation> <xs:documentation> <objectClass>VideoSwitch</objectClass> <requirement>REQ1109</requirement> </xs:documentation> </xs:annotation> </xs:element>

    This one is defined in .xsd file as similar ones for other operations.

  3. Modify input type for that operation

    <operation name="dlVideoSwitchStatusRequest">
        <documentation><objectClass>VideoSwitch</objectClass><objectClass>ExternalCenter</objectClass><objectClass>OwnerCenter</objectClass><msgPattern>R-R</msgPattern><requirement>REQ538</requirement></documentation>
        <input message="tns:MSG_VideoSwitchStatusRequest"/>    <!-- This is the new type -->
        <!--<input message="tns:MSG_DeviceInformationRequest"/>  This is the old one --> 
        <output message="tns:MSG_VideoSwitchStatus"/>
        <fault name="errorReport" message="tns:MSG_ErrorReport"/>
    </operation>
    

With this, that error was solved (i think), but now i get another error

Exception in thread "main" java.lang.InternalError: unresolved reference
    at com.sun.xml.xsom.impl.parser.DelayedRef._get(DelayedRef.java:103)
    at com.sun.xml.xsom.impl.parser.DelayedRef$Type.getType(DelayedRef.java:148)
    at com.sun.xml.xsom.impl.ElementDecl.getType(ElementDecl.java:110)
    at com.sun.xml.xsom.impl.ElementDecl.updateSubstitutabilityMap(ElementDecl.java:174)
    at com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:141)
    at com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:214)
    at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:538)
    at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
    at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:95)
    at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:459)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:723)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:267)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:185)

This one is too generic and I didn't found any info or doc from Apache site.


Solution

  • Well, as B. Leal suggest, i drop old tmdd.wsdl and re-do my wsdl files with separate files for each device i will need data for.

    As most work has been re-done, i'm not 100% sure about where that error came from, but i'm pretty sure that it was related with some types used in the old wsdl that wasn't declared properly in xsd files.

    I know this is not a big help, but if someone falls in this same error, i think you only have two choices:

    • Re-do your wsdl files, as i did. (I recommend this one, it's easier than it seems)
    • Check if every single type used in wsdl are present in xsd files and if they're correct.

    Thanks for help.