01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.webdav.client.webservice;
20:
21: import java.net.MalformedURLException;
22: import java.net.URL;
23: import java.rmi.RemoteException;
24:
25: import javax.xml.namespace.QName;
26: import javax.xml.rpc.ServiceException;
27:
28: import org.apache.axis.client.Call;
29: import org.apache.axis.client.Service;
30:
31: /**
32: * Web Service which provides functionality that WebDAV does not.
33: *
34: * @author Matthew Large
35: * @version $Revision: 1.3 $
36: *
37: */
38: public class UserDetailsService {
39: public static final String SIMULACRA_WEBSERVICE_NAMESPACE_URI = "http://webservice.server.dav.openharmonise.org";
40:
41: /**
42: *
43: */
44: public UserDetailsService() {
45: super ();
46: }
47:
48: /**
49: * Makes SOAP request to execute a report query.
50: *
51: * @param endpoint (e.g. http://localhost:8080/webdav/services/ReportService)
52: * @param sUserName The user to find the path for
53: * @return Full path to virtual file for principal representing the user
54: * @throws java.rmi.RemoteException
55: * @throws ServiceException
56: */
57: public static String getUserPath(URL endpoint, String sUserName)
58: throws java.rmi.RemoteException, ServiceException {
59:
60: Service service = new Service();
61: Call call = (Call) service.createCall();
62:
63: call.setTargetEndpointAddress(endpoint);
64: call.setOperationName(new QName(
65: SIMULACRA_WEBSERVICE_NAMESPACE_URI, "getUserPath"));
66:
67: call.addParameter("sUserName",
68: org.apache.axis.Constants.XSD_STRING,
69: javax.xml.rpc.ParameterMode.IN);
70:
71: call.setReturnType(org.apache.axis.Constants.XSD_STRING);
72: call.setReturnClass(String.class);
73:
74: String ret = (String) call.invoke(new Object[] { sUserName });
75:
76: return ret;
77: }
78:
79: public static void main(String[] args) {
80: URL endPointURL = null;
81: try {
82:
83: endPointURL = new URL(
84: "http://localhost:7000/webdav/services/DAVService");
85:
86: String sPath = UserDetailsService.getUserPath(endPointURL,
87: "guest");
88: } catch (RemoteException e) {
89: e.printStackTrace();
90: } catch (ServiceException e) {
91: e.printStackTrace();
92: } catch (MalformedURLException e) {
93: e.printStackTrace();
94: }
95: }
96:
97: }
|