use of jakarta.xml.ws.soap.SOAPFaultException 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.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class SOAPFaultBuilderTest method testCreate11FaultFromSFE.
public void testCreate11FaultFromSFE() throws Exception {
SOAPFaultException sfe = new SOAPFaultException(FAULT_11);
Message msg = SOAPFaultBuilder.createSOAPFaultMessage(SOAPVersion.SOAP_11, sfe, SOAPVersion.SOAP_11.faultCodeMustUnderstand);
verifyDetail(msg);
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class SOAPFaultBuilder1Test method testFault1.
public void testFault1() throws Throwable {
SOAPMessage msg = SOAPVersion.SOAP_11.getMessageFactory().createMessage(null, new ByteArrayInputStream(fault1.getBytes()));
SOAPFaultBuilder sfb = SOAPFaultBuilder.create(new SAAJMessage(msg));
Throwable t = sfb.createException(null);
assertTrue(t instanceof SOAPFaultException);
assertTrue(t.getMessage().contains("Client received SOAP Fault from server:"));
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class SOAPFaultBuilder1Test method testFault3.
public void testFault3() throws Exception {
QName sc1 = new QName("http://example.org/1", "one");
QName sc2 = new QName("http://example.org/2", "two");
QName sc3 = new QName("http://example.org/3", "three");
String faultString = "INTERNAL_ERROR";
QName detailMsg = new QName("DetailMessage");
String detailValue = "This method is not implemented";
SOAPFactory fac = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPFault fault = fac.createFault(faultString, SOAPConstants.SOAP_RECEIVER_FAULT);
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.appendFaultSubcode(sc1);
fault.appendFaultSubcode(sc2);
fault.appendFaultSubcode(sc3);
fault.addDetail().addDetailEntry(detailMsg).setTextContent(detailValue);
Message fm = SOAPFaultBuilder.createSOAPFaultMessage(SOAPVersion.SOAP_12, fault);
// get the SOAPFault back
SOAPFaultBuilder sfb = SOAPFaultBuilder.create(fm);
Throwable ex = sfb.createException(null);
assertTrue(ex instanceof SOAPFaultException);
SOAPFaultException sfe = (SOAPFaultException) ex;
SOAPFault sf = sfe.getFault();
assertTrue(sf.getFaultString().equals(faultString));
// compare detail
Detail detail = sfe.getFault().getDetail();
assertTrue(detail != null);
Iterator iter = detail.getDetailEntries();
assertTrue(iter.hasNext());
DetailEntry n = (DetailEntry) iter.next();
assertTrue((n.getNamespaceURI() != null ? n.getNamespaceURI() : "").equals(detailMsg.getNamespaceURI()) && n.getLocalName().equals(detailMsg.getLocalPart()));
assertEquals(n.getTextContent(), detailValue);
// compare code and subcodes
Iterator scs = sf.getFaultSubcodes();
assertTrue(scs.hasNext());
QName sc = (QName) scs.next();
assertTrue(sc.equals(sc1));
assertTrue(scs.hasNext());
sc = (QName) scs.next();
assertTrue(sc.equals(sc2));
assertTrue(scs.hasNext());
sc = (QName) scs.next();
assertTrue(sc.equals(sc3));
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class DispatchHello method kkktestBad3HelloRequestResponseXML.
// bad namespace- expect SFE
public void kkktestBad3HelloRequestResponseXML() {
Dispatch dispatch = getDispatchSource();
Source source = makeStreamSource(bad3helloMsg);
Source response = makeStreamSource(helloResponse);
try {
Object result = dispatch.invoke(source);
assertTrue(result == null);
System.out.println("B3HelloRR invoke succeded");
} catch (Exception e) {
try {
assertTrue(e instanceof SOAPFaultException);
System.out.println("testBad3HelloRequestResponseXML Passed");
} catch (Exception ex) {
System.err.println("Expected SOAPFAULTException - got " + ex.getClass().getName());
System.out.println("testBad3HelloRequestResponseXML FAILED");
fail("testBad3HelloRequestResponseXML FAILED");
}
}
}
Aggregations