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.Transformer;
08: import javax.xml.transform.TransformerFactory;
09: import javax.xml.transform.dom.DOMSource;
10: import javax.xml.transform.stream.StreamResult;
11: import javax.xml.ws.Provider;
12: import javax.xml.ws.WebServiceProvider;
13:
14: @WebServiceProvider(portName="SoapPort3",serviceName="SOAPService3",targetNamespace="http://objectweb.org/hello_world_soap_http",wsdlLocation="file:./wsdl/hello_world.wsdl")
15: public class GreeterDOMSourcePayloadProvider implements
16: Provider<DOMSource> {
17:
18: public GreeterDOMSourcePayloadProvider() {
19: //Complete
20: }
21:
22: public DOMSource invoke(DOMSource request) {
23: DOMSource response = new DOMSource();
24: try {
25: System.out
26: .println("Incoming Client Request as a DOMSource data in PAYLOAD Mode");
27: Transformer transformer = TransformerFactory.newInstance()
28: .newTransformer();
29: StreamResult result = new StreamResult(System.out);
30: transformer.transform(request, result);
31: System.out.println("\n");
32:
33: InputStream is = getClass().getResourceAsStream(
34: "GreetMeDocLiteralResp3.xml");
35:
36: SOAPMessage greetMeResponse = MessageFactory.newInstance()
37: .createMessage(null, is);
38: is.close();
39: response.setNode(greetMeResponse.getSOAPBody()
40: .extractContentAsDocument());
41: } catch (Exception ex) {
42: ex.printStackTrace();
43: }
44: return response;
45: }
46: }
|