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.callback;
19:
20: import java.net.URL;
21:
22: import javax.xml.namespace.QName;
23: import javax.xml.ws.Service;
24:
25: import org.apache.callback.CallbackPortType;
26: import org.apache.callback.ServerPortType;
27: import org.apache.cxf.jaxb.JAXBUtils;
28: import org.apache.cxf.ws.addressing.EndpointReferenceType;
29: import org.apache.cxf.wsdl.EndpointReferenceUtils;
30: import org.apache.cxf.wsdl.WSDLManager;
31: import org.apache.cxf.wsdl11.WSDLManagerImpl;
32:
33: @javax.jws.WebService(serviceName="SOAPService",portName="SOAPPort",targetNamespace="http://apache.org/callback",endpointInterface="org.apache.callback.ServerPortType",wsdlLocation="testutils/basic_callback_test.wsdl")
34: public class ServerImpl implements ServerPortType {
35:
36: //private static final Logger LOG =
37: // Logger.getLogger(ServerImpl.class.getPackage().getName());
38:
39: public String foo(String s) {
40: return s;
41: }
42:
43: public String registerCallback(EndpointReferenceType callback) {
44: try {
45: WSDLManager manager = new WSDLManagerImpl();
46:
47: QName interfaceName = EndpointReferenceUtils
48: .getInterfaceName(callback);
49: String wsdlLocation = EndpointReferenceUtils
50: .getWSDLLocation(callback);
51: QName serviceName = EndpointReferenceUtils
52: .getServiceName(callback);
53:
54: String portString = EndpointReferenceUtils
55: .getPortName(callback);
56:
57: QName portName = new QName(serviceName.getNamespaceURI(),
58: portString);
59:
60: StringBuffer seiName = new StringBuffer();
61: seiName.append(JAXBUtils
62: .namespaceURIToPackage(interfaceName
63: .getNamespaceURI()));
64: seiName.append(".");
65: seiName.append(JAXBUtils
66: .nameToIdentifier(interfaceName.getLocalPart(),
67: JAXBUtils.IdentifierType.INTERFACE));
68:
69: Class<?> sei = null;
70: try {
71: sei = Class.forName(seiName.toString(), true, manager
72: .getClass().getClassLoader());
73: } catch (ClassNotFoundException ex) {
74: ex.printStackTrace();
75: }
76:
77: URL wsdlURL = new URL(wsdlLocation);
78: Service service = Service.create(wsdlURL, serviceName);
79: CallbackPortType port = (CallbackPortType) service.getPort(
80: portName, sei);
81:
82: port.serverSayHi("Sean");
83:
84: } catch (Exception ex) {
85: ex.printStackTrace();
86: return null;
87: }
88:
89: return "registerCallback called";
90: }
91:
92: }
|