1 Reply Latest reply on Apr 30, 2009 6:39 AM by Bart Vanhaute

    WebFault targetNamespace and document/literal

    Bart Vanhaute Newbie

      It looks like there is a problem with the namespace for web faults when this is not the same as the namespace of the service. The type definition of the web faults has the correct namespace, but the reference to the type from the messsage elements uses the name space of the service instead.

      For example:

      package zzz.ws.flt;
      
      import javax.xml.bind.annotation.XmlType;
      import javax.xml.ws.WebFault;
      
      @WebFault(targetNamespace="zzz.ws.flt")
      @XmlType(namespace="zzz.ws.flt")
      public class ZZZException extends Exception {
       private String info;
      
       public ZZZException(String info) {
       this.setInfo(info);
       }
      
       public void setInfo(String info) {
       this.info = info;
       }
      
       public String getInfo() {
       return info;
       }
      }

      and
      package zzz.ws.srv.impl;
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.ParameterStyle;
      import javax.jws.soap.SOAPBinding.Style;
      import javax.jws.soap.SOAPBinding.Use;
      
      import zzz.ws.flt.ZZZException;
      import zzz.ws.srv.ZZZService;
      
      @Stateless
      @Remote(ZZZService.class)
      @WebService(targetNamespace="zzz.ws.srv", name="ZZZService")
      @SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.WRAPPED)
      public class ZZZServiceImpl implements ZZZService {
      
       @WebMethod
       public String echo(String input) throws ZZZException {
       return input;
       }
      }


      generates

      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name="ZZZServiceImplService" targetNamespace="zzz.ws.srv" xmlns:tns="zzz.ws.srv" xmlns:ns1="zzz.ws.flt" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
       <types>
       <xs:schema targetNamespace="zzz.ws.srv" version="1.0" xmlns:tns="zzz.ws.srv" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:element name="echo" type="tns:echo"/>
       <xs:element name="echoResponse" type="tns:echoResponse"/>
       <xs:complexType name="echo">
       <xs:sequence>
       <xs:element minOccurs="0" name="arg0" type="xs:string"/>
       </xs:sequence>
       </xs:complexType>
       <xs:complexType name="echoResponse">
       <xs:sequence>
       <xs:element minOccurs="0" name="return" type="xs:string"/>
       </xs:sequence>
       </xs:complexType>
       </xs:schema>
       <xs:schema targetNamespace="zzz.ws.flt" version="1.0" xmlns:tns="zzz.ws.flt" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:element name="ZZZException" type="tns:ZZZException"/>
       <xs:complexType name="ZZZException">
       <xs:sequence>
       <xs:element minOccurs="0" name="info" type="xs:string"/>
       <xs:element minOccurs="0" name="message" type="xs:string"/>
       </xs:sequence>
       </xs:complexType>
       </xs:schema>
       </types>
       <message name="ZZZService_echo">
       <part name="echo" element="tns:echo">
       </part>
       </message>
       <message name="ZZZException">
       <part name="ZZZException" element="tns:ZZZException">
       </part>
       </message>
       <message name="ZZZService_echoResponse">
       <part name="echoResponse" element="tns:echoResponse">
       </part>
       </message>
       <portType name="ZZZService">
       <operation name="echo" parameterOrder="echo">
       <input message="tns:ZZZService_echo">
       </input>
       <output message="tns:ZZZService_echoResponse">
       </output>
       <fault name="ZZZException" message="tns:ZZZException">
       </fault>
       </operation>
       </portType>
       <binding name="ZZZServiceBinding" type="tns:ZZZService">
       <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
       <operation name="echo">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal"/>
       </input>
       <output>
       <soap:body use="literal"/>
       </output>
       <fault name="ZZZException">
       <soap:fault name="ZZZException" use="literal"/>
       </fault>
       </operation>
       </binding>
       <service name="ZZZServiceImplService">
       <port name="ZZZServicePort" binding="tns:ZZZServiceBinding">
       <soap:address location="http://jbossws.undefined.host:8080/zzz-zzzservice-ejb/ZZZServiceImpl"/>
       </port>
       </service>
      </definitions>


      Notice the element="tns:ZZZException" in the output.

      This is running jbossws-native-3.1.0.GA on jboss-4.2.3.GA.