use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class MUTube method createMUSOAPFaultException.
/**
* @return SOAPfaultException with SOAPFault representing the MustUnderstand SOAP Fault.
* notUnderstoodHeaders are added in the fault detail.
*/
final SOAPFaultException createMUSOAPFaultException(Set<QName> notUnderstoodHeaders) {
try {
SOAPFault fault = soapVersion.getSOAPFactory().createFault(MUST_UNDERSTAND_FAULT_MESSAGE_STRING, soapVersion.faultCodeMustUnderstand);
fault.setFaultString("MustUnderstand headers:" + notUnderstoodHeaders + " are not understood");
return new SOAPFaultException(fault);
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class jaxws413Test method test1.
public void test1() throws SOAPException, IOException {
SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault();
fault.setFaultCode(new QName("http://foo/bar", "mycode", "myprefix"));
fault.setFaultString("Some exception");
Detail detail = fault.addDetail();
detail.addDetailEntry(new QName("http://foo/bar", "soap11detail"));
Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(SOAPVersion.SOAP_11, fault);
SOAPMessage sm = faultMsg.readAsSOAPMessage();
Detail det = sm.getSOAPBody().getFault().getDetail();
Iterator iter = det.getDetailEntries();
assertTrue(iter.hasNext());
Element item = (Element) iter.next();
assertEquals(item.getNamespaceURI(), "http://foo/bar");
assertEquals(item.getLocalName(), "soap11detail");
}
use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method createInvalidAddressingHeaderFault.
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
QName name = e.getProblemHeader();
QName subsubcode = e.getSubsubcode();
QName subcode = av.invalidMapTag;
String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);
try {
SOAPFactory factory;
SOAPFault fault;
if (soapVer == SOAPVersion.SOAP_12) {
factory = SOAPVersion.SOAP_12.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.appendFaultSubcode(subcode);
fault.appendFaultSubcode(subsubcode);
getInvalidMapDetail(name, fault.addDetail());
} else {
factory = SOAPVersion.SOAP_11.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(subsubcode);
}
fault.setFaultString(faultstring);
return fault;
} catch (SOAPException se) {
throw new WebServiceException(se);
}
}
use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method newMapRequiredFault.
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
QName subcode = addVer.mapRequiredTag;
QName subsubcode = addVer.mapRequiredTag;
String faultstring = addVer.getMapRequiredText();
try {
SOAPFactory factory;
SOAPFault fault;
if (soapVer == SOAPVersion.SOAP_12) {
factory = SOAPVersion.SOAP_12.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.appendFaultSubcode(subcode);
fault.appendFaultSubcode(subsubcode);
getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
} else {
factory = SOAPVersion.SOAP_11.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(subsubcode);
}
fault.setFaultString(faultstring);
return fault;
} catch (SOAPException se) {
throw new WebServiceException(se);
}
}
use of jakarta.xml.soap.SOAPFault in project metro-jax-ws by eclipse-ee4j.
the class SOAP12Fault method getProtocolException.
protected Throwable getProtocolException() {
try {
SOAPFault fault = SOAPVersion.SOAP_12.getSOAPFactory().createFault();
if (reason != null) {
for (TextType tt : reason.texts()) {
fault.setFaultString(tt.getText());
}
}
if (code != null) {
fault.setFaultCode(code.getValue());
fillFaultSubCodes(fault, code.getSubcode());
}
if (detail != null && detail.getDetail(0) != null) {
jakarta.xml.soap.Detail detail = fault.addDetail();
for (Node obj : this.detail.getDetails()) {
Node n = fault.getOwnerDocument().importNode(obj, true);
detail.appendChild(n);
}
}
if (node != null) {
fault.setFaultNode(node);
}
return new ServerSOAPFaultException(fault);
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
Aggregations