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!
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) {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.