3 Replies Latest reply on Sep 18, 2007 4:44 PM by Bernhard Pauler

    Custom exception/fault with JBoss & JWSDP

    Bernhard Pauler Newbie

      I'm struggling with this issue for a good while now - I hope somebody can help me...

      I want to develop a web service interface with methods that throw a custom exception. I have been using the developerWorks article on exception handling (http://www.ibm.com/developerworks/webservices/library/ws-tip-jaxrpc.html) and samples provided by web service toolkits like Axis as guides for my own implementation.

      But JBoss (4.2.1.GA) keeps printing the following messages while deploying my WAR file:

      19:25:26,031 WARN [JAXRPCMetaDataBuilder] Cannot obtain java type mapping for: {http://www.mycompany/MyService}>MyServiceFault
      19:25:26,109 WARN [SchemaBindingBuilder] Type definition not found in schema: {http://www.mycompany.com/MyService}MyServiceFault
      19:25:26,109 WARN [SchemaBindingBuilder] Cannot obtain type binding for: {http://www.mycompany.com/MyService}MyServiceFault


      I start with a handwritten WSDL file (see below) and use the JWSDP tools (2.0) to generate the server-side artifacts and the JAX-RPC mapping file (as outlined in the book "JBoss at Work").

      I tried the WSDL file of the faulthandling sample that comes with Apache Axis2 (1.3, bank.wsdl) and get the same messages.

      Any ideas? Do I have to use the wstools that come with JBossWS to get this thing working?

      Here is my WSDL file:

      <?xml version="1.0" encoding="utf-8"?>
      
      <definitions name="MyService"
       xmlns ="http://schemas.xmlsoap.org/wsdl/"
       xmlns:xsd ="http://www.w3.org/2001/XMLSchema"
       xmlns:soap ="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:mime ="http://schemas.xmlsoap.org/wsdl/mime/"
       xmlns:tns ="http://www.mycompany.com/MyService"
       targetNamespace="http://www.mycompany.com/MyService">
      
       <types>
       <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.mycompany.com/MyService">
       <element name="login">
       <complexType>
       <sequence>
       <element name="customerId" type="xsd:string"/>
       <element name="userId" type="xsd:string"/>
       <element name="password" type="xsd:string"/>
       </sequence>
       </complexType>
       </element>
       <element name="loginResponse">
       <complexType>
       <sequence>
       <element name="sessionId" type="xsd:int"/>
       </sequence>
       </complexType>
       </element>
       <element name="MyServiceFault">
       <complexType>
       <sequence>
       <element name="errorCode" type="xsd:string"/>
       <element name="errorMessage" type="xsd:string"/>
       </sequence>
       </complexType>
       </element>
       </schema>
       </types>
      
       <message name="loginRequest">
       <part name="parameters" element="tns:login"/>
       </message>
       <message name="loginResponse">
       <part name="result" element="tns:loginResponse"/>
       </message>
       <message name="MyServiceFaultMessage">
       <part name="fault" element="tns:MyServiceFault"/>
       </message>
      
       <portType name="MyServiceEndpoint">
       <operation name="login">
       <input message="tns:loginRequest"/>
       <output message="tns:loginResponse"/>
       <fault name="MyServiceFault" message="tns:MyServiceFaultMessage"/>
       </operation>
       </portType>
      
       <binding name="MyServiceEndpointBinding" type="tns:MyServiceEndpoint">
       <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="login">
       <input>
       <soap:body use="literal"/>
       </input>
       <output>
       <soap:body use="literal"/>
       </output>
       <fault name="MyServiceFault">
       <soap:fault name="MyServiceFault" use="literal"/>
       </fault>
       </operation>
       </binding>
      
       <service name="MyService">
       <port name="MyServiceEndpointPort" binding="tns:MyServiceEndpointBinding">
       <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
       </port>
       </service>
      
      </definitions>


        • 1. Re: Custom exception/fault with JBoss & JWSDP
          Richard Opalka Newbie

          I think you should use wstools that ships with JBoss AS you're using

          • 2. Re: Custom exception/fault with JBoss & JWSDP
            Bernhard Pauler Newbie

            I will try that and post my results later. Thank you.

            • 3. Re: Custom exception/fault with JBoss & JWSDP
              Bernhard Pauler Newbie

              I tried it - and it worked with the wstools.

              BUT ...

              Besides the custom exception I have to work with attachments. With the definition of attachments in place I really had a hard time with the wstools. I tried really hard - but I had to step back to the wscompile tool of the JWSDP which just worked without fiddling.

              I wanted to solve the custom exception issue though so I investigated once more and compared the generated artifacts/descriptors of the two tools.

              And I finally found the difference - it was in the jaxrpc-mapping.xml:

              JWSDP - wscompile

              <root-type-qname xmlns:typeNS="http://myservice.mycompany.com/myservice">typeNS:MyServiceFault</root-type-qname>

              JBoss - wstools
              <anonymous-type-qname xmlns:typeNS="http://myservice.mycompany.com/myservice">typeNS:>MyServiceFault</anonymous-type-qname>


              I don't know who to blame. The generated "root-type-qname" tag of the wscompile tool looks fishy if you compare it to the other tags in the same mapping file - and in fact JBoss can't seem to deal with it.
              Replace that line with the line the wstools generate and the warnings are gone and the custom exception mechanism is working. :)

              That's the solution to my problem now. Not a beautiful solution - but it works and I can't invest more time at the moment. Hope this helps somebody ...

              Bernhard