1
votes

Is there a way to process SOAP requests manually or on a per-request basis? Due to some very silly technical reasons in an existing system I cannot just publish JAX-WS services to an Endpoint created via the standard Endpoints factory. My situation is a bit messed up in that I am basically handed a raw InputStream from a ServerSocket and told to process it.

The data in the stream is being sent from a client that makes SOAP requests. The developer of the client provides a bunch of WSDL's and XSD's for generating the necessary server side classes using wsimport and xjc. All of it is JAX-WS and I would like to leverage as much of JAX-WS as possible to minimize the work I have to do.

Does anyone know where to start looking for how to do this? Is it even possible? My best guess at the moment is that I have to manually implement customer Endpoint or Provider.

Thanks!

1
Could you use JaxWsDynamicClientFactory?vikingsteve
You can use this tutorial. I'm linking it to the Stream usage to get web service results.Luiggi Mendoza
Axis2 provides a handler for a TCP endpoint. If you can get that working you can leverage the rest of the Axis stack rather than rolling your own solution.Perception

1 Answers

1
votes

You can process the raw input with the following steps. Just parse the incoming message as you would any XML stream

     try{ //throws a bunch of XML parsing related exceptions
      XMLInputFactory xFactory = XMLInputFactory.newFactory();
      XMLStreamReader xStream = xFactory.createXMLStreamReader(req.getInputStream());
      //Start skipping tags til you get to the message payload
      for(int nodeCount=0; nodeCount < 3; nodeCount++){
             xStream.nextTag(); //Jump <Envelope/>,<Body/>,<theMessageNode/>   
          }
      //You're now at the level of the actual class; Now unmarshal the payload  

      JAXBContext ctxt  = JAXBContext.newInstance(YourResponseClass.class);
      Unmarshaller um = ctxt.createUnmarshaller();
      JAXBElement<YourResponseClass.class> elem = um.unmarshal(xStream, YourResponseClass.class);             
      YourResponseClass theObj = elem.getValue();

     }
    catch(Exception ex) {

    }