KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > webdav > client > webservice > UserDetailsService


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * 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 JavaDoc;
22 import java.net.URL JavaDoc;
23 import java.rmi.RemoteException JavaDoc;
24
25 import javax.xml.namespace.QName JavaDoc;
26 import javax.xml.rpc.ServiceException JavaDoc;
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 JavaDoc SIMULACRA_WEBSERVICE_NAMESPACE_URI =
40       "http://webservice.server.dav.openharmonise.org";
41     
42       /**
43        *
44        */

45       public UserDetailsService() {
46           super();
47       }
48
49     /**
50      * Makes SOAP request to execute a report query.
51      *
52      * @param endpoint (e.g. http://localhost:8080/webdav/services/ReportService)
53      * @param sUserName The user to find the path for
54      * @return Full path to virtual file for principal representing the user
55      * @throws java.rmi.RemoteException
56      * @throws ServiceException
57      */

58     public static String JavaDoc getUserPath(
59                                     URL JavaDoc endpoint,
60                                     String JavaDoc sUserName)
61       throws java.rmi.RemoteException JavaDoc, ServiceException JavaDoc {
62
63       Service service = new Service();
64       Call call = (Call) service.createCall();
65
66       call.setTargetEndpointAddress(endpoint);
67       call.setOperationName(
68         new QName JavaDoc(SIMULACRA_WEBSERVICE_NAMESPACE_URI, "getUserPath"));
69
70       call.addParameter(
71         "sUserName",
72         org.apache.axis.Constants.XSD_STRING,
73         javax.xml.rpc.ParameterMode.IN);
74
75       call.setReturnType(org.apache.axis.Constants.XSD_STRING);
76       call.setReturnClass(String JavaDoc.class);
77
78       String JavaDoc ret =
79         (String JavaDoc) call.invoke(
80           new Object JavaDoc[] {
81             sUserName});
82
83       return ret;
84     }
85     
86     public static void main(String JavaDoc[] args) {
87         URL JavaDoc endPointURL = null;
88         try {
89             
90             endPointURL = new URL JavaDoc("http://localhost:7000/webdav/services/DAVService");
91             
92             String JavaDoc sPath = UserDetailsService.getUserPath(endPointURL, "guest");
93         } catch (RemoteException JavaDoc e) {
94             e.printStackTrace();
95         } catch (ServiceException JavaDoc e) {
96             e.printStackTrace();
97         } catch (MalformedURLException JavaDoc e) {
98             e.printStackTrace();
99         }
100     }
101     
102   }
103
Popular Tags