01: package demo.hwDispatch.server;
02:
03: import java.io.InputStream;
04:
05: import javax.xml.soap.MessageFactory;
06: import javax.xml.soap.SOAPMessage;
07: import javax.xml.transform.dom.DOMSource;
08: import javax.xml.ws.Provider;
09: import javax.xml.ws.Service;
10: import javax.xml.ws.ServiceMode;
11: import javax.xml.ws.WebServiceProvider;
12:
13: @WebServiceProvider(portName="SoapPort2",serviceName="SOAPService2",targetNamespace="http://objectweb.org/hello_world_soap_http",wsdlLocation="file:./wsdl/hello_world.wsdl")
14: @ServiceMode(value=Service.Mode.MESSAGE)
15: public class GreeterDOMSourceMessageProvider implements
16: Provider<DOMSource> {
17:
18: public GreeterDOMSourceMessageProvider() {
19: //Complete
20: }
21:
22: public DOMSource invoke(DOMSource request) {
23: DOMSource response = new DOMSource();
24: try {
25: MessageFactory factory = MessageFactory.newInstance();
26: SOAPMessage soapReq = factory.createMessage();
27: soapReq.getSOAPPart().setContent(request);
28:
29: System.out
30: .println("Incoming Client Request as a DOMSource data in MESSAGE Mode");
31: soapReq.writeTo(System.out);
32: System.out.println("\n");
33:
34: InputStream is = getClass().getResourceAsStream(
35: "GreetMeDocLiteralResp2.xml");
36: SOAPMessage greetMeResponse = factory.createMessage(null,
37: is);
38: is.close();
39:
40: response.setNode(greetMeResponse.getSOAPPart());
41: } catch (Exception ex) {
42: ex.printStackTrace();
43: }
44: return response;
45: }
46: }
|