Java Code Examples for org.apache.cxf.jaxws.JaxWsServerFactoryBean#setAddress()

The following examples show how to use org.apache.cxf.jaxws.JaxWsServerFactoryBean#setAddress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExceptionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test(expected = HelloException.class)
public void testJaxwsNoXfireCompat() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.getServiceFactory().setDataBinding(sfbean.getDataBinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs");
    proxyFac.setServiceClass(ExceptionService.class);
    proxyFac.setBus(getBus());
    proxyFac.getClientFactoryBean().getServiceFactory().setDataBinding(new AegisDatabinding());
    ExceptionService clientInterface = (ExceptionService)proxyFac.create();

    clientInterface.sayHiWithException();
}
 
Example 2
Source File: MtomPolicyTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void setupServer(boolean mtomRequired, String address) throws Exception {
    getStaticBus().getExtension(PolicyEngine.class).setAlternativeSelector(
        new FirstAlternativeSelector());
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new EchoService());
    sf.setBus(getStaticBus());
    sf.setAddress(address);

    WSPolicyFeature policyFeature = new WSPolicyFeature();
    List<Element> policyElements = new ArrayList<>();
    if (mtomRequired) {
        policyElements.add(StaxUtils.read(
            getClass().getResourceAsStream("mtom-policy.xml"))
                       .getDocumentElement());
    } else {
        policyElements.add(StaxUtils.read(
            getClass().getResourceAsStream("mtom-policy-optional.xml"))
                       .getDocumentElement());
    }
    policyFeature.setPolicyElements(policyElements);

    sf.getFeatures().add(policyFeature);

    sf.create();
}
 
Example 3
Source File: WSAFeatureXmlTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testServerFactory() {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();

    assertNotNull(bus != null);
    sf.setServiceBean(new GreeterImpl());
    sf.setAddress("http://localhost:" + PORT + "/test");
    sf.setStart(false);

    Configurer c = getBus().getExtension(Configurer.class);
    c.configureBean("server", sf);

    Server server = sf.create();

    Endpoint endpoint = server.getEndpoint();
    checkAddressInterceptors(endpoint.getInInterceptors());
}
 
Example 4
Source File: SimpleEventingIntegrationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Server createEndToEndpointWithReferenceParametersAssertion(String address,
                                                                     ReferenceParametersType params) {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestingEndToEndpointImpl());
    factory.setAddress(address);
    factory.getHandlers().add(new ReferenceParametersAssertingHandler(params));
    factory.getHandlers().add(new WSAActionAssertingHandler(EventingConstants.ACTION_SUBSCRIPTION_END));
    return factory.create();
}
 
Example 5
Source File: DOMToStaxSignatureIdentifierTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Service createService() {
    // Create the Service
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();

    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    return service;
}
 
Example 6
Source File: AbstractWebServiceTaskTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();

    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress("http://localhost:63081/webservicemock");
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
 
Example 7
Source File: SimpleEventingIntegrationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Server createEventSink(String address) {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestingEventSinkImpl());
    factory.setAddress(address);
    return factory.create();
}
 
Example 8
Source File: DOMToStaxRoundTripTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Service createService() {
    // Create the Service
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();

    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    return service;
}
 
Example 9
Source File: IntegrationBaseTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Server createLocalResourceFactory(ResourceManager manager) {
    ResourceFactoryImpl implementor = new ResourceFactoryImpl();
    implementor.setResourceResolver(new SimpleResourceResolver(RESOURCE_ADDRESS, manager));
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceClass(ResourceFactory.class);
    factory.setAddress(RESOURCE_FACTORY_ADDRESS);
    factory.setServiceBean(implementor);

    return factory.create();
}
 
Example 10
Source File: TestUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static Server createStudentsResource(ResourceManager resourceManager, String port) {
    ResourceLocal resourceLocal = new ResourceLocal();
    resourceLocal.setManager(resourceManager);
    resourceLocal.getResourceTypeIdentifiers().add(
            new XSDResourceTypeIdentifier(
                    new StreamSource(TestUtils.class.getResourceAsStream("/schema/studentPut.xsd")),
                    new XSLTResourceTransformer(
                            new StreamSource(TestUtils.class.getResourceAsStream("/xslt/studentPut.xsl")),
                            new StudentPutResourceValidator())));
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(Resource.class);
    factory.setServiceBean(resourceLocal);
    factory.setAddress("http://localhost:" + port + "/ResourceStudents");
    return factory.create();
}
 
Example 11
Source File: JavaFirstNoWsdlTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void startServer() {
    startBusAndJMS(JavaFirstNoWsdlTest.class);
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.getFeatures().add(cff);
    svrFactory.setServiceClass(Hello.class);
    svrFactory.setAddress(SERVICE_ADDRESS);
    svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
    svrFactory.setServiceBean(new HelloImpl());
    svrFactory.create();
}
 
Example 12
Source File: MultipleServiceShareClassTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void registerService(final Class<?> service, final Object serviceImpl) {
    final JaxWsServerFactoryBean builder = new JaxWsServerFactoryBean();
    builder.setBus(getBus());
    builder.setAddress("http://localhost:" + PORT + "/" + service.getSimpleName());
    builder.setServiceBean(serviceImpl);
    builder.setServiceClass(service);
    builder.create();
}
 
Example 13
Source File: StaxRoundTripTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Service createService() {
    // Create the Service
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();

    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    return service;
}
 
Example 14
Source File: EndpointCreationLoop3.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void iteration() {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setAddress("http://localhost:9000/test");
    sf.setServiceClass(org.apache.cxf.systest.jaxb.service.TestServiceImpl.class);
    sf.setStart(false);

    Server server = sf.create();
    server.start();
    server.stop();
}
 
Example 15
Source File: ProviderServiceFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testXMLBindingFromCode() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(DOMSourcePayloadProvider.class);
    bean.setBus(getBus());
    bean.setInvoker(new JAXWSMethodInvoker(new DOMSourcePayloadProvider()));

    Service service = bean.create();

    assertEquals("DOMSourcePayloadProviderService", service.getName().getLocalPart());

    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    assertNotNull(intf);

    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(getBus());
    svrFactory.setServiceFactory(bean);
    String address = "http://localhost:9000/test";
    svrFactory.setAddress(address);
    svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID);

    ServerImpl server = (ServerImpl)svrFactory.create();

    assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());

    Endpoint endpoint = server.getEndpoint();
    Binding binding = endpoint.getBinding();
    assertTrue(binding instanceof XMLBinding);

    Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID,
                      "/org/apache/cxf/jaxws/provider/sayHi.xml");

    addNamespace("j", "http://service.jaxws.cxf.apache.org/");
    assertValid("/j:sayHi", res);
}
 
Example 16
Source File: StaxToDOMSamlTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Service createService() {
    // Create the Service
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();

    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    return service;
}
 
Example 17
Source File: ActionTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@org.junit.Test
public void testAsymmetricActionToPolicyServerFactory() throws Exception {

    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    URL serviceWSDL = ActionTest.class.getResource("DoubleItActionPolicy.wsdl");
    svrFactory.setWsdlLocation(serviceWSDL.toString());
    String address = "http://localhost:" + PORT2 + "/DoubleItAsymmetric";
    svrFactory.setAddress(address);
    svrFactory.setServiceBean(new DoubleItImpl());
    QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
    svrFactory.setEndpointName(portQName);

    Map<String, Object> props = new HashMap<>();
    props.put("security.callback-handler", "org.apache.cxf.systest.ws.common.KeystorePasswordCallback");
    props.put("security.signature.properties", "bob.properties");
    props.put("security.encryption.properties", "alice.properties");
    props.put("security.encryption.username", "alice");
    svrFactory.setProperties(props);

    org.apache.cxf.endpoint.Server server = svrFactory.create();

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ActionTest.class.getResource("client.xml");

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

    URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    DoubleItPortType port =
            service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(port, PORT2);

    // Successful call
    assertEquals(50, port.doubleIt(25));

    ((java.io.Closeable)port).close();
    server.destroy();
    bus.shutdown(true);
}
 
Example 18
Source File: PublishedEndpointUrlTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testPublishedEndpointUrl() throws Exception {

    Greeter implementor = new org.apache.hello_world_soap_http.GreeterImpl();
    String publishedEndpointUrl = "http://cxf.apache.org/publishedEndpointUrl";
    Bus bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceClass(Greeter.class);
    svrFactory.setAddress("http://localhost:" + PORT + "/publishedEndpointUrl");
    svrFactory.setPublishedEndpointUrl(publishedEndpointUrl);
    svrFactory.setServiceBean(implementor);

    Server server = svrFactory.create();

    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);

    URL url = new URL(svrFactory.getAddress() + "?wsdl=1");
    HttpURLConnection connect = (HttpURLConnection)url.openConnection();
    assertEquals(500, connect.getResponseCode());

    Definition wsdl = wsdlReader.readWSDL(svrFactory.getAddress() + "?wsdl");
    assertNotNull(wsdl);

    Collection<Service> services = CastUtils.cast(wsdl.getAllServices().values());
    final String failMesg = "WSDL provided incorrect soap:address location";

    for (Service service : services) {
        Collection<Port> ports = CastUtils.cast(service.getPorts().values());
        for (Port port : ports) {
            List<?> extensions = port.getExtensibilityElements();
            for (Object extension : extensions) {
                String actualUrl = null;
                if (extension instanceof SOAP12Address) {
                    actualUrl = ((SOAP12Address)extension).getLocationURI();
                } else if (extension instanceof SOAPAddress) {
                    actualUrl = ((SOAPAddress)extension).getLocationURI();
                }

                //System.out.println("Checking url: " + actualUrl + " against " + publishedEndpointUrl);
                assertEquals(failMesg, publishedEndpointUrl, actualUrl);
            }
        }
    }
    server.stop();
    server.destroy();
    bus.shutdown(true);
}
 
Example 19
Source File: RoundTripTest.java    From steady with Apache License 2.0 4 votes vote down vote up
@Before
public void setUpService() throws Exception {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();
    Service service = server.getEndpoint().getService();
    
    service.getInInterceptors().add(new SAAJInInterceptor());
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new SAAJOutInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    wsIn = new WSS4JInInterceptor();
    wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties");
    wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties");
    wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());

    service.getInInterceptors().add(wsIn);

    wsOut = new WSS4JOutInterceptor();
    wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
    wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
    wsOut.setProperty(WSHandlerConstants.USER, "myalias");
    wsOut.setProperty("password", "myAliasPassword");
    wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
    service.getOutInterceptors().add(wsOut);

    // Create the client
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setServiceClass(Echo.class);
    proxyFac.setAddress("local://Echo");
    proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
    
    echo = (Echo)proxyFac.create();

    client = ClientProxy.getClient(echo);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getInInterceptors().add(wsIn);
    client.getInInterceptors().add(new SAAJInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    client.getOutInterceptors().add(wsOut);
    client.getOutInterceptors().add(new SAAJOutInterceptor());
}
 
Example 20
Source File: RoundTripTest.java    From steady with Apache License 2.0 4 votes vote down vote up
@Before
public void setUpService() throws Exception {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();
    Service service = server.getEndpoint().getService();
    
    service.getInInterceptors().add(new SAAJInInterceptor());
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new SAAJOutInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    wsIn = new WSS4JInInterceptor();
    wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties");
    wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties");
    wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());

    service.getInInterceptors().add(wsIn);

    wsOut = new WSS4JOutInterceptor();
    wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
    wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties");
    wsOut.setProperty(WSHandlerConstants.USER, "myalias");
    wsOut.setProperty("password", "myAliasPassword");
    wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
    service.getOutInterceptors().add(wsOut);

    // Create the client
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setServiceClass(Echo.class);
    proxyFac.setAddress("local://Echo");
    proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
    
    echo = (Echo)proxyFac.create();

    client = ClientProxy.getClient(echo);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getInInterceptors().add(wsIn);
    client.getInInterceptors().add(new SAAJInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    client.getOutInterceptors().add(wsOut);
    client.getOutInterceptors().add(new SAAJOutInterceptor());
}