KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > rpcParams > RpcParamsBindingStub


1 /**
2  * RpcParamsBindingStub.java
3  *
4  * This file was auto-generated from WSDL
5  * by the Apache Axis WSDL2Java emitter.
6  */

7
8 package test.wsdl.rpcParams;
9
10 import java.util.Enumeration JavaDoc;
11 import java.util.Vector JavaDoc;
12 import java.util.List JavaDoc;
13 import java.util.ArrayList JavaDoc;
14 import java.rmi.RemoteException JavaDoc;
15 import javax.xml.namespace.QName JavaDoc;
16
17 import org.apache.axis.description.OperationDesc;
18 import org.apache.axis.description.ParameterDesc;
19 import org.apache.axis.client.Stub;
20
21 public class RpcParamsBindingStub extends Stub implements RpcParamsTest {
22     private Vector JavaDoc cachedSerClasses = new Vector JavaDoc();
23     private Vector JavaDoc cachedSerQNames = new Vector JavaDoc();
24     private Vector JavaDoc cachedSerFactories = new Vector JavaDoc();
25     private Vector JavaDoc cachedDeserFactories = new Vector JavaDoc();
26
27     public RpcParamsBindingStub() throws org.apache.axis.AxisFault {
28          this(null);
29     }
30
31     public RpcParamsBindingStub(java.net.URL JavaDoc endpointURL, javax.xml.rpc.Service JavaDoc service) throws org.apache.axis.AxisFault {
32          this(service);
33          super.cachedEndpoint = endpointURL;
34     }
35
36     public RpcParamsBindingStub(javax.xml.rpc.Service JavaDoc service) throws org.apache.axis.AxisFault {
37         if (service == null) {
38             super.service = new org.apache.axis.client.Service();
39         } else {
40             super.service = service;
41         }
42             Class JavaDoc cls;
43             QName JavaDoc qName;
44             Class JavaDoc beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class;
45             Class JavaDoc beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class;
46             qName = new QName JavaDoc("urn:rpcParams.wsdl.test", "EchoStruct");
47             cachedSerQNames.add(qName);
48             cls = EchoStruct.class;
49             cachedSerClasses.add(cls);
50             cachedSerFactories.add(beansf);
51             cachedDeserFactories.add(beandf);
52
53     }
54
55     private org.apache.axis.client.Call createCall() throws RemoteException JavaDoc {
56         try {
57             org.apache.axis.client.Call _call =
58                     (org.apache.axis.client.Call) super.service.createCall();
59             if (super.maintainSessionSet) {
60                 _call.setMaintainSession(super.maintainSession);
61             }
62             if (super.cachedUsername != null) {
63                 _call.setUsername(super.cachedUsername);
64             }
65             if (super.cachedPassword != null) {
66                 _call.setPassword(super.cachedPassword);
67             }
68             if (super.cachedEndpoint != null) {
69                 _call.setTargetEndpointAddress(super.cachedEndpoint);
70             }
71             if (super.cachedTimeout != null) {
72                 _call.setTimeout(super.cachedTimeout);
73             }
74             if (super.cachedPortName != null) {
75                 _call.setPortName(super.cachedPortName);
76             }
77             Enumeration JavaDoc keys = super.cachedProperties.keys();
78             while (keys.hasMoreElements()) {
79                 String JavaDoc key = (String JavaDoc) keys.nextElement();
80                 _call.setProperty(key, super.cachedProperties.get(key));
81             }
82             // All the type mapping information is registered
83
// when the first call is made.
84
// The type mapping information is actually registered in
85
// the TypeMappingRegistry of the service, which
86
// is the reason why registration is only needed for the first call.
87
synchronized (this) {
88                 if (firstCall()) {
89                     // must set encoding style before registering serializers
90
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
91                     _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);
92                     for (int i = 0; i < cachedSerFactories.size(); ++i) {
93                         Class JavaDoc cls = (Class JavaDoc) cachedSerClasses.get(i);
94                         QName JavaDoc qName =
95                                 (QName JavaDoc) cachedSerQNames.get(i);
96                         Class JavaDoc sf = (Class JavaDoc)
97                                  cachedSerFactories.get(i);
98                         Class JavaDoc df = (Class JavaDoc)
99                                  cachedDeserFactories.get(i);
100                         _call.registerTypeMapping(cls, qName, sf, df, false);
101                     }
102                 }
103             }
104             return _call;
105         }
106         catch (Throwable JavaDoc t) {
107             throw new org.apache.axis.AxisFault("Failure trying to get the Call object", t);
108         }
109     }
110
111     /**
112      * Send the given request to the server, ommitting any null parameters.
113      */

114     public EchoStruct echo(String JavaDoc first, String JavaDoc second) throws RemoteException JavaDoc {
115         EchoStruct result;
116         if (super.cachedEndpoint == null) {
117             throw new org.apache.axis.NoEndPointException();
118         }
119
120         // create the operation... omit any null parameters
121
OperationDesc operation = new OperationDesc();
122         operation.setName("echo");
123         if (first != null)
124             operation.addParameter(new QName JavaDoc("", "first"), new QName JavaDoc("http://www.w3.org/2001/XMLSchema", "string"), String JavaDoc.class, ParameterDesc.IN, false, false);
125         if (second != null)
126             operation.addParameter(new QName JavaDoc("", "second"), new QName JavaDoc("http://www.w3.org/2001/XMLSchema", "string"), String JavaDoc.class, ParameterDesc.IN, false, false);
127         operation.setReturnType(new QName JavaDoc("urn:rpcParams.wsdl.test", "EchoStruct"));
128         operation.setReturnClass(EchoStruct.class);
129         operation.setReturnQName(new QName JavaDoc("", "echoReturn"));
130         operation.setStyle(org.apache.axis.constants.Style.RPC);
131         operation.setUse(org.apache.axis.constants.Use.ENCODED);
132
133         org.apache.axis.client.Call _call = createCall();
134         _call.setOperation(operation);
135         _call.setUseSOAPAction(true);
136         _call.setSOAPActionURI("");
137         _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
138         _call.setOperationName(new QName JavaDoc("urn:rpcParams.wsdl.test", "echo"));
139
140         setRequestHeaders(_call);
141         setAttachments(_call);
142
143         // add the params we're actually going to send, again ommitting nulls
144
List JavaDoc params = new ArrayList JavaDoc(2);
145         if (first != null)
146             params.add(first);
147         if (second != null)
148             params.add(second);
149
150         Object JavaDoc _resp = _call.invoke(params.toArray());
151
152         if (_resp instanceof RemoteException JavaDoc) {
153             throw (RemoteException JavaDoc)_resp;
154         }
155         else {
156             getResponseHeaders(_call);
157             extractAttachments(_call);
158             try {
159                 result = (EchoStruct) _resp;
160             } catch (Exception JavaDoc _exception) {
161                 result = (EchoStruct) org.apache.axis.utils.JavaUtils.convert(_resp, EchoStruct.class);
162             }
163         }
164         return result;
165     }
166
167     /**
168      * The same as echo, but reverse the order of parameters we send.
169      */

170     public EchoStruct echoReverse(String JavaDoc first, String JavaDoc second) throws RemoteException JavaDoc {
171         EchoStruct result;
172         if (super.cachedEndpoint == null) {
173             throw new org.apache.axis.NoEndPointException();
174         }
175
176         // create the operation... omit any null parameters
177
OperationDesc operation = new OperationDesc();
178         operation.setName("echo");
179         if (second != null)
180             operation.addParameter(new QName JavaDoc("", "second"), new QName JavaDoc("http://www.w3.org/2001/XMLSchema", "string"), String JavaDoc.class, ParameterDesc.IN, false, false);
181         if (first != null)
182             operation.addParameter(new QName JavaDoc("", "first"), new QName JavaDoc("http://www.w3.org/2001/XMLSchema", "string"), String JavaDoc.class, ParameterDesc.IN, false, false);
183         operation.setReturnType(new QName JavaDoc("urn:rpcParams.wsdl.test", "EchoStruct"));
184         operation.setReturnClass(EchoStruct.class);
185         operation.setReturnQName(new QName JavaDoc("", "echoReturn"));
186         operation.setStyle(org.apache.axis.constants.Style.RPC);
187         operation.setUse(org.apache.axis.constants.Use.ENCODED);
188
189         org.apache.axis.client.Call _call = createCall();
190         _call.setOperation(operation);
191         _call.setUseSOAPAction(true);
192         _call.setSOAPActionURI("");
193         _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
194         _call.setOperationName(new QName JavaDoc("urn:rpcParams.wsdl.test", "echo"));
195
196         setRequestHeaders(_call);
197         setAttachments(_call);
198
199         // add the params we're actually going to send, again ommitting nulls
200
List JavaDoc params = new ArrayList JavaDoc(2);
201         if (second != null)
202             params.add(second);
203         if (first != null)
204             params.add(first);
205
206         Object JavaDoc _resp = _call.invoke(params.toArray());
207
208         if (_resp instanceof RemoteException JavaDoc) {
209             throw (RemoteException JavaDoc)_resp;
210         }
211         else {
212             getResponseHeaders(_call);
213             extractAttachments(_call);
214             try {
215                 result = (EchoStruct) _resp;
216             } catch (Exception JavaDoc _exception) {
217                 result = (EchoStruct) org.apache.axis.utils.JavaUtils.convert(_resp, EchoStruct.class);
218             }
219         }
220         return result;
221     }
222
223 }
224
Popular Tags