1 /****************************************************************
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * Based on EmbreoPublicRequest
19 * @author: Copyright (C) Tim Carver
21 ***************************************************************/
23 package ext.jemboss.soap;
28 import ext.jemboss.JembossParams;
31 import org.apache.axis.client.Call;
32 import org.apache.axis.client.Service;
33 import javax.xml.namespace.QName;
34 import org.apache.axis.encoding.XMLType;
38 * Make a axis call to a public server, using the default service
41 public class PublicRequest
44 private Hashtable proganswer;
48 * @param mysettings jemboss properties
49 * @param method method to call
50 * @throws JembossSoapException if call to web service fails
53 public PublicRequest(JembossParams mysettings, String method)
54 throws JembossSoapException
56 this(mysettings, mysettings.getPublicSoapService(), method);
61 * @param mysettings jemboss properties
62 * @param method method to call
63 * @param args arguments
64 * @throws JembossSoapException if call to web service fails
67 public PublicRequest(JembossParams mysettings, String method, Vector args)
68 throws JembossSoapException
70 this(mysettings, mysettings.getPublicSoapService(), method, args);
75 * @param mysettings jemboss properties
76 * @param service web service to call
77 * @param method method to call
78 * @throws JembossSoapException if call to web service fails
81 public PublicRequest(JembossParams mysettings, String service, String method)
82 throws JembossSoapException
84 this(mysettings, service, method, (Vector) null);
89 * @param mysettings jemboss properties
90 * @param service web service to call
91 * @param method method to call
92 * @param args arguments
93 * @throws JembossSoapException if call to web service fails
96 public PublicRequest(JembossParams mysettings, String service,
97 String method, Vector args)
98 throws JembossSoapException
103 String endpoint = mysettings.getPublicSoapURL();
104 org.apache.axis.client.Service serv =
105 new org.apache.axis.client.Service();
107 Call call = (Call) serv.createCall();
108 call.setTargetEndpointAddress( new java.net.URL(endpoint) );
109 call.setOperationName(new QName(service, method));
111 Object params[] = null;
114 params = new Object[args.size()];
115 Enumeration e = args.elements();
116 for(int i=0;i<args.size();i++)
118 Object obj = e.nextElement();
119 if(obj.getClass().equals(String.class))
121 params[i] = (String)obj;
122 call.addParameter("Args", XMLType.XSD_STRING,
123 javax.xml.rpc.ParameterMode.IN);
127 params[i] = (byte[])obj;
128 call.addParameter("Args", XMLType.XSD_BYTE,
129 javax.xml.rpc.ParameterMode.IN);
133 call.setReturnType(org.apache.axis.Constants.SOAP_VECTOR);
137 vans = (Vector)call.invoke( params );
139 vans = (Vector)call.invoke( new Object[] {});
141 proganswer = new Hashtable();
142 // assumes it's even sized
144 for(int j=0;j<n;j+=2)
146 String s = (String)vans.get(j);
147 proganswer.put(s,vans.get(j+1));
152 throw new JembossSoapException("Connection failed");
160 * Gets an element out of the Jemboss result hash
161 * @param val key to look up
162 * @return element, or an empty String if there isn't
163 * an element that matches the key
166 public String getVal(String val)
168 if (proganswer.containsKey(val))
169 return (String)proganswer.get(val);
177 * The hash returned by the Jemboss call.
181 public Hashtable getHash()