use of jakarta.xml.ws.ProtocolException in project metro-jax-ws by eclipse-ee4j.
the class FaultImpl method echo.
public java.lang.String echo(java.lang.String type) throws Fault1Exception, Fault2Exception, Fault3Exception, Fault4Exception {
if (type.equals("Fault1")) {
FooException fault = new FooException();
fault.setVarInt(1);
fault.setVarString("1");
fault.setVarFloat(1);
System.out.println("Throwing Fault1Exception");
throw new Fault1Exception("Fault1 message", fault);
} else if (type.equals("Fault1-SOAPFaultException")) {
FooException fault = new FooException();
fault.setVarInt(1);
fault.setVarString("1");
fault.setVarFloat(1);
System.out.println("Throwing Fault1Exception with Cause");
throw new Fault1Exception("Fault1 message", fault, createSOAPFaultException());
} else if (type.equals("Fault2")) {
String fault = "fault2";
System.out.println("Throwing Fault2Exception");
throw new Fault2Exception("Fault2 message", fault);
} else if (type.equals("Fault3")) {
Integer fault = Integer.valueOf("1");
System.out.println("Throwing Fault3Exception");
throw new Fault3Exception("Fault3 message", fault);
} else if (type.equals("Fault4")) {
Fault4 fault = new Fault4();
fault.setMessage("fault4");
fault.setCount(1);
System.out.println("Throwing Fault4Exception");
throw new Fault4Exception("Fault4 message", fault);
} else if (type.equals("SOAPFaultException")) {
throw createSOAPFaultException();
} else if (type.equals("NullPointerException")) {
Object o = null;
// generate NPE
o.hashCode();
} else if (type.equals("ProtocolException")) {
throw new ProtocolException();
} else if (type.equals("ProtocolException2")) {
throw new ProtocolException("FaultImpl");
} else if (type.equals("multipleDetails")) {
createSaajBug();
} else if (type.equals("nullBean")) {
throw new Fault2Exception(null, null, new WebServiceException("User exception!"));
} else if (type.equals("echo")) {
// used in MU test
return "echo";
}
return "Unknown fault: " + type;
}
use of jakarta.xml.ws.ProtocolException in project metro-jax-ws by eclipse-ee4j.
the class FaultImpl method echo.
public java.lang.String echo(java.lang.String type) throws Fault1Exception, Fault2Exception, Fault3Exception, Fault4Exception {
if (type.equals("Fault1")) {
FooException fault = new FooException();
fault.setVarInt(1);
fault.setVarString("1");
fault.setVarFloat(1);
System.out.println("Throwing Fault1Exception");
throw new Fault1Exception("Fault1 message", fault);
} else if (type.equals("Fault1-SOAPFaultException")) {
FooException fault = new FooException();
fault.setVarInt(1);
fault.setVarString("1");
fault.setVarFloat(1);
System.out.println("Throwing Fault1Exception with Cause");
throw new Fault1Exception("Fault1 message", fault, createSOAPFaultException());
} else if (type.equals("Fault2")) {
String fault = "fault2";
System.out.println("Throwing Fault2Exception");
throw new Fault2Exception("Fault2 message", fault);
} else if (type.equals("Fault3")) {
Integer fault = Integer.valueOf("1");
System.out.println("Throwing Fault3Exception");
throw new Fault3Exception("Fault3 message", fault);
} else if (type.equals("Fault4")) {
Fault4 fault = new Fault4();
fault.setMessage("fault4");
fault.setCount(1);
System.out.println("Throwing Fault4Exception");
throw new Fault4Exception("Fault4 message", fault);
} else if (type.equals("SOAPFaultException")) {
throw createSOAPFaultException();
} else if (type.equals("NullPointerException")) {
Object o = null;
// generate NPE
o.hashCode();
} else if (type.equals("ProtocolException")) {
throw new ProtocolException();
} else if (type.equals("ProtocolException2")) {
throw new ProtocolException("FaultImpl");
} else if (type.equals("multipleDetails")) {
createSaajBug();
} else if (type.equals("nullBean")) {
throw new Fault2Exception(null, null, new WebServiceException("User exception!"));
} else if (type.equals("echo")) {
// used in MU test
return "echo";
}
return "Unknown fault: " + type;
}
use of jakarta.xml.ws.ProtocolException in project metro-jax-ws by eclipse-ee4j.
the class FaultImpl method echo.
public java.lang.String echo(java.lang.String type) throws Fault1Exception, Fault2Exception, Fault3Exception, Fault4Exception {
if (type.equals("Fault1")) {
FooException fault = new FooException();
fault.setVarInt(1);
fault.setVarString("1");
fault.setVarFloat(1);
System.out.println("Throwing Fault1Exception");
throw new Fault1Exception("Fault1 message", fault);
} else if (type.equals("Fault1-SOAPFaultException")) {
FooException fault = new FooException();
fault.setVarInt(1);
fault.setVarString("1");
fault.setVarFloat(1);
System.out.println("Throwing Fault1Exception with Cause");
throw new Fault1Exception("Fault1 message", fault, createSOAPFaultException(null, "Fault1 message"));
} else if (type.equals("Fault2")) {
String fault = "fault2";
System.out.println("Throwing Fault2Exception");
throw new Fault2Exception("Fault2 message", fault);
} else if (type.equals("Fault3")) {
Integer fault = Integer.valueOf("1");
System.out.println("Throwing Fault3Exception");
throw new Fault3Exception("Fault3 message", fault);
} else if (type.equals("Fault4")) {
Fault4 fault = new Fault4();
fault.setMessage("fault4");
fault.setCount(1);
System.out.println("Throwing Fault4Exception");
throw new Fault4Exception("Fault4 message", fault);
} else if (type.equals("SOAPFaultException")) {
throw createSOAPFaultException(null, "SOAPFaultException");
} else if (type.equals("NullPointerException")) {
Object o = null;
o.hashCode();
} else if (type.equals("ProtocolException")) {
throw new ProtocolException();
} else if (type.equals("ProtocolException2")) {
throw new ProtocolException("FaultImpl");
// } else if (type.equals("RemoteExceptionWithSFECause")) {
// throw new RemoteException("RemoteExceptionWithSFECause", createSOAP12FaultException(null,
// "SOAP12FaultException Test"));
// } else if (type.equals("RemoteExceptionWithSFECause2")) {
// SOAP12FaultException soapFault = createSOAP12FaultException(new QName("SoapFault"),
// "Endpoint encountered an error");
// throw new RemoteException("RemoteExceptionWithSFECause2", soapFault);
} else if (type.equals("echo")) {
// used in MU test
return "echo";
}
return "Unknown fault: " + type;
}
use of jakarta.xml.ws.ProtocolException in project metro-jax-ws by eclipse-ee4j.
the class SOAPTestHandler method handleMessage.
public boolean handleMessage(SOAPMessageContext smc) {
try {
SOAPMessage message = smc.getMessage();
SOAPBody body = message.getSOAPBody();
SOAPElement paramElement = (SOAPElement) body.getFirstChild().getFirstChild();
int number = Integer.parseInt(paramElement.getValue());
if (number == THROW_RUNTIME_EXCEPTION) {
throw new RuntimeException("EXPECTED EXCEPTION");
} else if (number == THROW_PROTOCOL_EXCEPTION) {
throw new ProtocolException("EXPECTED EXCEPTION");
} else if (number == THROW_SOAPFAULT_EXCEPTION) {
// todo
}
paramElement.setValue(String.valueOf(++number));
} catch (SOAPException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return true;
}
use of jakarta.xml.ws.ProtocolException in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTest method testServerInboundRuntimeException2.
/*
* Have one of the server handlers throw a runtime
* exception and check that the proper methods are called.
* This test uses a protocol handler.
*/
public void testServerInboundRuntimeException2() throws Exception {
TestService_Service service = getService();
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
HandlerTracker tracker = HandlerTracker.getClientInstance();
// these lines make calls to the server
reportStub.clearHandlerTracker();
for (int i = 0; i < numTotalHandlers; i++) {
reportStub.setInstruction(SERVER_PREFIX + i, HA_REGISTER_HANDLE_XYZ);
}
reportStub.setInstruction(SERVER_PREFIX + 2, HA_THROW_RUNTIME_EXCEPTION_INBOUND);
// so we clear out the client handlers afterwards
tracker.clearAll();
try {
testStub.testInt(3);
fail("did not receive exception");
} catch (ProtocolException e) {
// ok
}
// check result
String[] called = { "4", "2" };
List<String> calledHandlers = reportStub.getReport(REPORT_CALLED_HANDLERS);
assertEquals("Did not get proper number of called handlers", called.length, calledHandlers.size());
for (int i = 0; i < called.length; i++) {
assertEquals("did not find expected handler", SERVER_PREFIX + called[i], calledHandlers.get(i));
}
// should be no destroyed handlers
List<String> destroyedHandlers = reportStub.getReport(REPORT_DESTROYED_HANDLERS);
assertTrue("Should be no destroyed handlers", destroyedHandlers.isEmpty());
}
Aggregations