Search in sources :

Example 16 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class Usecase2TestCase method testAnonymousEndpoint.

@Test
public void testAnonymousEndpoint() throws Exception {
    final QName serviceName = new QName("org.jboss.as.test.integration.ws.anonymousPojos", "AnonymousPOJOService");
    final URL wsdlURL = new URL(baseUrl, "/anonymous-pojo-usecase2/AnonymousPOJOService?wsdl");
    final Service service = Service.create(wsdlURL, serviceName);
    final POJOIface port = service.getPort(POJOIface.class);
    final String result = port.echo("hello");
    Assert.assertEquals("hello from anonymous POJO", result);
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) Test(org.junit.Test)

Example 17 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class EJBEndpointAuthenticationTestCase method accessHelloWithUnauthorizedUser.

@Test
public void accessHelloWithUnauthorizedUser() 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, "user2");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
    try {
        proxy.hello("World");
        Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertEquals(getNotAllowedExceptionMessage("hello"), 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 18 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class EJBEndpointAuthenticationTestCase method accessHelloForNoneWithValidRole3.

@Test
public void accessHelloForNoneWithValidRole3() 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.helloForNone("World");
        Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertEquals(getNotAllowedExceptionMessage("helloForNone"), 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 19 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class EJBEndpointAuthenticationTestCase method accessHelloForRolesWithValidRole2.

@Test
public void accessHelloForRolesWithValidRole2() 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, "user2");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
    final String result = proxy.helloForRoles("World");
    Assert.assertEquals("Hello World!", result);
}
Also used : Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 20 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class TestNoAddressingTestCase method getServicePortFromWSDL.

private ServiceIface getServicePortFromWSDL(String wsdlFileName) throws MalformedURLException {
    QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService");
    File wsdlFile = new File(System.getProperty("jbossas.ts.submodule.dir") + "/src/test/java/org/jboss/as/test/integration/ws/wsa/" + wsdlFileName);
    URL wsdlURL = wsdlFile.toURI().toURL();
    Service service = Service.create(wsdlURL, serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
    BindingProvider bp = (BindingProvider) proxy;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, new URL(baseUrl, "/jaxws-wsa/AddressingService").toString());
    return proxy;
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) File(java.io.File) URL(java.net.URL)

Aggregations

Service (javax.xml.ws.Service)138 URL (java.net.URL)125 QName (javax.xml.namespace.QName)91 Test (org.junit.Test)84 BindingProvider (javax.xml.ws.BindingProvider)39 WebServiceException (javax.xml.ws.WebServiceException)18 IOException (java.io.IOException)12 Bus (org.apache.cxf.Bus)12 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)11 InsuranceService (com.salaboy.jbpm5.dev.guide.webservice.InsuranceService)10 HashMap (java.util.HashMap)10 ServiceIface (org.jboss.as.test.integration.ws.wsse.ServiceIface)10 UseNewBusFeature (org.jboss.wsf.stack.cxf.client.UseNewBusFeature)10 MalformedURLException (java.net.MalformedURLException)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 File (java.io.File)8 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)8 SAAJOutInterceptor (org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor)7 Client (org.apache.cxf.endpoint.Client)7