Example usage for javax.xml.ws Service create

List of usage examples for javax.xml.ws Service create

Introduction

In this page you can find the example usage for javax.xml.ws Service create.

Prototype

public static Service create(QName serviceName, WebServiceFeature... features) 

Source Link

Document

Creates a Service instance.

Usage

From source file:org.apache.coheigea.cxf.ldap.authentication.AuthenticationTest.java

@org.junit.Test
public void testAuthenticatedRequestViaSun() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthenticationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSunPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "alice");

    doubleIt(transportPort, 25);//  w w  w . jav a2 s  . c  o m
}

From source file:org.apache.coheigea.cxf.ldap.authentication.AuthenticationTest.java

@org.junit.Test
public void testUnauthenticatedRequestviaSun() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthenticationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSunPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "bob");

    try {/*from   w  w  w.  ja v  a 2 s.  c o  m*/
        doubleIt(transportPort, 25);
        Assert.fail("Failure expected on bob");
    } catch (Exception ex) {
        // expected
    }
}

From source file:org.apache.coheigea.cxf.ldap.authentication.AuthenticationTest.java

@org.junit.Test
public void testAuthenticatedRequestViaJetty() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthenticationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportJettyPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "alice");

    doubleIt(transportPort, 25);/*from   ww  w.j  a  v  a2 s  . c  o m*/
}

From source file:org.apache.coheigea.cxf.ldap.authentication.AuthenticationTest.java

@org.junit.Test
public void testUnauthenticatedRequestViaJetty() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthenticationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportJettyPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "bob");

    try {/*from w w w.  j  a v a  2  s  .c o  m*/
        doubleIt(transportPort, 25);
        Assert.fail("Failure expected on bob");
    } catch (Exception ex) {
        // expected
    }
}

From source file:org.apache.coheigea.cxf.ldap.authentication.AuthenticationTest.java

@org.junit.Test
public void testAuthenticatedRequestViaKaraf() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthenticationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportKarafPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "alice");

    doubleIt(transportPort, 25);//from  w ww  .  j a va2s  .  c o  m
}

From source file:org.apache.coheigea.cxf.ldap.authentication.AuthenticationTest.java

@org.junit.Test
public void testUnauthenticatedRequestViaKaraf() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthenticationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthenticationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportKarafPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "bob");

    try {/* www .  j av a 2  s  .  c  o  m*/
        doubleIt(transportPort, 25);
        Assert.fail("Failure expected on bob");
    } catch (Exception ex) {
        // expected
    }
}

From source file:org.apache.coheigea.cxf.ldap.authorization.AuthorizationTest.java

@org.junit.Test
public void testAuthorizedRequestViaJetty() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthorizationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportJettyPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "alice");

    doubleIt(transportPort, 25);//from w w w  .  j a v  a  2  s .co  m
}

From source file:org.apache.coheigea.cxf.ldap.authorization.AuthorizationTest.java

@org.junit.Test
public void testUnauthorizedRequestViaJetty() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthorizationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportJettyPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "bob");

    try {//from w ww. java2 s .com
        doubleIt(transportPort, 25);
        Assert.fail("Failure expected on bob");
    } catch (Exception ex) {
        // expected
    }
}

From source file:org.apache.coheigea.cxf.ldap.authorization.AuthorizationTest.java

@org.junit.Test
public void testAuthorizedRequestViaKaraf() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthorizationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportKarafPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "alice");

    doubleIt(transportPort, 25);/*from   www.  ja  va2 s  .  c  o m*/
}

From source file:org.apache.coheigea.cxf.ldap.authorization.AuthorizationTest.java

@org.junit.Test
public void testUnauthorizedRequestViaKaraf() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = AuthorizationTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    URL wsdl = AuthorizationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportKarafPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    TestUtil.updateAddressPort(transportPort, PORT);

    Client client = ClientProxy.getClient(transportPort);
    client.getRequestContext().put("ws-security.username", "bob");

    try {//w  w  w.j a  v  a  2s .c o m
        doubleIt(transportPort, 25);
        Assert.fail("Failure expected on bob");
    } catch (Exception ex) {
        // expected
    }
}