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);
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class EchoClientTest method test1193.
public void test1193() throws Exception {
try {
SOAPMessage response = invoke12(createDispatchWithWSDLWithoutAddressing(), MESSAGES.getReplyToRefpsEchoMessage(), S12_NS, getAddress(), ECHO_IN_ACTION, "test1193");
fail("SOAPFaultException must be thrown");
} catch (SOAPFaultException e) {
assertNotNull(e.getFault());
SOAPFault f = e.getFault();
assertEquals(new QName("http://schemas.xmlsoap.org/soap/envelope/", "VersionMismatch"), f.getFaultCodeAsQName());
}
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class HelloLiteralTest method testMustUnderstand1.
/*
* MU test here for soap 1.1. Test uses a simple handler
* on client side to test service with no handlers.
*/
public void testMustUnderstand1() throws Exception {
String next_1_1 = "http://schemas.xmlsoap.org/soap/actor/next";
try {
// clear handlers (should be none) and add helper handler
ClientServerTestUtil.clearHandlers((BindingProvider) stub);
MUHelperHandler handler = new MUHelperHandler();
ClientServerTestUtil.addHandlerToBinding(handler, (BindingProvider) stub);
// have handler set header that is ignored
handler.setMUHeader(new QName("urn:mutest", "someheader"), "notarealactor");
// make the call
String arg = "foo";
Hello_Type req = new Hello_Type();
req.setArgument(arg);
HelloResponse response = stub.hello(req);
assertEquals(arg, response.getArgument());
// add header that should result in soap fault
handler.setMUHeader(new QName("urn:mutest", "someheader"), next_1_1);
// make the call
try {
response = stub.hello(req);
fail("did not receive any exception");
} catch (ProtocolException e) {
if (e instanceof SOAPFaultException) {
// pass
} else {
fail("did not receive soap fault, received: " + e.toString());
}
} catch (Exception e) {
fail("did not receive protocol exception. received " + e.toString());
}
} finally {
// always clear the handlers
ClientServerTestUtil.clearHandlers((BindingProvider) stub);
}
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testServerRtException1.
public void testServerRtException1() throws Exception {
HandlerTracker tracker = HandlerTracker.getClientInstance();
tracker.clearAll();
Hello stub = createStub();
ReportService report = createReportStub();
report.clearHandlerTracker();
try {
int bar = stub.hello(SERVER_THROW_RUNTIME_EXCEPTION);
assert (false);
} catch (SOAPFaultException e) {
// as expected.
System.out.println("ok");
}
List<String> expClientCalled = Arrays.asList(new String[] { "client1", "client1_FAULT" });
List<String> gotClientCalled = tracker.getCalledHandlers();
assertTrue(ERR_CLIENT_CALLED_HANDLERS, checkEqual(expClientCalled, gotClientCalled));
List<String> expServerCalled = Arrays.asList(new String[] { "server2", "server2_FAULT" });
List<String> gotServerCalled = report.getReport(REPORT_CALLED_HANDLERS);
assertTrue(ERR_SERVER_CALLED_HANDLERS, checkEqual(expServerCalled, gotServerCalled));
List<String> expClientClosed = Arrays.asList(new String[] { "client1" });
List<String> gotClientClosed = tracker.getClosedHandlers();
assertTrue(ERR_CLIENT_CLOSED_HANDLERS, checkEqual(expClientClosed, gotClientClosed));
List<String> expServerClosed = Arrays.asList(new String[] { "server2" });
List<String> gotServerClosed = report.getReport(REPORT_CLOSED_HANDLERS);
assertTrue(ERR_SERVER_CLOSED_HANDLERS, checkEqual(expServerClosed, gotServerClosed));
}
use of jakarta.xml.ws.soap.SOAPFaultException in project metro-jax-ws by eclipse-ee4j.
the class HandlerUtil method throwSOAPFaultException.
boolean throwSOAPFaultException(MessageContext context, String name, String direction) {
// register called first
registerHandlerCalled(context, name);
Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if ((outbound == Boolean.TRUE && direction.equals(INBOUND)) || (outbound == Boolean.FALSE && direction.equals(OUTBOUND))) {
// not the direction we want
return true;
}
if (ignoreReportMessage(context)) {
return true;
}
// random info in soap fault
try {
QName faultCode = new QName("uri", "local", "prefix");
String faultString = "fault";
String faultActor = "faultActor";
SOAPFault sf = SOAPFactory.newInstance().createFault(faultString, faultCode);
sf.setFaultActor(faultActor);
Detail detail = sf.addDetail();
Name entryName = SOAPFactory.newInstance().createName("someFaultEntry");
detail.addDetailEntry(entryName);
throw new SOAPFaultException(sf);
} catch (SOAPException e) {
throw new RuntimeException("Couldn't create SOAPFaultException " + e);
}
}
Aggregations