use of javax.xml.ws.WebServiceException in project wildfly by wildfly.
the class EJBEndpointAuthenticationTestCase method accessHelloForRolesWithInvalidRole.
@Test
public void accessHelloForRolesWithInvalidRole() throws Exception {
URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3/EJB3AuthService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
reqContext.put(BindingProvider.USERNAME_PROPERTY, "user3");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password3");
try {
proxy.helloForRoles("World");
Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
} catch (WebServiceException e) {
// failure is expected
Assert.assertEquals(getNotAllowedExceptionMessage("helloForRoles"), e.getCause().getMessage());
}
}
use of javax.xml.ws.WebServiceException in project wildfly by wildfly.
the class ReliableCheckHandler method verifySequenceAcknowledgement.
private boolean verifySequenceAcknowledgement(SOAPMessage message) throws SOAPException {
Iterator headerElements = message.getSOAPHeader().getChildElements();
boolean found = false;
boolean otherRMHeadersFound = false;
final QName sequenceAckQName = new QName("http://schemas.xmlsoap.org/ws/2005/02/rm", "SequenceAcknowledgement");
while (headerElements.hasNext()) {
SOAPElement soapElement = (SOAPElement) headerElements.next();
if (sequenceAckQName.equals(soapElement.getElementQName())) {
found = true;
} else if ("http://schemas.xmlsoap.org/ws/2005/02/rm".equals(soapElement.getNamespaceURI())) {
otherRMHeadersFound = true;
}
}
//fail if we did not find the sequence ack and the message has other WS-RM headers (hence out of order) or has body contents (hence a non-reliable message is being processed)
if (!found && (otherRMHeadersFound || message.getSOAPBody().getChildElements().hasNext())) {
throw new WebServiceException("wsrm:SequenceAcknowledgement is not present in soap header");
}
return found;
}
use of javax.xml.ws.WebServiceException in project camel by apache.
the class CamelDestinationTest method testCAMEL4073.
@Test
public void testCAMEL4073() throws Exception {
try {
Endpoint.publish("camel://foo", new Person() {
public void getPerson(Holder<String> personId, Holder<String> ssn, Holder<String> name) throws UnknownPersonFault {
}
});
fail("Should throw and Exception");
} catch (WebServiceException ex) {
Throwable c = ex.getCause();
assertNotNull(c);
assertTrue(c instanceof NoSuchEndpointException);
}
}
use of javax.xml.ws.WebServiceException in project cxf by apache.
the class LoadDistributorTest method testDistributedSequentialStrategyWithoutFailover.
@Test
public void testDistributedSequentialStrategyWithoutFailover() throws Exception {
startTarget(REPLICA_A);
startTarget(REPLICA_B);
startTarget(REPLICA_C);
startTarget(REPLICA_E);
setupGreeter();
stopTarget(REPLICA_B);
ConduitSelector conduitSelector = ClientProxy.getClient(greeter).getConduitSelector();
if (conduitSelector instanceof LoadDistributorTargetSelector) {
((LoadDistributorTargetSelector) conduitSelector).setStrategy(new LoadDistributorStaticStrategy());
((LoadDistributorTargetSelector) conduitSelector).setFailover(false);
} else {
fail("unexpected conduit selector: " + conduitSelector);
}
Map<String, Integer> responseCounts = new HashMap<>();
for (int i = 0; i < 12; ++i) {
try {
String response = greeter.greetMe("fred");
assertNotNull("expected non-null response", response);
incrementResponseCount(responseCounts, response);
} catch (WebServiceException ex) {
incrementResponseCount(responseCounts, "");
}
}
assertEquals(3, (long) responseCounts.get(REPLICA_A));
assertEquals(null, responseCounts.get(REPLICA_B));
assertEquals(3, (long) responseCounts.get(REPLICA_C));
assertEquals(3, (long) responseCounts.get(REPLICA_E));
assertEquals(3, (long) responseCounts.get(""));
stopTarget(REPLICA_A);
stopTarget(REPLICA_C);
stopTarget(REPLICA_E);
}
use of javax.xml.ws.WebServiceException in project cxf by apache.
the class CorbaTimeoutTest method testTimeout.
@Test
public void testTimeout() throws Exception {
System.getProperties().remove("com.sun.CORBA.POA.ORBServerId");
System.getProperties().remove("com.sun.CORBA.POA.ORBPersistentServerPort");
System.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
System.setProperty("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
System.setProperty("jacorb.connection.client.pending_reply_timeout", "1000");
URL wsdlUrl = this.getClass().getResource("/wsdl_systest/hello_world_corba_timeout.wsdl");
new SpringBusFactory().createBus("org/apache/cxf/systest/corba/hello_world_client.xml");
GreeterCORBAService gcs = new GreeterCORBAService(wsdlUrl, SERVICE_NAME);
Greeter port = gcs.getPort(new QName("http://cxf.apache.org/hello_world_corba", "GreeterTimeoutCORBAPort"), GreeterCORBAService.GreeterProxy.class);
try {
port.greetMe("Betty");
fail("Should throw org.omg.CORBA.TIMEOUT exception");
} catch (WebServiceException e) {
assertTrue(e.getCause() instanceof TIMEOUT);
} finally {
System.getProperties().remove("org.omg.CORBA.ORBClass");
System.getProperties().remove("org.omg.CORBA.ORBSingletonClass");
System.setProperty("org.omg.CORBA.ORBClass", "com.sun.corba.se.impl.orb.ORBImpl");
}
}
Aggregations