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

The following examples show how to use org.apache.cxf.jaxws.JaxWsServerFactoryBean#setWsdlLocation() . 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: ExtSoapHeaderClientServerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run() {
    String address0 = "http://localhost:" + PORT0 + "/SoapExtHeader/SampleService";

    Object implementor1 = new SamplePortTypeImpl();
    Endpoint.publish(address0, implementor1);

    String address1 = "http://localhost:" + PORT1 + "/SoapExtHeader/SampleService";
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(SamplePortTypeImpl.class);

    WebServiceClient webService = SampleService.class.getAnnotation(WebServiceClient.class);
    sf.setServiceName(new QName(webService.targetNamespace(), webService.name()));
    sf.setWsdlLocation(webService.wsdlLocation());
    sf.setAddress(address1);

    extserver = sf.create();
}
 
Example 2
Source File: ClientServerSwaTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run() {
    try {
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        factory.setBus(getBus());
        factory.setWsdlLocation("classpath:/swa-mime_jms.wsdl");
        factory.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
        factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
        factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceJMSPort"));
        factory.setAddress(ADDRESS + broker.getEncodedBrokerURL());
        factory.setServiceBean(new SwAServiceImpl());
        factory.create().start();
    } catch (Exception e) {
        e.printStackTrace();
        Thread.currentThread().interrupt();
    }
}
 
Example 3
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Server(String wsdl) throws Exception {
    System.out.println("Starting Server");
    String address = "http://localhost:9000/SoapContext/SoapPort";

    System.out.println("Starting Server");
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    //svrFactory.setServiceClass(Greeter.class);
    svrFactory.setWsdlLocation(wsdl);
    svrFactory.setAddress(address);
    svrFactory.setServiceBean(new GreeterImpl());
    svrFactory.setFeatures(Collections.singletonList(new LoggingFeature()));
    svrFactory.create();
}
 
Example 4
Source File: WSDLAddrPolicyAttachmentJaxwsMMProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    SpringBusFactory bf = new SpringBusFactory();
    Bus bus = bf.createBus("org/apache/cxf/systest/ws/addr_wsdl/jaxwsmm/server.xml");
    setBus(bus);
    JaxWsServerFactoryBean serviceFactory = new JaxWsServerFactoryBean();
    serviceFactory.setBus(bus);
    serviceFactory.setServiceClass(MessageProviderWithAddressingPolicy.class);
    serviceFactory.setWsdlLocation("wsdl_systest_wsspec/addr-jaxwsmm.wsdl");
    serviceFactory.setAddress(ADDRESS);
    org.apache.cxf.endpoint.Server provider = serviceFactory.create();
    EndpointInfo ei = provider.getEndpoint().getEndpointInfo();
    LOG.info("Started server at: " + ei.getAddress());

    testInterceptors(bus);
}
 
Example 5
Source File: CXFWebservicePublisher.java    From kumuluzee with MIT License 4 votes vote down vote up
public Server publish(final Endpoint endpoint, final Bus bus, final boolean cdiPresent) {

        final Class<?> clazz = endpoint.getImplementationClass();
        final String url = endpoint.getUrl();

        //inject resources into WS instance
        Stream.of(clazz.getDeclaredFields())
                .filter(f -> f.getType() == WebServiceContext.class)
                .forEach(f -> injectWebServiceResource(f, clazz));

        final Object targetBean = getBean(clazz, cdiPresent);

        AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder(bus);
        InjectionHelper.injectWebServiceContext(targetBean, KumuluzWebServiceContext.getInstance());

        final Invoker invoker = new KumuluzWSInvoker(clazz, targetBean);

        final JaxWsServerFactoryBean fb = new JaxWsServerFactoryBean();

        fb.setBlockPostConstruct(true);
        fb.setAddress(url);
        fb.setBus(bus);
        fb.setServiceClass(clazz);
        fb.setInvoker(invoker);
        fb.setHandlers(builder.buildHandlerChainFromClass(clazz, fb.getEndpointName(), fb.getServiceName(), fb.getBindingId()));

        if (endpoint.wsdlLocation() != null) {
            //top-down approach
            fb.setWsdlLocation(endpoint.wsdlLocation());
        }

        Server server = fb.create();

        LOG.info("Webservice endpoint published with address=" + fb.getAddress() +
                ", wsdlLocation=" + fb.getWsdlURL() +
                ", implementor=" + clazz.getName() +
                ", serviceName=" + endpoint.serviceName() +
                ", portName=" + endpoint.portName());

        return server;
    }
 
Example 6
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 7
Source File: AbstractDOMProvider.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void publish() throws Exception {
    String addr = epAddress;
    String wsdlLoc = null;
    String svcNm = null;
    String portNm = null;
    String tgtNmspc = null;
    String binding = null;
    Object obj = webSvcProviderVar.get("wsdlLocation", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_WSDL_LOCATION);
    }
    if (obj instanceof String) {
        wsdlLoc = (String)obj;
    }
    obj = webSvcProviderVar.get("serviceName", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_SERVICE_NAME);
    }
    if (obj instanceof String) {
        svcNm = (String)obj;
    }
    obj = webSvcProviderVar.get("portName", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_PORT_NAME);
    }
    if (obj instanceof String) {
        portNm = (String)obj;
    }
    obj = webSvcProviderVar.get("targetNamespace", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_TGT_NAMESPACE);
    }
    if (obj instanceof String) {
        tgtNmspc = (String)obj;
    }
    if (addr == null) {
        obj = webSvcProviderVar.get("EndpointAddress", scriptScope);
        if (obj != Scriptable.NOT_FOUND && obj instanceof String) {
            addr = (String)obj;
            isBaseAddr = false;
        }
    }
    if (addr == null) {
        throw new JSDOMProviderException(NO_EP_ADDR);
    }
    if (isBaseAddr) {
        if (addr.endsWith("/")) {
            addr += portNm;
        } else {
            addr = addr + "/" + portNm;
        }
    }
    obj = webSvcProviderVar.get("BindingType", scriptScope);
    if (obj != Scriptable.NOT_FOUND && obj instanceof String) {
        binding = (String)obj;
    }
    obj = webSvcProviderVar.get("invoke", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_INVOKE);
    }
    if (obj instanceof Function) {
        invokeFunc = (Function)obj;
    } else {
        throw new JSDOMProviderException(ILLEGAL_INVOKE_TYPE);
    }

    Bus bus = BusFactory.getThreadDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setWsdlLocation(wsdlLoc);
    factory.setBindingId(binding);
    factory.setServiceName(new QName(tgtNmspc, svcNm));
    factory.setEndpointName(new QName(tgtNmspc, portNm));
    ep = new EndpointImpl(bus, this, factory);
    ep.publish(addr);
}