Question

My goal is to set up a generic web service. By "generic" in this context I mean that, one should be able to run an arbitrary sequence of tools on the input (let's say a file). These tools are compiled programms installed on the server.

My idea was to specify each tool in a central WSDL File. This WSDL File is parsed and for each tool, included in the WSDL file, a separate Service Class is created, which executes the respective tool via apache commons exec.

Is it then possible to manually create a SOAP Message in which the sequence of tools, one wants to perform on the input, is specified ? This SOAP Message should then be parsed and the respective Service Classes should be started.

I have to say I'm completely new to Web Service programming and I'm gratefuly for any advice. The above is just an idea and I'm open for any better advice ;)

greetings,

Was it helpful?

Solution

You can create, modify SOAP messages manually (programmatically) by implementing SOAPHandler<SOAPMessageContext> interface. Then you need to override this method:

public boolean handleMessage(SOAPMessageContext context) {
   //do anything you like with a message    
}

You get the SOAP message from SOAPMessageContext object passed into this method:

SOAPMessage soapMsg = context.getMessage();

From your message you can get SOAP Body, SOAP Envelope, SOAP Header. You can add as many element as you like by doing this. But do not forget that every element you add manually must match your XSD of your WSDL file.

To declare this handler into JAX-WS context you can Spring configuration as follows:

  <jaxws:endpoint id="HandlerExample"
                  implementor="your.service.ImplemetationClass"
                  address="http://localhost:8080/Example/services/Example">
    <jaxws:handlers>
       <bean class="your.Handler" />
    </jaxws:handlers>
  </jaws:endpoint>

More information about how to configure JAX-WS endpoint you can find here. Also information about handlers you can find here.

Hope this helps for a start.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top