|
Replies:
9
-
Last Post:
Sep 18, 2008 11:12 AM
by: vinodsingh
|
|
|
|
|
|
|
How to override endpoint address of service from client code
Posted:
Sep 17, 2008 11:46 AM
|
|
|
Hi All,
I am working for a use case where I need to overwrite the endpoint of service from client code? I have cached the wsdl in the file system along with the project. However, when client is invoked, based on some configuration that client selects I need to invoke service hosted in different machines. How can I override the endpoint address of the service from code for this?
Thanks, Manesh
|
|
|
|
|
|
|
Re: How to override endpoint address of service from client code
Posted:
Sep 17, 2008 11:54 AM
in response to: maneshhere
|
|
|
Use the following: ((BindingProvider) yourPortVariable).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://host:port/.....");
Leo Golubovsky
metro@javadesktop.org wrote: > Hi All, > > I am working for a use case where I need to overwrite the endpoint of service from client code? I have cached the wsdl in the file system along with the project. However, when client is invoked, based on some configuration that client selects I need to invoke service hosted in different machines. How can I override the endpoint address of the service from code for this? > > Thanks, > Manesh > [Message sent by forum member 'maneshhere' (maneshhere)] > > http://forums.java.net/jive/thread.jspa?messageID=299909 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net > For additional commands, e-mail: users-help@metro.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|
|
Re: How to override endpoint address of service from client code
Posted:
Sep 17, 2008 12:04 PM
in response to: Leo Golubovsky
|
|
|
Hi Leo,
Thanks for a quick reply. Can I change the endpoint address before creating the port somehow?
In my use case, I am creating a custom transport tube. I am basing my tube creation based on the scheme of the endpoint. To force this can I change the endpoint url (including a scheme change) before port creation?
Thanks, Manesh
|
|
|
|
|
|
|
|
Re: How to override endpoint address of service from client code
Posted:
Sep 17, 2008 12:37 PM
in response to: maneshhere
|
|
|
I do not know - never tried it. Endpoint is an attribute of the port which is created based on the wsdl from the service I guess. I am not sure where u would overwrite that.
Leo
metro@javadesktop.org wrote: > Hi Leo, > > Thanks for a quick reply. Can I change the endpoint address before creating the port somehow? > > In my use case, I am creating a custom transport tube. I am basing my tube creation based on the scheme of the endpoint. To force this can I change the endpoint url (including a scheme change) before port creation? > > Thanks, > Manesh > [Message sent by forum member 'maneshhere' (maneshhere)] > > http://forums.java.net/jive/thread.jspa?messageID=299915 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net > For additional commands, e-mail: users-help@metro.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|
|
|
|
Re: How to override endpoint address of service from client code
Posted:
Sep 17, 2008 1:00 PM
in response to: ramapulavarthi
|
|
|
Hi Rama,
Thanks,
In my use case, I am creating a custom transport tube. I am basing my tube creation based on the scheme of the endpoint. To force this can I change the endpoint url (including a scheme change) before port creation?
I have only a single wsdl file. I just need to change the endpoint address to some other scheme and url.
Thanks, Manesh
|
|
|
|
|
|
|
|
Re: How to override endpoint address of service from client code
Posted:
Sep 17, 2008 6:36 PM
in response to: maneshhere
|
|
|
That's pretty specialized, since you are already using custom tubes there may be more specific hooks, but I can think of a number of approaches that just change the WSDL used: The WSDL used to initialise the client is specified by a URL passed into the Service constructor, the default constructor for a generated service uses a pre-configured value, but you can also specify a URL explicitly - so at service construction time you can point at WSDL with customized endpoints. Presumably the selection made by the client comes from somewhere - if it is a static list then it is probably just easiest to use the catalog facility (jax-ws-catalog.xml) to set up a collection of local resources (identified by abstract URLs) that are substituted with appropriate endpoints. If the list is dynamic then you could get the WSDL from the same place.
I can think of many more exotic alternatives - using a custom URL scheme for the default WSDL URL and implementing your own handler (or specifying a handler when constructing the URL passed to Service), and using the handler to serve up substituted WSDL.
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|
|
Re: How to override endpoint address of service from client code
Posted:
Sep 18, 2008 12:02 AM
in response to: Clive Brettingh...
|
|
|
It shouldn't all that complicated. I have seen a relevant thread in the same forum. http://forums.java.net/jive/thread.jspa?messageID=298460񈷜
But that also is not doing good for me. I added a custom port to the service. But in getPort() it is not returning the just created port. I see from a post of Jitu that it is only for dispatch cases.
In my case usually URL is dynamically generated based on client input. For example if user is 'manesh', I will create endpoint as sb://globalserver.com/services/manesh/calculator. If the user is anish, I will create endpoint as sb://globalserver.com/services/anish/calculator. So based on some input at runtime, I should build up the endpoint url.
Thanks, Manesh
|
|
|
|
|
|
|
|
Re: How to override endpoint address of service from client code
Posted:
Sep 18, 2008 2:10 AM
in response to: maneshhere
|
|
|
You don't need to dynamically add ports if you have specified WSDL, either using Service.create(URL,QName) or a generated Service class (instances of gererated service are just like the two arg create; the default constructor simply uses a default WSDL URL & QName). As you have noticed Service.create(QName) is really only useful for Dispatch, but the two argument method (and subclasses) will work out the ports from the WSDL (WSDL is also needed for the getPort methods to work). The default endpoint addressed come from this WSDL - and as my previous post mentioned there should be no obstacle to changing this WSDL to either specify a location with the desired protocol, of as the discussion you linked suggests, a placeholder that defers transport creation.
If you don't actually need to change protocol the simplest is to use a WSDL resource with endpoints with the desired protocol and override with full runtime detail by setting the endpoint address on the proxy. Otherwise my suggestion of using a custom URLStreamHandler should allow completely dynamic manipulation of the WSDL.
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|