• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

pom.xml

<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
<webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
<webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
<contextPath>/Service</contextPath>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>4433</port>
</connector>
</connectors>
<contextHandlers>
<contextHandler implementation="org.mortbay.jetty.handler.ContextHandler">
<contextPath>/Service</contextPath>
<resourceBase>${java.io.tmpdir}</resourceBase>
<handler implementation="org.mortbay.jetty.handler.ResourceHandler"/>
</contextHandler>
</contextHandlers>
</configuration>
</plugin>
</plugins>
</build>

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

@WebService(portName="Service",
serviceName="Service",
targetNamespace = "http://project.company.de/project-webutils/wsdl",
endpointInterface="de.company.project.project_webutils.wsdl.Service")

public class ServiceImpl implements Service {
...
 }
 
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic