01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.systest.provider;
19:
20: import java.io.InputStream;
21:
22: import javax.xml.parsers.DocumentBuilder;
23: import javax.xml.parsers.DocumentBuilderFactory;
24: import javax.xml.transform.dom.DOMSource;
25: import javax.xml.ws.Provider;
26: import javax.xml.ws.Service;
27: import javax.xml.ws.ServiceMode;
28: import javax.xml.ws.WebServiceProvider;
29:
30: import org.w3c.dom.Document;
31:
32: import org.apache.cxf.helpers.DOMUtils;
33:
34: //The following wsdl file is used.
35: //wsdlLocation = "/trunk/testutils/src/main/resources/wsdl/hello_world_rpc_lit.wsdl"
36: @WebServiceProvider(portName="XMLProviderPort",serviceName="XMLService",targetNamespace="http://apache.org/hello_world_xml_http/wrapped",wsdlLocation="/wsdl/hello_world_xml_wrapped.wsdl")
37: @ServiceMode(value=Service.Mode.PAYLOAD)
38: @javax.xml.ws.BindingType(value="http://cxf.apache.org/bindings/xformat")
39: public class HWDOMSourcePayloadXMLBindingProvider implements
40: Provider<DOMSource> {
41:
42: public HWDOMSourcePayloadXMLBindingProvider() {
43: }
44:
45: public DOMSource invoke(DOMSource request) {
46: DocumentBuilderFactory factory;
47: DocumentBuilder builder;
48: Document document = null;
49: DOMSource response = null;
50:
51: try {
52: factory = DocumentBuilderFactory.newInstance();
53: factory.setNamespaceAware(true);
54: builder = factory.newDocumentBuilder();
55: InputStream greetMeResponse = getClass()
56: .getResourceAsStream(
57: "resources/XML_GreetMeDocLiteralResp.xml");
58:
59: document = builder.parse(greetMeResponse);
60: DOMUtils.writeXml(document, System.out);
61: response = new DOMSource(document.getDocumentElement());
62: } catch (Exception e) {
63: e.printStackTrace();
64: }
65: return response;
66: }
67: }
|