KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > soap > jaxrpc > CallImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.soap.jaxrpc;
30
31 import com.caucho.log.Log;
32 import com.caucho.soap.wsdl.WSDLOperation;
33 import com.caucho.soap.wsdl.WSDLPort;
34 import com.caucho.util.L10N;
35 import com.caucho.xml.XMLWriter;
36
37 import org.xml.sax.SAXException JavaDoc;
38
39 import javax.xml.namespace.QName JavaDoc;
40 import javax.xml.rpc.Call JavaDoc;
41 import javax.xml.rpc.JAXRPCException JavaDoc;
42 import javax.xml.rpc.ParameterMode JavaDoc;
43 import java.io.IOException JavaDoc;
44 import java.util.Iterator JavaDoc;
45 import java.util.List JavaDoc;
46 import java.util.Map JavaDoc;
47 import java.util.logging.Logger JavaDoc;
48
49 /**
50  * Service
51  */

52 public class CallImpl implements Call JavaDoc {
53   private final static L10N L = new L10N(CallImpl.class);
54   private final static Logger JavaDoc log = Log.open(CallImpl.class);
55
56   public final static String JavaDoc XMLNS =
57     "http://www.w3.org/2000/xmlns/";
58
59   public final static String JavaDoc SOAP_ENVELOPE =
60     "http://www.w3.org/2003/05/soap-envelope";
61   public final static String JavaDoc SOAP_ENCODING =
62     "http://schemas.xmlsoap.org/soap/encoding/";
63
64   private WSDLPort _port;
65   private WSDLOperation _op;
66
67   CallImpl(WSDLPort port)
68   {
69     _port = port;
70   }
71
72   CallImpl(WSDLPort port, WSDLOperation op)
73   {
74     _port = port;
75     _op = op;
76   }
77
78
79   /**
80    * Returns true if the parameter and return type should be invoked.
81    */

82   public boolean isParameterAndReturnSpecRequired(QName JavaDoc operationName)
83   {
84     throw new UnsupportedOperationException JavaDoc();
85   }
86
87   /**
88    * Adds a parameter type and mode for the operation.
89    */

90   public void addParameter(String JavaDoc paramName,
91                            QName JavaDoc xmlType,
92                            ParameterMode JavaDoc parameterMode)
93     throws JAXRPCException JavaDoc
94   {
95     throw new UnsupportedOperationException JavaDoc();
96   }
97
98   /**
99    * Adds a parameter type and mode for the operation.
100    */

101   public void addParameter(String JavaDoc paramName,
102                            QName JavaDoc xmlType,
103                            Class JavaDoc javaType,
104                            ParameterMode JavaDoc parameterMode)
105     throws JAXRPCException JavaDoc
106   {
107     throw new UnsupportedOperationException JavaDoc();
108   }
109
110   /**
111    * Adds Returns the XML type of a parameter.
112    */

113   public QName JavaDoc getParameterTypeByName(String JavaDoc paramName)
114   {
115     throw new UnsupportedOperationException JavaDoc();
116   }
117
118   /**
119    * Sets the return type.
120    */

121   public void setReturnType(QName JavaDoc xmlType)
122     throws JAXRPCException JavaDoc
123   {
124     throw new UnsupportedOperationException JavaDoc();
125   }
126
127   /**
128    * Sets the return type.
129    */

130   public void setReturnType(QName JavaDoc xmlType,
131                             Class JavaDoc javaType)
132     throws JAXRPCException JavaDoc
133   {
134     throw new UnsupportedOperationException JavaDoc();
135   }
136
137   /**
138    * Returns the return type.
139    */

140   public QName JavaDoc getReturnType()
141   {
142     throw new UnsupportedOperationException JavaDoc();
143   }
144
145   /**
146    * Removes the parameters.
147    */

148   public void removeAllParameters()
149     throws JAXRPCException JavaDoc
150   {
151     throw new UnsupportedOperationException JavaDoc();
152   }
153
154   /**
155    * Returns the operation name.
156    */

157   public QName JavaDoc getOperationName()
158   {
159     throw new UnsupportedOperationException JavaDoc();
160   }
161
162   /**
163    * Returns the port type.
164    */

165   public QName JavaDoc getPortTypeName()
166   {
167     throw new UnsupportedOperationException JavaDoc();
168   }
169
170   /**
171    * Sets the port type.
172    */

173   public void setPortTypeName(QName JavaDoc portType)
174   {
175     throw new UnsupportedOperationException JavaDoc();
176   }
177
178   /**
179    * Sets the target endpoing.
180    */

181   public void setTargetEndpointAddress(String JavaDoc address)
182   {
183     throw new UnsupportedOperationException JavaDoc();
184   }
185
186   /**
187    * Gets the target endpoint.
188    */

189   public String JavaDoc getTargetEndpointAddress()
190   {
191     throw new UnsupportedOperationException JavaDoc();
192   }
193
194   /**
195    * Sets a property.
196    */

197   public void setProperty(String JavaDoc name, Object JavaDoc value)
198     throws JAXRPCException JavaDoc
199   {
200     throw new UnsupportedOperationException JavaDoc();
201   }
202
203   /**
204    * Gets a property.
205    */

206   public Object JavaDoc getProperty(String JavaDoc name)
207     throws JAXRPCException JavaDoc
208   {
209     throw new UnsupportedOperationException JavaDoc();
210   }
211
212   /**
213    * Removes a property.
214    */

215   public void removeProperty(String JavaDoc name)
216     throws JAXRPCException JavaDoc
217   {
218     throw new UnsupportedOperationException JavaDoc();
219   }
220
221   /**
222    * Iterates over the property names.
223    */

224   public Iterator JavaDoc getPropertyNames()
225   {
226     throw new UnsupportedOperationException JavaDoc();
227   }
228
229   /**
230    * Invokes the operation
231    */

232   public Object JavaDoc invoke(Object JavaDoc []params)
233     throws java.rmi.RemoteException JavaDoc
234   {
235     throw new UnsupportedOperationException JavaDoc();
236   }
237
238   /**
239    * Invokes the operation
240    */

241   public Object JavaDoc invoke(QName JavaDoc operationName, Object JavaDoc []params)
242     throws java.rmi.RemoteException JavaDoc
243   {
244     throw new UnsupportedOperationException JavaDoc();
245   }
246
247   /**
248    * Invokes the operation in one-way mode.
249    */

250   public void invokeOneWay(Object JavaDoc []params)
251   {
252     writeCall(params);
253   }
254
255   /**
256    * Creates the send message.
257    */

258
259   /**
260    * Returns the Map of the output parameters.
261    */

262   public Map JavaDoc getOutputParams()
263   {
264     throw new UnsupportedOperationException JavaDoc();
265   }
266
267   /**
268    * Returns a list of theoutput parameters.
269    */

270   public List JavaDoc getOutputValues()
271   {
272     throw new UnsupportedOperationException JavaDoc();
273   }
274
275   /**
276    * Writes the call.
277    */

278   private void writeCall(Object JavaDoc []params)
279   {
280     /*
281     if (_op.getInput() == null)
282       throw new IllegalStateException(L.l("writing call with no input"));
283
284     OutputStream os = null;
285
286     try {
287       os = com.caucho.vfs.Vfs.lookup("file:/tmp/caucho/qa/soap.xml").openWrite();
288
289       XMLWriter writer = new XmlPrinter(os);
290
291       writeCall(writer, params);
292     } catch (Exception e) {
293       throw new RuntimeException(e);
294     } finally {
295       try {
296         if (os != null) os.close();
297       } catch (Throwable e) {
298       }
299     }
300     */

301   }
302
303   /**
304    * Writes the call.
305    */

306   private void writeCall(XMLWriter writer, Object JavaDoc []params)
307     throws IOException JavaDoc, SAXException JavaDoc
308   {
309     writer.startDocument();
310     /*
311
312     WSDLOperation op = _op;
313     QName opName = op.getName();
314
315     writer.startPrefixMapping("env", SOAP_ENVELOPE);
316     writer.startPrefixMapping("m", opName.getNamespaceURI());
317
318     writer.startElement(SOAP_ENVELOPE, "Envelope", "env:Envelope");
319     writer.attribute(XMLNS, "env", "xmlns:env", SOAP_ENVELOPE);
320     writer.attribute(XMLNS, "m", "xmlns:m", opName.getNamespaceURI());
321     writer.attribute(SOAP_ENVELOPE, "encodingStyle", "env:encodingStyle",
322                      SOAP_ENCODING);
323
324     writer.startElement(SOAP_ENVELOPE, "Header", "env:Header");
325     */

326     /*
327     writer.attribute(SOAP_ENVELOPE, "encodingStyle", "env:encodingStyle",
328                      "ook");
329     */

330
331     /*
332     writer.endElement(SOAP_ENVELOPE, "Header", "env:Header");
333
334     writer.startElement(SOAP_ENVELOPE, "Body", "env:Body");
335
336     writer.startElement(opName.getNamespaceURI(), opName.getLocalPart(),
337                         "m:" + opName.getLocalPart());
338
339     WSDLMessage input = op.getInput();
340
341     ArrayList<WSDLMessage.Part> wsdlParams = input.getParts();
342
343     writeParams(writer, wsdlParams, params);
344
345     writer.endElement(opName.getNamespaceURI(), opName.getLocalPart(),
346                       "m:" + opName.getLocalPart());
347
348     writer.endElement(SOAP_ENVELOPE, "Body", "env:Body");
349
350     writer.endElement(SOAP_ENVELOPE, "env", "Envelope");
351     writer.endPrefixMapping("env");
352     */

353
354     writer.endDocument();
355   }
356
357   /*
358    * Starts writing an element.
359   private void writeParams(XMLWriter writer,
360                            ArrayList<WSDLMessage.Part> msgParts,
361                            Object []params)
362     throws IOException, SAXException
363   {
364     for (int i = 0; i < params.length; i++) {
365       Object param = params[i];
366       WSDLMessage.Part part = null;
367       String name = null;
368
369       if (i < msgParts.size()) {
370         part = msgParts.get(i);
371         name = part.getName();
372       }
373       else
374         name = "a" + i;
375
376       writer.startElement("", name, name);
377       writer.text(String.valueOf(param));
378       writer.endElement("", name, name);
379     }
380   }
381    */

382
383   /**
384    * Starts writing an element.
385    */

386   private void startElement(XMLWriter writer, QName JavaDoc name)
387     throws IOException JavaDoc, SAXException JavaDoc
388   {
389     if (name.getPrefix().equals("")) {
390       writer.startElement(name.getNamespaceURI(),
391                           name.getLocalPart(),
392                           name.getLocalPart());
393     }
394     else {
395       writer.startElement(name.getNamespaceURI(),
396                           name.getLocalPart(),
397                           name.getPrefix() + ":" + name.getLocalPart());
398     }
399   }
400
401   /**
402    * Ends writing an element.
403    */

404   private void endElement(XMLWriter writer, QName JavaDoc name)
405     throws IOException JavaDoc, SAXException JavaDoc
406   {
407     if (name.getPrefix().equals("")) {
408       writer.endElement(name.getNamespaceURI(),
409                           name.getLocalPart(),
410                           name.getLocalPart());
411     }
412     else {
413       writer.endElement(name.getNamespaceURI(),
414                         name.getLocalPart(),
415                         name.getPrefix() + ":" + name.getLocalPart());
416     }
417   }
418
419   /**
420    * Returns the id.
421    */

422   public String JavaDoc toString()
423   {
424     if (_op != null)
425       return "CallImpl[" + _port.getName() + ",op=" + _op.getName() + "]";
426     else
427       return "CallImpl[" + _port.getName() + "]";
428   }
429 }
430
431
432
Popular Tags