use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class WSAResponsesClientServerTest method testWSAResponses.
@Test
public void testWSAResponses() throws Exception {
this.setupInLogging();
this.setupOutLogging();
URL wsdlURL = new URL("http://localhost:" + PORT + "/wsa/responses?wsdl");
QName serviceQName = new QName("http://cxf.apache.org/systest/wsa/responses", "HelloService");
HelloService service = new HelloService(wsdlURL, serviceQName);
try {
service.getHelloPort().sayHi("helloWorld");
fail("Expect exception");
} catch (Exception e) {
String expectedDetail = "A header representing a Message Addressing Property is not valid";
if (e instanceof SOAPFaultException) {
assertTrue("Expect fault deail : " + expectedDetail, e.getMessage().indexOf(expectedDetail) > -1);
} else {
throw e;
}
}
}
use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class SecurityPolicyTest method testFault.
@Test
public void testFault() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SecurityPolicyTest.class.getResource("https_config_client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItFaultPortSignThenEncrypt");
DoubleItPortType pt = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(pt, PORT);
((BindingProvider) pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
((BindingProvider) pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties");
((BindingProvider) pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "bob.properties");
// DOM
try {
pt.doubleIt(5);
fail("SOAPFaultException expected!");
} catch (SOAPFaultException e) {
assertEquals("Foo", e.getFault().getFaultString());
} finally {
((java.io.Closeable) pt).close();
bus.shutdown(true);
}
}
use of javax.xml.ws.soap.SOAPFaultException in project tomee by apache.
the class MaxChildTest method tooBig.
@Test
public void tooBig() throws MalformedURLException {
try {
final Root root = new Root();
for (int i = 0; i < 2; i++) {
root.getChildren().add(new Child());
}
javax.xml.ws.Service.create(new URL(this.root.toExternalForm() + "app/ws?wsdl"), new QName("http://cxf.server.openejb.apache.org/", "SimpleContractImplService")).getPort(SimpleContract.class).test(root);
} catch (final SOAPFaultException e) {
assertEquals("Unmarshalling Error: Maximum Number of Child Elements limit (1) Exceeded ", e.getMessage());
}
}
use of javax.xml.ws.soap.SOAPFaultException in project tomee by apache.
the class CalculatorTest method call.
@Test
public void call() throws MalformedURLException {
final EJBContainer container = EJBContainer.createEJBContainer(new Properties() {
{
setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
// random port to avoid issue on CI, default is 4204
setProperty("httpejbd.port", "0");
}
});
// get back the random port
final int port = Integer.parseInt(SystemInstance.get().getProperty("httpejbd.port"));
// normal call
final Service service = Service.create(new URL("http://127.0.0.1:" + port + "/webservice-ws-with-resources-config/CalculatorBean?wsdl"), new QName("http://security.ws.superbiz.org/", "CalculatorBeanService"));
final Calculator calculator = service.getPort(Calculator.class);
ClientProxy.getClient(calculator).getOutInterceptors().add(new WSS4JOutInterceptor(new HashMap<String, Object>() {
{
put("action", "UsernameToken");
put("user", "openejb");
put("passwordType", "PasswordText");
put("passwordCallbackRef", new CallbackHandler() {
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
pc.setPassword("tomee");
}
});
}
}));
assertEquals(5, calculator.add(2, 3));
// bad auth
final Calculator calculator2 = service.getPort(Calculator.class);
ClientProxy.getClient(calculator2).getOutInterceptors().add(new WSS4JOutInterceptor(new HashMap<String, Object>() {
{
put("action", "UsernameToken");
put("user", "openejb");
put("passwordType", "PasswordText");
put("passwordCallbackRef", new CallbackHandler() {
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
pc.setPassword("wrong");
}
});
}
}));
try {
assertEquals(5, calculator2.add(2, 3));
} catch (SOAPFaultException sfe) {
assertThat(sfe.getMessage(), CoreMatchers.containsString("A security error was encountered when verifying the message"));
}
container.close();
// valid it passed because all was fine and not because the server config was not here
assertTrue(PasswordCallbackHandler.wasCalled());
}
use of javax.xml.ws.soap.SOAPFaultException in project wildfly by wildfly.
the class EJBEndpoint method helloError.
public String helloError(String input) {
try {
SOAPFault fault = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createFault(input, SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
fault.setFaultActor("mr.actor");
fault.addDetail().addChildElement("test");
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException"));
fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "OperatorNotFound"));
throw new SOAPFaultException(fault);
} catch (SOAPException ex) {
ex.printStackTrace();
}
return "Failure!";
}
Aggregations