Perhaps this article that discusses Exception handling in JAX-WS services
would be helpful:

http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-and-exceptions-in-java-jaxws-web-services.html



Mark


On Tue, Feb 19, 2013 at 8:26 AM, galvanni <[email protected]> wrote:

> Getting this exception in my JAX-WS dynamic proxy.  The AckResponse is a
> valid response type as declared in the WSDL - when things go right that
> works fine.  However, when a fault is thrown because of a validation error
> e.g., below response, the client cannot unmarshal the fault.  Looking for
> some assistance with this as I'm now at a loss to what's going on here.
>
> The exception...
>
> javax.xml.ws.soap.SOAPFaultException: Unexpected element
> {http://schemas.xmlsoap.org/soap/envelope/}Body found.   Expected
> {http://mhs.mckesson.com/common/schema/AckResponseV1}Response.
>         at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
>
>
> --------------------------------------------------------------------------------
>
> When I trace the response envelope it looks like this - looks fine to me.
> We have a custom fault container type i.e.,
> http://mhs.mckesson.com/common/schema/FaultV1 in the detail section but
> that
> should be valid as well according to the wsdl.
>
>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>         <soap:Body>
>                 <SOAP-ENV:Body xmlns:SOAP-ENV="
> http://schemas.xmlsoap.org/soap/envelope/";>
>                     <SOAP-ENV:Fault>
>                         <faultcode
> xmlns:env="http://www.w3.org/2003/05/soap-envelope";>env:Sender</faultcode>
>                         <faultstring>Contract has a contractee with
> invalid type "No Entity
> Type"</faultstring>
>                         <faultactor>provider.createContract</faultactor>
>                         <detail>
>                                 <Fault xmlns="
> http://mhs.mckesson.com/common/schema/FaultV1";>
>                                         <Event code="70050">
>                                                 <Desc
> xmlns="http://mhs.mckesson.com/common/schema/CommonV1";>Invalid entity
> id</Desc>
>                                         </Event>
>                                 </Fault>
>                         </detail>
>                     </SOAP-ENV:Fault>
>                 </SOAP-ENV:Body>
>         </soap:Body>
> </soap:Envelope>
>
>
> --------------------------------------------------------------------------------
>
> And the WSDL for this service.
>
>
> <wsdl:definitions
> targetNamespace="
> http://mhs.mckesson.com/contracting/contract/ContractServiceV1";
>                   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
>                   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>                   xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>
> xmlns:tns="http://mhs.mckesson.com/contracting/contract/ContractServiceV1";
>
> xmlns:ack="http://mhs.mckesson.com/common/schema/AckResponseV1";
>
> xmlns:cc="http://mhs.mckesson.com/contracting/schema/CreateContractV1";
>                   xmlns:err="http://mhs.mckesson.com/common/schema/FaultV1
> "
>                   name="ContractService">
>
>     <wsdl:documentation>Contracting canonical message
> schema(s)</wsdl:documentation>
>     <wsdl:types>
>         <xsd:schema>
>             <xsd:import
> namespace="http://mhs.mckesson.com/common/schema/AckResponseV1";
> schemaLocation="com/mckesson/mhs/common/schema/AckResponseV1.xsd"/>
>             <xsd:import
> namespace="http://mhs.mckesson.com/common/schema/FaultV1";
> schemaLocation="com/mckesson/mhs/common/schema/FaultV1.xsd"/>
>             <xsd:import
> namespace="http://mhs.mckesson.com/contracting/schema/CreateContractV1";
> schemaLocation="com/mckesson/mhs/contracting/schema/CreateContractV1.xsd"/>
>         </xsd:schema>
>     </wsdl:types>
>
>     <wsdl:message name="mCreateContract">
>         <wsdl:part name="parameters" element="cc:CreateContractRequest"/>
>     </wsdl:message>
>
>     <wsdl:message name="mAckResponse">
>         <wsdl:part name="parameters" element="ack:Response"/>
>     </wsdl:message>
>
>     <wsdl:message name="mFault">
>         <wsdl:part name="fault" element="err:Fault"/>
>     </wsdl:message>
>
>     <wsdl:portType name="ptCreateContract">
>         <wsdl:operation name="CreateContractRequest">
>             <wsdl:input message="tns:mCreateContract"/>
>             <wsdl:output message="tns:mAckResponse"/>
>             <wsdl:fault name="fault" message="tns:mFault"/>
>         </wsdl:operation>
>     </wsdl:portType>
>
>     <wsdl:binding name="bdgCreateContract" type="tns:ptCreateContract">
>         <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>         <wsdl:operation name="CreateContractRequest">
>             <soap:operation
> soapAction="http://mhs.mckesson.com/services/contracting/createContract"/>
>             <wsdl:input>
>                 <soap:body use="literal"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <soap:body use="literal"/>
>             </wsdl:output>
>             <wsdl:fault name="fault">
>                 <soap:fault use="literal" name="fault"/>
>             </wsdl:fault>
>         </wsdl:operation>
>     </wsdl:binding>
>
>     <wsdl:service name="CreateContractService">
>         <wsdl:port name="ptCreateContract" binding="tns:bdgCreateContract">
>             <soap:address
> location="http://localhost:8085/services/contracting"/>
>         </wsdl:port>
>     </wsdl:service>
>
> </wsdl:definitions>
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Problem-unmarshalling-fault-in-CXF-JAX-WS-client-tp5723372.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Reply via email to