use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class SoapJmsSpecTest method testBindingVersionError.
@Test
public void testBindingVersionError() throws Exception {
QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
QName portName = new QName(SERVICE_NS, "GreeterPort");
URL wsdl = getWSDLURL(WSDL);
JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
JMSGreeterPortType greeter = markForClose(service.getPort(portName, JMSGreeterPortType.class, cff));
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestHeader.setSOAPJMSBindingVersion("0.3");
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
try {
greeter.greetMe("Milestone-");
Assert.fail("Should have thrown a fault");
} catch (SOAPFaultException ex) {
Assert.assertTrue(ex.getMessage().contains("0.3"));
Map<String, Object> responseContext = bp.getResponseContext();
JMSMessageHeadersType responseHdr = (JMSMessageHeadersType) responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
if (responseHdr == null) {
Assert.fail("response Header should not be null");
}
Assert.assertTrue(responseHdr.isSOAPJMSIsFault());
}
}
use of javax.xml.ws.soap.SOAPFaultException in project Payara by payara.
the class SOAPWebConsumer method addUsingSOAPConsumer.
private void addUsingSOAPConsumer() {
com.example.calculator.Calculator port = null;
port = service.getCalculatorPort();
// Get Stub
BindingProvider stub = (BindingProvider) port;
String endpointURI = "http://localhost:12011/calculatorendpoint";
stub.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURI);
String failedMsg = null;
try {
System.out.println("\nInvoking throwRuntimeException");
port.throwRuntimeException("bhavani");
} catch (Exception ex) {
System.out.println(ex);
if (!(ex instanceof SOAPFaultException) || !(ex.getMessage().equals("java.lang.RuntimeException: Calculator :: Threw Runtime Exception"))) {
failedMsg = "port.throwRuntimeException() did not receive RuntimeException 'Calculator :: Threw Runtime Exception'";
}
}
try {
System.out.println("\nInvoking throwApplicationException");
port.throwApplicationException("bhavani");
} catch (Exception ex) {
System.out.println(ex);
if (!(ex instanceof com.example.calculator.Exception_Exception)) {
failedMsg = "port.throwApplicationException() did not throw ApplicationException";
}
}
if (failedMsg != null) {
stat.addStatus(testId, stat.FAIL);
} else {
stat.addStatus(testId, stat.PASS);
}
}
Aggregations