You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Guy Pardon <gu...@atomikos.com> on 2010/12/01 21:37:26 UTC
How to get/pass a service reference?
Hi,
Just wondering: is there an easy and universally supported way of passing a reference to a service? I know WS-A EPRs exist, but is that it or am I missing something?
If EPR: how can a service in JAX-WS (or CXF if not standardized) get an EPR reference to itself?
Thanks
Guy
Re: How to get/pass a service reference?
Posted by Guy Pardon <gu...@me.com>.
Thanks to all. I will experiment with these ideas...
Sent from my iPad
On 2-dec.-2010, at 10:35, Andrew Dinn <an...@googlemail.com> wrote:
> On 12/01/2010 09:32 PM, Daniel Kulp wrote:
>> If you have the WebServiceContext injected, just call:
>>
>> context.getEndpointReference()
>>
>> and that should be it.
>
> That's all very well if something can be convinced to invoke the service first. But this is a chicken and egg situation. What can you do if e.g. service A wants to initiate communication with service B and send a message containing an EPR for A so that B can call back to A later.
>
> This is a problem I faced when implementing the WSTX standard and I could not work out how to resolve it using the method you describe. In the end I had to use an EPRBuilder and code up the EPR address using properties configured on the service deployment.
>
>
> regards,
>
>
> Andrew Dinn
> -----------
Re: How to get/pass a service reference?
Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 02 December 2010 4:35:05 am Andrew Dinn wrote:
> On 12/01/2010 09:32 PM, Daniel Kulp wrote:
> > If you have the WebServiceContext injected, just call:
> >
> > context.getEndpointReference()
> >
> > and that should be it.
>
> That's all very well if something can be convinced to invoke the service
> first. But this is a chicken and egg situation. What can you do if e.g.
> service A wants to initiate communication with service B and send a
> message containing an EPR for A so that B can call back to A later.
>
> This is a problem I faced when implementing the WSTX standard and I
> could not work out how to resolve it using the method you describe. In
> the end I had to use an EPRBuilder and code up the EPR address using
> properties configured on the service deployment.
Well, if you can get a handle to the javax.xml.ws.Endpoint that represents the
service, then you just need to call endpoint.getEndpointReference(); Kind
of. When running in a Servlet, that CAN be problematic as we don't know the
context and path and such until the first hit. Thus, prior to the first hit,
that endpoint address might not be completely valid.
For the most part, if you are using an embedded Jetty thing, you can just do
something like:
Endpoint ep = Endpoint.publish("http:///.....", myImpl);
ep.getEndpointReference();
to get the EPR to pass around.
If using Spring and you use a "jaxws:endpoint" element to define the endpoint,
the jaxws:endpoint maps directly to a javax.xml.ws.Endpoint object. You can
just lookup the been by ID from the context and cast to the Endpoint.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: How to get/pass a service reference?
Posted by Andrew Dinn <an...@googlemail.com>.
On 12/01/2010 09:32 PM, Daniel Kulp wrote:
> If you have the WebServiceContext injected, just call:
>
> context.getEndpointReference()
>
> and that should be it.
That's all very well if something can be convinced to invoke the service
first. But this is a chicken and egg situation. What can you do if e.g.
service A wants to initiate communication with service B and send a
message containing an EPR for A so that B can call back to A later.
This is a problem I faced when implementing the WSTX standard and I
could not work out how to resolve it using the method you describe. In
the end I had to use an EPRBuilder and code up the EPR address using
properties configured on the service deployment.
regards,
Andrew Dinn
-----------
Re: How to get/pass a service reference?
Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 01 December 2010 3:37:26 pm Guy Pardon wrote:
> Hi,
>
> Just wondering: is there an easy and universally supported way of passing a
> reference to a service? I know WS-A EPRs exist, but is that it or am I
> missing something?
>
> If EPR: how can a service in JAX-WS (or CXF if not standardized) get an EPR
> reference to itself?
If you have the WebServiceContext injected, just call:
context.getEndpointReference()
and that should be it.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: How to get/pass a service reference?
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
I guess you can get WebServiceContext injected and get a request URI from
HttpServletRequest. You can then return it as is or may be use
W3CEndpointReferenceBuilder to construct an EPR from this URI.
cheers, Sergey
On Wed, Dec 1, 2010 at 8:37 PM, Guy Pardon <gu...@atomikos.com> wrote:
> Hi,
>
> Just wondering: is there an easy and universally supported way of passing a
> reference to a service? I know WS-A EPRs exist, but is that it or am I
> missing something?
>
> If EPR: how can a service in JAX-WS (or CXF if not standardized) get an EPR
> reference to itself?
>
> Thanks
> Guy