0 Replies Latest reply on May 17, 2012 4:17 PM by kimba74

    How do I register additional JAXB types during WS deploy?

    kimba74

      I have the following problem:

       

      Assuming I created a JSE Web Service using the JSR-181 annotations, I created the necessary JAXB classes, and deployed the WAR file to JBossAS 5.1 with the result that the following WSDL is being generated:

       

      <definitions name='AnyTestService' 
                        targetNamespace='urn:any:test:service:1.0'
                        xmlns='http://schemas.xmlsoap.org/wsdl/'
                        xmlns:ns1='urn:any:test:binding:one:1.0'
                        xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
                        xmlns:tns='urn:any:test:service:1.0'
                        xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
      <types>
        <xs:schema elementFormDefault='qualified' targetNamespace='urn:any:test:binding:one:1.0' version='1.0' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
         <xs:element name='AnyTestRequest'>
          <xs:complexType>
           <xs:sequence>
            <xs:element name='Name' type='xs:string'/>
            <xs:any namespace='##other' processContents='lax'/>
           </xs:sequence>
          </xs:complexType>
         </xs:element>
         <xs:element name='AnyTestResponse'>
          <xs:complexType>
           <xs:sequence>
            <xs:element name='Code' type='xs:int'/>
            <xs:element name='Status' type='xs:string'/>
           </xs:sequence>
          </xs:complexType>
         </xs:element>
        </xs:schema>
      </types>
      <message name='AnyTestSEI_Test'>
        <part element='ns1:AnyTestRequest' name='req'></part>
      </message>
      <message name='AnyTestSEI_TestResponse'>
        <part element='ns1:AnyTestResponse' name='res'></part>
      </message>
      <portType name='AnyTestSEI'>
        <operation name='Test' parameterOrder='req'>
         <input message='tns:AnyTestSEI_Test'></input>
         <output message='tns:AnyTestSEI_TestResponse'></output>
        </operation>
      </portType>
      <binding name='AnyTestSEIBinding' type='tns:AnyTestSEI'>
        <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
        <operation name='Test'>
         <soap:operation soapAction=''/>
         <input>
          <soap:body use='literal'/>
         </input>
         <output>
          <soap:body use='literal'/>
         </output>
        </operation>
      </binding>
      <service name='AnyTestService'>
        <port binding='tns:AnyTestSEIBinding' name='AnyTestPort'>
         <soap:address location='http://127.0.0.1:8080/sandbox/service/anytest'/>
        </port>
      </service>
      </definitions>
      

       

       

      Now I connect to the Web Service with for example soapUI and call it using the following SOAP message

       

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                    xmlns:urn="urn:any:test:binding:one:1.0"
                                    xmlns:lsb="urn:any:test:binding:two:1.0">
         <soapenv:Header/>
         <soapenv:Body>
            <urn:AnyTestRequest>
               <urn:Name>Test</urn:Name>
               <lsb:root>
                  <lsb:Status>Everything is OK</lsb:Status>
               </lsb:root>
            </urn:AnyTestRequest>
         </soapenv:Body>
      </soapenv:Envelope>
      

       

       

      When I handle the Web Service call in the implementation...

       

      package com.test.service.any;
      
      import com.test.binding.one.AnyTestRequest;
      import com.test.binding.one.AnyTestResponse;
      
      import javax.jws.WebService;
      
      @WebService(portName = "AnyTestPort",
            serviceName = "AnyTestService",
            targetNamespace = "urn:any:test:service:1.0",
            endpointInterface = "com.test.service.any.AnyTestSEI")
      public class AnyTestWS implements AnyTestSEI {
      
         public AnyTestResponse test(AnyTestRequest request) {
            System.out.println(request);
            if (request.getAny() != null)
               System.out.println("--> ANY=" + request.getAny().getClass());
            return new AnyTestResponse(200, "Received");
         }
      
      }
      

       

      ...the Class of the the "ANY" object is as expected org.apache.xerces.dom.ElementNSImpl

       

      Now I create a JAXB class com.test.binding.two.Root to handle the namespace urn:any:test:binding:two:1.0 (the one that was submitted as ANY object) package it as JAR file and bundle it in the WEB-INF/lib of the WAR file.

       

      How do I get JBossAS 5.1 to register this unreferenced JAXB type with the other JAXB types that will be handed to the JAXBContext before unmarshalling it?

       

      Thanks,

       

      Kimba