• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access server configuration information from JAX-WS web service implementation?  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set up a working project which deploys a web service using JAX-WS to a Jetty web server via Maven Jetty Plugin.
I attached part of pom.xml, web service interface and web service implementation below.

So, what's the problem?

The web service generates a file which must be made available via http. The web service responds with the URI of that file.
I thought the best option to accomplish this is to define a ContextHandler serving as a file server (see pom.xml below).
I want to be able to configure the resourceBase and contextPath.

However, I did not find a way to access this (any) configuration from the web service implementation in order to provide the necessary 
information to the web service where to store the generated file on disk. Besides persisting the file, I need to determine the URI to be returned
back to the client. While I am only declaring the contextPath in pom.xml, which I need to have access to, how can I actually determine host and port
within the web service implemention? There is nothing such as a request object known from servlets.  

Or is there a better way?


<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<contextHandler implementation="org.mortbay.jetty.handler.ContextHandler">
<handler implementation="org.mortbay.jetty.handler.ResourceHandler"/>

Web Service Interface

@WebService(targetNamespace = "http://project.company.de/project-webutils/wsdl", name = "Service")
@XmlSeeAlso({de.company.project.project_webutils.xsd.ObjectFactory.class, de.company.project.resources.ObjectFactory.class})
public interface Service {

@WebResult(name = "return", targetNamespace = "http://project.company.de/project-webutils/xsd")
@RequestWrapper(localName = "Align", targetNamespace = "http://project.company.de/project-webutils/xsd", className = "de.company.project.project_webutils.xsd.AlignType")
@WebMethod(operationName = "Align", action = "Align")
@ResponseWrapper(localName = "AlignResponse", targetNamespace = "http://project.company.de/project-webutils/xsd", className = "de.company.project.project_webutils.xsd.AlignResponseType")
public java.lang.String align(
@WebParam(name = "param1", targetNamespace = "http://project.company.de/project-webutils/xsd")
java.lang.String param1,
@WebParam(name = "param2", targetNamespace = "http://project.company.de/project-webutils/xsd")
java.lang.String param2,
@WebParam(name = "input3", targetNamespace = "http://project.company.de/project-webutils/xsd")
java.lang.String input3,
@WebParam(name = "parameters", targetNamespace = "http://project.company.de/project-webutils/xsd")
java.util.List<de.company.project.resources.ArgumentType> parameters
) throws SERVICEFault;

Web Service implementation

targetNamespace = "http://project.company.de/project-webutils/wsdl",

public class ServiceImpl implements Service {
Ranch Hand
Posts: 2198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to obtain the HttpServletRequest object of a web service request in a JAX-WS web service handler.
Using the getRequestURL method you should be able to retrieve the URL the client used to perform the request.
In the handler, you can then insert the data you need in the web service into the SOAP message context.
The message context can later be obtained in the web service, via the WebServiceContext.
Best wishes!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!