0

I am getting the below exception when trying to call service from SOAPUI that is fine because message part element dose not exits in wsdl. But I want to handle in proper way in CXF web service and send proper fault string instead of below message ex: "Bad Request"

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
      <Action xmlns="http://www.w3.org/2005/08/addressing"/>
      <MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:109a84f4-373d-4406-9087-82bd58bea394</MessageID>
      <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
      <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">uuid:3dcf9e26-20fc-4c93-bc01-8ca9ab1ae2eb</RelatesTo>
   </soap:Header>
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Message part Reservation was not recognized.  (Does it exist in service WSDL?)</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

Does any one know in cxf where I can handle in proper way ?

himanshu
  • 3
  • 1
  • 4

1 Answers1

0

You can solve this problem by consuming the web service from a client application. Everywhere you need to consume the WS, should put a BindingProvider to the port. This example is a method of:

...
import javax.xml.ws.BindingProvider;

public class WSClient {

        public String getUserName(int userCode) {

            WebServiceAuth ss = new WebServiceAuth();
            IWebServiceAuth port = ss.getPort(IWebServiceAuth.class);

            BindingProvider bindingProvider = (BindingProvider) port;
            bindingProvider
                    .getRequestContext()
                    .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                            "http://localhost:8081/WebServiceAuth/WSAuth");

            return port.getUserName(userCode);
        }
}

In this case you need to put your service's address into the BindingProvider.

J.C. Gras
  • 4,934
  • 1
  • 37
  • 44