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"
       <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.mycompany.com/MyService">
       <element name="login">
       <element name="customerId" type="xsd:string"/>
       <element name="userId" type="xsd:string"/>
       <element name="password" type="xsd:string"/>
       <element name="loginResponse">
       <element name="sessionId" type="xsd:int"/>
       <element name="MyServiceFault">
       <element name="errorCode" type="xsd:string"/>
       <element name="errorMessage" type="xsd:string"/>
       <message name="loginRequest">
       <part name="parameters" element="tns:login"/>
       <message name="loginResponse">
       <part name="result" element="tns:loginResponse"/>
       <message name="MyServiceFaultMessage">
       <part name="fault" element="tns:MyServiceFault"/>
       <portType name="MyServiceEndpoint">
       <operation name="login">
       <input message="tns:loginRequest"/>
       <output message="tns:loginResponse"/>
       <fault name="MyServiceFault" message="tns:MyServiceFaultMessage"/>
       <binding name="MyServiceEndpointBinding" type="tns:MyServiceEndpoint">
       <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="login">
       <soap:body use="literal"/>
       <soap:body use="literal"/>
       <fault name="MyServiceFault">
       <soap:fault name="MyServiceFault" use="literal"/>
       <service name="MyService">
       <port name="MyServiceEndpointPort" binding="tns:MyServiceEndpointBinding">
       <soap:address location="REPLACE_WITH_ACTUAL_URL"/>

        • 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 ...