Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8455887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:24:14+00:00 2026-06-10T12:24:14+00:00

I’m working on a web service using the top-down approach, generating service types and

  • 0

I’m working on a web service using the top-down approach, generating service types and interfaces from a WSDL using JAX-WS’ wsimport. This provides a port type interface as follows, which I implement.

/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.2.4-b01
 * Generated source version: 2.2
 */
@WebService(name = "ExamplePortType", targetNamespace = "http://example.com")
public interface ExamplePortType {

    /**
     * @param example
     * @return java.lang.String
     * @throws ExampleException
     */
    @WebMethod
    @WebResult(name = "exampleResponse", targetNamespace = "http://example.com")
    @RequestWrapper(localName = "sendExample", targetNamespace = "http://example.com", className = "com.example.SendExample")
    @ResponseWrapper(localName = "sendExampleResponse", targetNamespace = "http://example.com", className = "com.example.SendExampleResponse")
    public String sendExample(
        @WebParam(name = "example", targetNamespace = "http://example.com")
        ExampleRequest example)
        throws ExampleException
    ;
}

It seems like the normal way to add this service to your application server (in my case, Tomcat), is to add the implementation class to the web.xml as a servlet and add WSServletContextListener as a listener. Very roughly, it seems that on initialization of the context, the listener constructs ServletAdapters which wrap the implementation bean and add them to a WSServletDelegate which is called by a thin WSServlet. Requests to your implementation are then handled by the WSServlet and passed to your bean by the delegate based on whatever URL patterns you have set up.

Is there a way to do the above programmatically? I want a method which accepts an instance of the above interface and returns to me an instance of a Servlet, which, if registered in a ServletContext, would route the appropriate requests to the wrapped implementation. Something like:

Servlet exampleServlet = new ServletAdapter().wrap(new ExamplePortTypeImpl());

One requirement is that I cannot rely on static configuration files (such as web.xml or sun-jaxws.xml). Does JAX-WS or a related library (ie: Axis2, etc.) provide this kind of functionality?

Apologies if something is not clear; it’s my first time here :). Any pointers are appreciated.

Currently Using JAX-WS 2.1, Tomcat 7, Servlet 3.0.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:24:16+00:00Added an answer on June 10, 2026 at 12:24 pm

    Okay, after a lot of experimenting, I’ve been able to put together something that works. I’ll post it here for the sake of documentation.

    Basically, I got to this by emulating or re-implementing how JAX-WS creates it’s WSServlet from it’s WSServletContextListener. Unfortunately, I was not able to find an easier or better support and straightforward way of doing this.

    Basically, my factory creates a WSEndpoint using it’s WSEndpoint.create() method. create() takes as input the Class of the WebService implementation which I’m trying to wrap. Most of the other inputs are null to encourage WSEndpoint to use a default or try to pull some configuration off of annotations in the implementation class.

    I then use a new ServletAdapterList() to create a ServletAdapter using the previously created WSEndpoint. For this, since I’m creating one Servlet per implementation class, the name of the adapter doesn’t matter, and it can be configured to send all traffic to the implementation regardless of the URL.

    Then, I create a single new WSServletDelegate() using a singleton list of the prior ServletAdapter. The only trick here is that it seems that JAX-WS has, at least for this and the next step, a bad habit of storing some values in the init params of the ServletContext. It also doesn’t null check properly, even though it has defaults to use if the parameters are not in the context. So I also ended up creating a dummy implementation of the ServletContext which I pass into the WSServletDelegate constructor to make it feel like it’s looking up init params.

    Lastly, I created an implementation of HttpServlet that forwards requests to the WSServletDelegate similar to how WSServlet does. Since WSServlet again stores the delegate object in the ServletContext init params, I found it easier to just re-implement its functionality than mess around with the existing WSServlet. This implementation of an HttpServlet can then be treated like any normal Servlet that will accept and handle SOAP webservice calls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.