Search in sources :

Example 21 with Service

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

the class TestNoAddressingTestCase method usingWSDLFromDeployedEndpoint.

@Test
public void usingWSDLFromDeployedEndpoint() throws Exception {
    QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService");
    URL wsdlURL = new URL(baseUrl, "/jaxws-wsa/AddressingService?wsdl");
    File wsdlFile = new File(this.getClass().getSimpleName() + ".wsdl");
    downloadWSDLToFile(wsdlURL, wsdlFile);
    Service service = Service.create(wsdlFile.toURI().toURL(), serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
    Assert.assertEquals(expectedResponse, proxy.sayHello(message));
    wsdlFile.delete();
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 22 with Service

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

the class TestOptionalAddressingTestCase method usingWSDLFromDeployedEndpoint.

@Test
public void usingWSDLFromDeployedEndpoint() throws Exception {
    QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService");
    URL wsdlURL = new URL(baseUrl, "/jaxws-wsa/AddressingService?wsdl");
    File wsdlFile = new File(this.getClass().getSimpleName() + ".wsdl");
    TestNoAddressingTestCase.downloadWSDLToFile(wsdlURL, wsdlFile);
    Service service = Service.create(wsdlFile.toURI().toURL(), serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
    Assert.assertEquals(expectedResponse, proxy.sayHello(message));
    wsdlFile.delete();
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 23 with Service

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

the class EJBEndpointSecuredWSDLAccessTestCase method createService.

@Test
public void createService() throws Exception {
    QName serviceName = new QName("http://jbossws.org/authenticationForWSDL", "EJB3ServiceForWSDL");
    URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3-for-wsdl/EJB3ServiceForWSDL?wsdl");
    try {
        Service service = Service.create(wsdlURL, serviceName);
        EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
        Assert.fail("Proxy shouldn't be created because WSDL access should be secured");
    } catch (WebServiceException e) {
    // failure is expected
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) Test(org.junit.Test)

Example 24 with Service

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

the class PojoEndpointAuthenticationTestCase method accessHelloWithValidUser2.

@Test
public void accessHelloWithValidUser2() throws Exception {
    URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-pojo/POJOAuthService?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    PojoEndpointIface proxy = service.getPort(PojoEndpointIface.class);
    Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
    reqContext.put(BindingProvider.USERNAME_PROPERTY, "user2");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
    final String result = proxy.hello("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 25 with Service

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

the class PojoEndpointAuthenticationTestCase method accessHelloWithoutUsernameAndPassord.

@Test
public void accessHelloWithoutUsernameAndPassord() throws Exception {
    URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-pojo/POJOAuthService?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    PojoEndpointIface proxy = service.getPort(PojoEndpointIface.class);
    try {
        proxy.hello("World");
        Assert.fail("Test should fail, HTTP response '401: Unauthorized' was expected");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertTrue("HTTPException '401: Unauthorized' was expected", e.getCause().getMessage().contains("401: Unauthorized"));
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Service(javax.xml.ws.Service) URL(java.net.URL) Test(org.junit.Test)

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