views:

84

answers:

1

I have different Spring Web Services, which are included into the context by the Endpoint Annotation, so there are no dependencies despite the Annotation (no interface etc.). Therefore, no "context" information is present.

Now I want to chain a web service request, ie. an Endpoint is called which itself should call a web service on the same server. I can use Spring's WebServiceTemplate, however, I need the current server url for this request.

Is there any way how this url can be injected during application startup into the Endpoints? Since the Endpoints do not extend some class, there is no way to get this information anywhere inside the Endpoints, also the request parameters do not have this information (these are simple JAXB-classes, which are marshalled on request).

A: 

I believe the best option is to send the URL as part of the request.

This also enables you to dynamically change the URL to a third server later.

Espen
Thats true, however, I dont have it. It handled by Spring internally and I dont know how to access it. My classes (Endpoints) are called with the pure JAXB objects.
Ice09
Spring's `WebServiceTemplate` class has a `getDefaultUri()` method that you can use.
Espen
But where does it come from? Somewhere the WebServiceTemplate has to be defined in the app-context and it has to be set there, doesnt it? Since I am using the WebServiceTemplate inside the Endpoint (chaining...), I do not know the actual adress of the server, provided that Spring does not provide such a property "by itself", which could be injected during startup into the endpoint.
Ice09
You can send the URL as a property in the JAXB request object. Then you can use this URL and create a new WebServiceTemplate. Eventually have a separate `WebServiceTemplate` bean in your repository and just inject the URL into this bean.
Espen