spring-bootjaxbcxfweblogic12c

Apache CXF SOAP JAXB issue on WebLogic 12c


We are using Java 8, Apache CXF as a SOAP client on top of Spring Boot to send SOAP messages to WS.

If the app is deployed as a WAR on Tomcat 8, the app works well and the SOAP client is sending the right XML messages with the right namespaces.

If the same app WAR is deployed on Weblogic 12c the SOAP message that is produced by the CXF SOAP client has missing namespaces.

We know that the WebLogic maybe uses some old JAXB jars that are responsible for creating the XML message from Java objects and they are different then the Tomcat server and this maybe the reason why we are seeing this issue.

We also know that we can specify in the weblogic.xml in the war file what jars the Weblogic needs to load from the war and what dependencies to load from directly from the Weblogic libraries, but every combination that we tried in the weblogic.xml does not work.

Any good advice will be fully appreciated

Sample XML output from Tomcat server with Apache CXF

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
    <event xmlns="http://www.test.com" xmlns:ns5="http://www.test2.com" xmlns:ns3="urn:test1:1423.15465:123123:namespace">
        <ns5:created-date-time>2020-08-12T08:02:35Z</ns5:created-date-time>
        <ns5:payload>
            <Test2>
                <ns3:ID>f14bb</ns3:ID>
                <ns3:createdDateTime>2020-08-12T08:02:35Z</ns3:createdDateTime>
            </Test2>
        </ns5:payload>
    </event>
</env:Body>

</env:Envelope>

Sample code from Weblogic 12c

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
    <event xmlns="http://www.test.com" xmlns:ns5="http://www.test2.com">
        <ns5:created-date-time>2020-08-12T08:02:35Z</ns5:created-date-time>
        <ns5:payload>
            <Test2>
                <ID>f14bb</ID>
                <createdDateTime>2020-08-12T08:02:35Z</createdDateTime>
            </Test2>
        </ns5:payload>
    </event>
</env:Body>

</env:Envelope>

The "urn:test1:1423.15465:123123:namespace" is completely ignored in the weblogic server making this XML message not valid by the consumer

weblogic.xml we are trying to tell weblogic to load our classes from the war file instead of the JaxB classes from the web logic but without success

<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>java.xml.bind.*</wls:package-name>
        <wls:package-name>org.apache.cxf.*</wls:package-name>
        <wls:package-name>javax.xml.ws.*</wls:package-name>
        <wls:package-name>javax.wsdl.*</wls:package-name>
</wls:prefer-application-resources>
    </wls:container-descriptor>

Except this issue everything else is working fine, the Apache CXF is sending correct in multiple scenarios, just in one is it not adding the namespace we need


Solution

  • This issue was solved by updating the package-info.java

    @javax.xml.bind.annotation.XmlSchema(namespace = "urn:test1",
        xmlns = {@XmlNs(prefix = "",
             namespaceURI = "http://www.test.com")},
        elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
    

    This is the part of the package-info that was not been there before

    xmlns = {@XmlNs(prefix = "", namespaceURI = "http://www.test.com")}

    adding the namespace trick JavaXB to add the original namespace