You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Chris Dunphy <ch...@sjrb.ca> on 2008/05/22 23:31:19 UTC

wsdl2java java code generation for multiple hosts

Hello,

Is it possible to generate a java service using the CXF wsdl2java
(JAX-WS front end) in such a way that we can use the service with more
than one host?

Basically, I am working on a project where a centralized console
communicates via web services to a number of agents running on remote
hosts.  

On the console side I want to be able to use one set of wsdl generated
stub classes and just tell the ServiceImpl class which host to connect
to.

Is this possible?

Thanks,


Chris Dunphy             
Software Developer, Enterprise Software Development
Shaw Cablesystems G.P.  750-7417 chris.dunphy@sjrb.ca
Suite 800 630 3rd Avenue SW, Calgary, Alberta, T2P 4L4
 
try {
    succeed();
} catch (const failed_error& e) {
    try {
        try_again();
    }
}
 


Re: wsdl2java java code generation for multiple hosts

Posted by Daniel Kulp <dk...@apache.org>.
Yes.   There are a couple of options:

1) When you create your Service object, the first parameter is the  
wsdl URL to use.    If you point that to the wsdl (possibly the live "? 
wsdl" on the host you want), any proxies (getPort(..)/createPort(...))  
stuff created from there will use the URL's in that wsdl.

2) After calling the getPort/createPort, you can override the address  
in it by doing:
((BindingProvider)port).getRequestContext().put(
     BindingProvider.ENDPOINT_ADDRESS_URL,
     address);


With #2, memory footprint will be less and the startup is quicker as  
the wsdl can be cached.   Only one wsdl is used and it's just the  
address that is overridden.    However, you have to make sure that  
proxy is synchronized  or only used on one thread or something as use  
of  the RequestContext is not thread safe.   (Although in 2.1/2.0.6,  
there is a way to make it thread safe at the expense of using more  
ThreadLocals internally)


Dan





On May 22, 2008, at 5:31 PM, Chris Dunphy wrote:

> Hello,
>
> Is it possible to generate a java service using the CXF wsdl2java
> (JAX-WS front end) in such a way that we can use the service with more
> than one host?
>
> Basically, I am working on a project where a centralized console
> communicates via web services to a number of agents running on remote
> hosts.
>
> On the console side I want to be able to use one set of wsdl generated
> stub classes and just tell the ServiceImpl class which host to connect
> to.
>
> Is this possible?
>
> Thanks,
>
>
> Chris Dunphy
> Software Developer, Enterprise Software Development
> Shaw Cablesystems G.P.  750-7417 chris.dunphy@sjrb.ca
> Suite 800 630 3rd Avenue SW, Calgary, Alberta, T2P 4L4
>
> try {
>    succeed();
> } catch (const failed_error& e) {
>    try {
>        try_again();
>    }
> }
>
>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog





Re: wsdl2java java code generation for multiple hosts

Posted by Benson Margulies <bi...@gmail.com>.
Sure. You can always override the URL from the WSDL by asking the
endpoint nicely, and the server side will always patch the generated
WSDL to show the place it's actually sitting unless you override that.

On Thu, May 22, 2008 at 5:31 PM, Chris Dunphy <ch...@sjrb.ca> wrote:
> Hello,
>
> Is it possible to generate a java service using the CXF wsdl2java
> (JAX-WS front end) in such a way that we can use the service with more
> than one host?
>
> Basically, I am working on a project where a centralized console
> communicates via web services to a number of agents running on remote
> hosts.
>
> On the console side I want to be able to use one set of wsdl generated
> stub classes and just tell the ServiceImpl class which host to connect
> to.
>
> Is this possible?
>
> Thanks,
>
>
> Chris Dunphy
> Software Developer, Enterprise Software Development
> Shaw Cablesystems G.P.  750-7417 chris.dunphy@sjrb.ca
> Suite 800 630 3rd Avenue SW, Calgary, Alberta, T2P 4L4
>
> try {
>    succeed();
> } catch (const failed_error& e) {
>    try {
>        try_again();
>    }
> }
>
>
>

Re: wsdl2java java code generation for multiple hosts

Posted by Christian Schneider <ch...@die-schneider.net>.
Hello Chris,

I am using the JaxWsProxyFactoryBean to do what you described. In the 
sample code here I went java first but this should work the same for 
wsdl2java.
You simply set the url of the service in setAddress and then initialize 
a stub for this service.
Is this what you wanted?

Best regards

Christian

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:9000/helloWorld");
HelloWorld client = (HelloWorld) factory.create();
String reply = client.sayHi("HI");


Chris Dunphy schrieb:
> Hello,
>
> Is it possible to generate a java service using the CXF wsdl2java
> (JAX-WS front end) in such a way that we can use the service with more
> than one host?
>
> Basically, I am working on a project where a centralized console
> communicates via web services to a number of agents running on remote
> hosts.  
>
> On the console side I want to be able to use one set of wsdl generated
> stub classes and just tell the ServiceImpl class which host to connect
> to.
>
> Is this possible?
>
> Thanks,
>
>
> Chris Dunphy             
> Software Developer, Enterprise Software Development
> Shaw Cablesystems G.P.  750-7417 chris.dunphy@sjrb.ca
> Suite 800 630 3rd Avenue SW, Calgary, Alberta, T2P 4L4
>  
> try {
>     succeed();
> } catch (const failed_error& e) {
>     try {
>         try_again();
>     }
> }
>  
>
>
>