You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by God Dang <go...@hotmail.com> on 2016/06/27 19:00:31 UTC

Problem with multiple ports for one Service

I'm trying to develop a Server that serves two "services" using different ports in the WSDL, i.e.--- 8< ---
    <wsdl:service name="Service">        <wsdl:port name="ServicePort-v1" binding="service:ServiceBinding-v1">            <soap:address location="http://uri/Service/v1"/>        </wsdl:port>        <wsdl:port name="ServicePort-v2" binding="service:ServiceBinding-v2">            <soap:address location="http://uri/Service/v2"/>        </wsdl:port>    </wsdl:service>--- 8< ---

I've implemented two services using:--- 8< ---
@WebService (        serviceName = "Service",        portName = "ServicePort-v1",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace = "http://uri/Service")public class MyService1 {...}--- 8< ---
@WebService (        serviceName = "Service",        portName = "ServicePort-v2",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace = "http://uri/Service")public class MyService2 {...}--- 8< ---

And then starting the services using:--- 8< ---
        final Service1 implementor1 = new Service1(...);        final JaxWsServerFactoryBean serverFactoryBean1 = new JaxWsServerFactoryBean();
        serverFactoryBean1.setServiceClass(Service1.class);        serverFactoryBean1.setAddress(address + "/v1");        serverFactoryBean1.setServiceBean(implementor1);        serverFactoryBean1.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor1));
        Server server1 = serverFactoryBean1.create();

        final Service2 implementor2 = new Service2(...);        final JaxWsServerFactoryBean serverFactoryBean2 = new JaxWsServerFactoryBean();
        serverFactoryBean2.setServiceClass(Service2.class);        serverFactoryBean2.setAddress(address + "/v2");        serverFactoryBean2.setServiceBean(implementor2);        serverFactoryBean2.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor2));
        Server server2 = serverFactoryBean2.create();--- 8< ---

But only the second service is working. When I start them one at a time they're working so the underlying implementation is good. I can't seem to find a good way to create a Server that can route on multiple ports(WSDL-ports that is).
I've searched long and hard but have yet to find any recent information on how to go about this and would be very grateful for any pointers.
Regards, Dang
 		 	   		  

RE: Problem with multiple ports for one Service

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

Multiple endpoints are supported out of the box.

Take a look into integration tests, for example https://github.com/apache/cxf/blob/master/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerServer.java 
Server publishes the multiple endpoints.

Regards,
Andrei.

> -----Original Message-----
> From: God Dang [mailto:goddang@hotmail.com]
> Sent: Mittwoch, 29. Juni 2016 16:26
> To: users@cxf.apache.org
> Subject: RE: Problem with multiple ports for one Service
> 
> I've been trying this oldie: http://cxf.547215.n5.nabble.com/Deploying-
> multiple-endpoints-ports-for-a-service-td569470.htmlbut can't get it to work.
> Are people still using CXF? Most examples and code that you find when
> searching how to solve this seem to be really old...
> /dang
> 
> From: goddang@hotmail.com
> To: users@cxf.apache.org
> Subject: Problem with multiple ports for one Service
> Date: Mon, 27 Jun 2016 19:00:31 +0000
> 
> 
> 
> 
> I'm trying to develop a Server that serves two "services" using different ports in
> the WSDL, i.e.--- 8< ---
>     <wsdl:service name="Service">        <wsdl:port name="ServicePort-v1"
> binding="service:ServiceBinding-v1">            <soap:address
> location="http://uri/Service/v1"/>        </wsdl:port>        <wsdl:port
> name="ServicePort-v2" binding="service:ServiceBinding-v2">
> <soap:address location="http://uri/Service/v2"/>        </wsdl:port>
> </wsdl:service>--- 8< ---
> 
> I've implemented two services using:--- 8< ---
> @WebService (        serviceName = "Service",        portName = "ServicePort-
> v1",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace =
> "http://uri/Service")public class MyService1 {...}--- 8< ---
> @WebService (        serviceName = "Service",        portName = "ServicePort-
> v2",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace =
> "http://uri/Service")public class MyService2 {...}--- 8< ---
> 
> And then starting the services using:--- 8< ---
>         final Service1 implementor1 = new Service1(...);        final
> JaxWsServerFactoryBean serverFactoryBean1 = new
> JaxWsServerFactoryBean();
>         serverFactoryBean1.setServiceClass(Service1.class);
> serverFactoryBean1.setAddress(address + "/v1");
> serverFactoryBean1.setServiceBean(implementor1);
> serverFactoryBean1.getServiceFactory().setInvoker(new
> JAXWSMethodInvoker(implementor1));
>         Server server1 = serverFactoryBean1.create();
> 
>         final Service2 implementor2 = new Service2(...);        final
> JaxWsServerFactoryBean serverFactoryBean2 = new
> JaxWsServerFactoryBean();
>         serverFactoryBean2.setServiceClass(Service2.class);
> serverFactoryBean2.setAddress(address + "/v2");
> serverFactoryBean2.setServiceBean(implementor2);
> serverFactoryBean2.getServiceFactory().setInvoker(new
> JAXWSMethodInvoker(implementor2));
>         Server server2 = serverFactoryBean2.create();--- 8< ---
> 
> But only the second service is working. When I start them one at a time they're
> working so the underlying implementation is good. I can't seem to find a good
> way to create a Server that can route on multiple ports(WSDL-ports that is).
> I've searched long and hard but have yet to find any recent information on how
> to go about this and would be very grateful for any pointers.
> Regards, Dang
> 
> 

Re: Problem with multiple ports for one Service

Posted by God Dang <go...@hotmail.com>.
Ok, after some more digging the problem seems to be the following:

If I start up both services on "http://localhost/service" and "http://localhost/service/v2" respectively we can successfully process SOAP requests on "http://localhost/service/v2". When we try to use the other service we get an:

"org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader: Unexpected EOF in prolog".


This comes from the the fact that we don't get a valid SOAP-response back but a 302 with location "http://localhost/service/" notice the trailing slash at the end. If we turn on autoredirect on the http conduit it will work. It will also work if we adress the URL using trailing slash directly.


Is there a way to not have the built-in Jetty behave like this and treat "/service" and "/service/" the same? Unfortunately we know that some clients out there do not have autoredirect set to true so this change would break for them.


Regards, Dang


________________________________
From: God Dang <go...@hotmail.com>
Sent: Friday, August 26, 2016 1:30 PM
To: users@cxf.apache.org
Subject: RE: Problem with multiple ports for one Service

Hi Andrei, sorry I wasn't clear in my example, it was even wrong. The problem is when using the same base url, i.e. "http://localhost/service" and "http://localhost/service/v2". It seems as if the url mapping is for the address+anything after it, i.e. "http://localhost/server/*" which overrides "http://localhost/server/v2".

I have still not found a solution for this.

Regards, Dang

________________________________

Hi,

Multiple endpoints are supported out of the box.

Take a look into integration tests, for example https://github.com/apache/cxf/blob/master/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerServer.java

Server publishes the multiple endpoints.

Regards,
Andrei.

________________________________
From: goddang@hotmail.com
To: users@cxf.apache.org
Subject: Problem with multiple ports for one Service
Date: Mon, 27 Jun 2016 19:00:31 +0000

I'm trying to develop a Server that serves two "services" using different ports in the WSDL, i.e.
--- 8< ---
    <wsdl:service name="Service">
        <wsdl:port name="ServicePort-v1" binding="service:ServiceBinding-v1">
            <soap:address location="http://uri/Service/v1"/>
        </wsdl:port>
        <wsdl:port name="ServicePort-v2" binding="service:ServiceBinding-v2">
            <soap:address location="http://uri/Service/v2"/>
        </wsdl:port>
    </wsdl:service>
--- 8< ---

I've implemented two services using:
--- 8< ---
@WebService (
        serviceName = "Service",
        portName = "ServicePort-v1",
        wsdlLocation = "WEB-INF/Service.wsdl",
        targetNamespace = "http://uri/Service")
public class MyService1 {
...
}
--- 8< ---
@WebService (
        serviceName = "Service",
        portName = "ServicePort-v2",
        wsdlLocation = "WEB-INF/Service.wsdl",
        targetNamespace = "http://uri/Service")
public class MyService2 {
...
}
--- 8< ---

And then starting the services using:
--- 8< ---
        final Service1 implementor1 = new Service1(...);
        final JaxWsServerFactoryBean serverFactoryBean1 = new JaxWsServerFactoryBean();

        serverFactoryBean1.setServiceClass(Service1.class);
        serverFactoryBean1.setAddress(address + "/v1");
        serverFactoryBean1.setServiceBean(implementor1);
        serverFactoryBean1.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor1));

        Server server1 = serverFactoryBean1.create();


        final Service2 implementor2 = new Service2(...);
        final JaxWsServerFactoryBean serverFactoryBean2 = new JaxWsServerFactoryBean();

        serverFactoryBean2.setServiceClass(Service2.class);
        serverFactoryBean2.setAddress(address + "/v2");
        serverFactoryBean2.setServiceBean(implementor2);
        serverFactoryBean2.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor2));

        Server server2 = serverFactoryBean2.create();
--- 8< ---

But only the second service is working. When I start them one at a time they're working so the underlying implementation is good. I can't seem to find a good way to create a Server that can route on multiple ports(WSDL-ports that is).

I've searched long and hard but have yet to find any recent information on how to go about this and would be very grateful for any pointers.

Regards, Dang


RE: Problem with multiple ports for one Service

Posted by God Dang <go...@hotmail.com>.
Hi Andrei, sorry I wasn't clear in my example, it was even wrong. The problem is when using the same base url, i.e. "http://localhost/service" and "http://localhost/service/v2". It seems as if the url mapping is for the address+anything after it, i.e. "http://localhost/server/*" which overrides "http://localhost/server/v2".
I have still not found a solution for this.
Regards, Dang



Hi,

Multiple endpoints are supported out of the box.

Take a look into integration tests, for example https://github.com/apache/cxf/blob/master/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerServer.java

Server publishes the multiple endpoints.

Regards,
Andrei.
From: goddang@hotmail.com
To: users@cxf.apache.org
Subject: Problem with multiple ports for one Service
Date: Mon, 27 Jun 2016 19:00:31 +0000




I'm trying to develop a Server that serves two "services" using different ports in the WSDL, i.e.--- 8< ---
    <wsdl:service name="Service">        <wsdl:port name="ServicePort-v1" binding="service:ServiceBinding-v1">            <soap:address location="http://uri/Service/v1"/>        </wsdl:port>        <wsdl:port name="ServicePort-v2" binding="service:ServiceBinding-v2">            <soap:address location="http://uri/Service/v2"/>        </wsdl:port>    </wsdl:service>--- 8< ---

I've implemented two services using:--- 8< ---
@WebService (        serviceName = "Service",        portName = "ServicePort-v1",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace = "http://uri/Service")public class MyService1 {...}--- 8< ---
@WebService (        serviceName = "Service",        portName = "ServicePort-v2",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace = "http://uri/Service")public class MyService2 {...}--- 8< ---

And then starting the services using:--- 8< ---
        final Service1 implementor1 = new Service1(...);        final JaxWsServerFactoryBean serverFactoryBean1 = new JaxWsServerFactoryBean();
        serverFactoryBean1.setServiceClass(Service1.class);        serverFactoryBean1.setAddress(address + "/v1");        serverFactoryBean1.setServiceBean(implementor1);        serverFactoryBean1.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor1));
        Server server1 = serverFactoryBean1.create();

        final Service2 implementor2 = new Service2(...);        final JaxWsServerFactoryBean serverFactoryBean2 = new JaxWsServerFactoryBean();
        serverFactoryBean2.setServiceClass(Service2.class);        serverFactoryBean2.setAddress(address + "/v2");        serverFactoryBean2.setServiceBean(implementor2);        serverFactoryBean2.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor2));
        Server server2 = serverFactoryBean2.create();--- 8< ---

But only the second service is working. When I start them one at a time they're working so the underlying implementation is good. I can't seem to find a good way to create a Server that can route on multiple ports(WSDL-ports that is).
I've searched long and hard but have yet to find any recent information on how to go about this and would be very grateful for any pointers.
Regards, Dang
 		 	   		   		 	   		   		 	   		  

RE: Problem with multiple ports for one Service

Posted by God Dang <go...@hotmail.com>.
I've been trying this oldie: http://cxf.547215.n5.nabble.com/Deploying-multiple-endpoints-ports-for-a-service-td569470.htmlbut can't get it to work.
Are people still using CXF? Most examples and code that you find when searching how to solve this seem to be really old...
/dang

From: goddang@hotmail.com
To: users@cxf.apache.org
Subject: Problem with multiple ports for one Service
Date: Mon, 27 Jun 2016 19:00:31 +0000




I'm trying to develop a Server that serves two "services" using different ports in the WSDL, i.e.--- 8< ---
    <wsdl:service name="Service">        <wsdl:port name="ServicePort-v1" binding="service:ServiceBinding-v1">            <soap:address location="http://uri/Service/v1"/>        </wsdl:port>        <wsdl:port name="ServicePort-v2" binding="service:ServiceBinding-v2">            <soap:address location="http://uri/Service/v2"/>        </wsdl:port>    </wsdl:service>--- 8< ---

I've implemented two services using:--- 8< ---
@WebService (        serviceName = "Service",        portName = "ServicePort-v1",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace = "http://uri/Service")public class MyService1 {...}--- 8< ---
@WebService (        serviceName = "Service",        portName = "ServicePort-v2",        wsdlLocation = "WEB-INF/Service.wsdl",        targetNamespace = "http://uri/Service")public class MyService2 {...}--- 8< ---

And then starting the services using:--- 8< ---
        final Service1 implementor1 = new Service1(...);        final JaxWsServerFactoryBean serverFactoryBean1 = new JaxWsServerFactoryBean();
        serverFactoryBean1.setServiceClass(Service1.class);        serverFactoryBean1.setAddress(address + "/v1");        serverFactoryBean1.setServiceBean(implementor1);        serverFactoryBean1.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor1));
        Server server1 = serverFactoryBean1.create();

        final Service2 implementor2 = new Service2(...);        final JaxWsServerFactoryBean serverFactoryBean2 = new JaxWsServerFactoryBean();
        serverFactoryBean2.setServiceClass(Service2.class);        serverFactoryBean2.setAddress(address + "/v2");        serverFactoryBean2.setServiceBean(implementor2);        serverFactoryBean2.getServiceFactory().setInvoker(new JAXWSMethodInvoker(implementor2));
        Server server2 = serverFactoryBean2.create();--- 8< ---

But only the second service is working. When I start them one at a time they're working so the underlying implementation is good. I can't seem to find a good way to create a Server that can route on multiple ports(WSDL-ports that is).
I've searched long and hard but have yet to find any recent information on how to go about this and would be very grateful for any pointers.
Regards, Dang