KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > reports > ReportServiceClient


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.him.reports;
20
21 import java.net.*;
22
23 import org.apache.axis.client.Call;
24 import org.apache.axis.client.Service;
25
26 import javax.xml.namespace.QName JavaDoc;
27 import javax.xml.rpc.ServiceException JavaDoc;
28
29 /**
30  * Client interface for the Report service
31  *
32  * @author Fidel Viegas
33  * @version $Revision: 1.1 $
34  *
35  */

36 public class ReportServiceClient {
37   public static final String JavaDoc SIMULACRA_WEBSERVICE_NAMESPACE_URI =
38     "http://webservices.simulacra.thebritishmuseum.ac.uk";
39     
40     /**
41      *
42      */

43     public ReportServiceClient() {
44         super();
45     }
46
47   /**
48    * Makes SOAP request to execute a report query.
49    *
50    * @param endpoint (e.g. http://localhost:8080/webdav/services/ReportService)
51    * @param sPath The Webdav path to the query
52    * @param sUserName The user making the request
53    * @param sPassword The password of the user making the request
54    * @return
55    * @throws java.rmi.RemoteException
56    * @throws ServiceException
57    */

58   public static String JavaDoc executeQuery(
59   URL endpoint,
60   String JavaDoc sPath,
61   String JavaDoc sUserName,
62   String JavaDoc sPassword)
63     throws java.rmi.RemoteException JavaDoc, ServiceException JavaDoc {
64
65     Service service = new Service();
66     Call call = (Call) service.createCall();
67
68     call.setTargetEndpointAddress(endpoint);
69     call.setOperationName(
70       new QName JavaDoc(SIMULACRA_WEBSERVICE_NAMESPACE_URI, "executeQuery"));
71
72     call.addParameter(
73       "sPath",
74       org.apache.axis.Constants.XSD_STRING,
75       javax.xml.rpc.ParameterMode.IN);
76     call.addParameter(
77       "sUserName",
78       org.apache.axis.Constants.XSD_STRING,
79       javax.xml.rpc.ParameterMode.IN);
80
81     call.addParameter(
82       "sPassword",
83       org.apache.axis.Constants.XSD_STRING,
84       javax.xml.rpc.ParameterMode.IN);
85
86     call.setReturnType(org.apache.axis.Constants.XSD_STRING);
87     call.setReturnClass(String JavaDoc.class);
88
89     String JavaDoc ret =
90       (String JavaDoc) call.invoke(
91         new Object JavaDoc[] {
92           sPath,
93           sUserName,
94           sPassword});
95
96     return ret;
97   }
98 }
99
Popular Tags