Search in sources :

Example 76 with WebServiceException

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());
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 77 with WebServiceException

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;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) SOAPElement(javax.xml.soap.SOAPElement)

Example 78 with WebServiceException

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);
    }
}
Also used : UnknownPersonFault(org.apache.camel.wsdl_first.UnknownPersonFault) WebServiceException(javax.xml.ws.WebServiceException) Person(org.apache.camel.wsdl_first.Person) NoSuchEndpointException(org.apache.camel.NoSuchEndpointException) Test(org.junit.Test)

Example 79 with WebServiceException

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);
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) HashMap(java.util.HashMap) LoadDistributorTargetSelector(org.apache.cxf.clustering.LoadDistributorTargetSelector) ConduitSelector(org.apache.cxf.endpoint.ConduitSelector) Test(org.junit.Test)

Example 80 with WebServiceException

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");
    }
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) WebServiceException(javax.xml.ws.WebServiceException) GreeterCORBAService(org.apache.cxf.hello_world_corba.GreeterCORBAService) QName(javax.xml.namespace.QName) Greeter(org.apache.cxf.hello_world_corba.Greeter) TIMEOUT(org.omg.CORBA.TIMEOUT) URL(java.net.URL) Test(org.junit.Test)

Aggregations

WebServiceException (javax.xml.ws.WebServiceException)120 Test (org.junit.Test)50 URL (java.net.URL)37 BindingProvider (javax.xml.ws.BindingProvider)25 Service (javax.xml.ws.Service)22 QName (javax.xml.namespace.QName)14 IOException (java.io.IOException)10 Message (org.apache.cxf.common.i18n.Message)9 JAXBException (javax.xml.bind.JAXBException)8 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)8 Bus (org.apache.cxf.Bus)7 Packet (com.sun.xml.ws.api.message.Packet)6 AuthStatus (javax.security.auth.message.AuthStatus)6 SOAPException (javax.xml.soap.SOAPException)6 SOAPMessage (javax.xml.soap.SOAPMessage)6 ArrayList (java.util.ArrayList)5 WebService (javax.jws.WebService)5 Subject (javax.security.auth.Subject)5 HttpSession (javax.servlet.http.HttpSession)5 Handler (javax.xml.ws.handler.Handler)5