How To Supply Soapfault Inwards A Jax Ws Spider Web Service Inwards Javaee

The code below is an event of how you lot tin throw a soapFault exception when an mistake is encountered inwards your spider web service  call.

There are basically ii things ii accept note, take in comments inwards code.

 //#1 - inject WebServiceContext @Resource somebody WebServiceContext webServiceContext;  //#2 give-up the ghost the soapMessage, add together a soapFault inwards trunk in addition to throw the soapFault exception. SOAPMessageContext jaxwsContext = (SOAPMessageContext) webServiceContext.getMessageContext(); SOAPMessage soapMsg = jaxwsContext.getMessage(); endeavour {  SOAPFault soapFault = soapMsg.getSOAPBody().addFault();  soapFault.setFaultString("ERROR");  Name qname = soapMsg.getSOAPPart().getEnvelope().createName("Client", null, SOAPConstants.URI_NS_SOAP_ENVELOPE);  soapFault.setFaultCode(qname);  throw novel SOAPFaultException(soapFault); } choose grip of (SOAPException e) {  // TODO Auto-generated choose grip of block  e.printStackTrace(); } 
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.