KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > wsif > providers > soap > apachesoap > WSIFPort_ApacheSOAP


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "WSIF" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, 2002, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.apache.wsif.providers.soap.apachesoap;
59
60 import java.io.IOException JavaDoc;
61 import java.io.ObjectInputStream JavaDoc;
62 import java.io.ObjectOutputStream JavaDoc;
63 import java.net.MalformedURLException JavaDoc;
64 import java.net.URL JavaDoc;
65 import java.util.HashMap JavaDoc;
66 import java.util.Iterator JavaDoc;
67 import java.util.List JavaDoc;
68 import java.util.Map JavaDoc;
69
70 import javax.wsdl.Binding;
71 import javax.wsdl.BindingInput;
72 import javax.wsdl.BindingOperation;
73 import javax.wsdl.BindingOutput;
74 import javax.wsdl.Definition;
75 import javax.wsdl.Port;
76 import javax.wsdl.Service;
77 import javax.wsdl.extensions.soap.SOAPAddress;
78 import javax.wsdl.extensions.soap.SOAPBinding;
79 import javax.wsdl.extensions.soap.SOAPBody;
80 import javax.wsdl.extensions.soap.SOAPHeader;
81 import javax.wsdl.extensions.soap.SOAPOperation;
82
83 import org.apache.soap.Constants;
84 import org.apache.soap.encoding.SOAPMappingRegistry;
85 import org.apache.soap.encoding.soapenc.Base64Serializer;
86 import org.apache.soap.encoding.soapenc.BeanSerializer;
87 import org.apache.soap.encoding.soapenc.DateSerializer;
88 import org.apache.soap.rpc.Call;
89 import org.apache.soap.transport.SOAPTransport;
90 import org.apache.soap.transport.http.SOAPHTTPConnection;
91 import org.apache.soap.util.xml.Deserializer;
92 import org.apache.soap.util.xml.Serializer;
93 import org.apache.wsif.WSIFException;
94 import org.apache.wsif.WSIFOperation;
95 import org.apache.wsif.base.WSIFDefaultPort;
96 import org.apache.wsif.logging.Trc;
97 import org.apache.wsif.providers.WSIFDynamicTypeMap;
98 import org.apache.wsif.providers.WSIFDynamicTypeMapping;
99 import org.apache.wsif.util.WSIFUtils;
100 import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
101 import org.apache.wsif.wsdl.extensions.jms.JMSProperty;
102 import org.apache.wsif.wsdl.extensions.jms.JMSPropertyValue;
103
104 /**
105  * This is Apache SOAP dynamic WSIF port that is driven by WSDL.
106  *
107  * @author Alekander Slominski
108  * @author Owen Burroughs <owenb@apache.org>
109  * @author Ant Elder <antelder@apache.org>
110  * @author Jeremy Hughes <hughesj@apache.org>
111  * @author Mark Whitlock <whitlock@apache.org>
112  */

113 public class WSIFPort_ApacheSOAP extends WSIFDefaultPort {
114
115     private static final long serialVersionUID = 1L;
116
117     transient protected Map JavaDoc operationInstances = new HashMap JavaDoc();
118     protected Port port;
119     protected Definition definition;
120     transient protected Call call;
121     transient protected SOAPTransport st;
122     protected URL JavaDoc url;
123     protected String JavaDoc style = "document";
124     protected String JavaDoc partSerializerName = null;
125
126     private WSIFDynamicTypeMap wsifTypeMap = null;
127     private HashMap JavaDoc localTypeMap;
128     private List JavaDoc jmsAddressPropVals = null;
129
130     private static final String JavaDoc LITERAL_ENCODING = "literal";
131     
132     /**
133      * Create dynamic port instance from WDL model defintion and port.
134      * <p><b>NOTE:</b> this constructor is doing full initialization
135      * therefore after dynamic port is created overhead of executing
136      * operation should be as small as possible for dynamic case...
137      */

138     public WSIFPort_ApacheSOAP(
139         Definition def,
140         Service service,
141         Port port,
142         WSIFDynamicTypeMap typeMap,
143         String JavaDoc partSerName)
144         throws WSIFException {
145         Trc.entry(this, def, service, port, typeMap, partSerName);
146
147         setPartSerializerName(partSerName);
148         setDefinition(def);
149         setPort(port);
150         wsifTypeMap = typeMap;
151
152         JMSAddress ja =
153             (JMSAddress) getExtElem(port,
154                 JMSAddress.class,
155                 port.getExtensibilityElements());
156         SOAPAddress sa =
157             (SOAPAddress) getExtElem(port,
158                 SOAPAddress.class,
159                 port.getExtensibilityElements());
160
161         if (sa != null && ja != null)
162             throw new WSIFException(
163                 "Both soap:address and jms:address cannot be specified for port "
164                     + port.getName());
165
166         if (sa == null && ja == null)
167             throw new WSIFException(
168                 "Either soap:address or jms:address must be specified for port "
169                     + port.getName());
170
171         if (ja != null) {
172             // Port jms:address binding element
173
jmsAddressPropVals = ja.getJMSPropertyValues();
174             st = new SOAPJMSConnection(ja, port.getName());
175         } else {
176             // Port soap:address bindng element
177
st = new SOAPHTTPConnection();
178             // call.getSOAPTransport() is null...
179

180             String JavaDoc s = sa.getLocationURI();
181             try {
182                 url = new URL JavaDoc(s);
183             } catch (MalformedURLException JavaDoc meu) {
184                 Trc.exception(meu);
185                 throw new WSIFException(
186                     "could not set SOAP address to " + s,
187                     meu);
188             }
189             if (url == null) {
190                 throw new WSIFException(
191                     "soap:address with location URI is required for " + port.getName());
192             }
193         }
194
195         // check soap:binding element
196
Binding binding = port.getBinding();
197         SOAPBinding soapBinding =
198             (SOAPBinding) getExtElem(binding,
199                 SOAPBinding.class,
200                 binding.getExtensibilityElements());
201         if (soapBinding != null) {
202             style = soapBinding.getStyle();
203             if (style == null)
204                 style = "document"; //it is default style value as of WSDL 1.1
205

206             String JavaDoc transport = soapBinding.getTransportURI();
207             if ((ja != null
208                 && !"http://schemas.xmlsoap.org/soap/jms".equals(transport))
209                 || (sa != null
210                     && !"http://schemas.xmlsoap.org/soap/http".equals(
211                         transport))) {
212                 throw new WSIFException(
213                     "unsupported transport "
214                         + transport
215                         + " for "
216                         + soapBinding);
217             }
218         }
219         
220         if (Trc.ON)
221             Trc.exit(deep());
222     }
223
224     public static SOAPMappingRegistry createSOAPMappingRegistry(Call call) {
225         Trc.entry(null,call);
226         SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
227
228         // Add mapping registry entry for dateTime
229
DateSerializer dateSer = new DateSerializer();
230         // 1999 deserializer
231
smr.mapTypes(
232             Constants.NS_URI_SOAP_ENC,
233             new org.apache.soap.util.xml.QName(
234                 Constants.NS_URI_1999_SCHEMA_XSD,
235                 "dateTime"),
236             java.util.Date JavaDoc.class,
237             null,
238             dateSer);
239         // 2000 deserializer
240
smr.mapTypes(
241             Constants.NS_URI_SOAP_ENC,
242             new org.apache.soap.util.xml.QName(
243                 Constants.NS_URI_2000_SCHEMA_XSD,
244                 "dateTime"),
245             java.util.Date JavaDoc.class,
246             null,
247             dateSer);
248         // 2001 deserializer
249
smr.mapTypes(
250             Constants.NS_URI_SOAP_ENC,
251             new org.apache.soap.util.xml.QName(
252                 Constants.NS_URI_2001_SCHEMA_XSD,
253                 "dateTime"),
254             java.util.Date JavaDoc.class,
255             null,
256             dateSer);
257         // Use current serializer for serialization
258
smr.mapTypes(
259             Constants.NS_URI_SOAP_ENC,
260             new org.apache.soap.util.xml.QName(
261                 Constants.NS_URI_CURRENT_SCHEMA_XSD,
262                 "dateTime"),
263             java.util.Date JavaDoc.class,
264             dateSer,
265             null);
266
267         // Add mapping registry entry for base64
268
Base64Serializer base64Ser = new Base64Serializer();
269         // 1999 deserializer
270
smr.mapTypes(
271             Constants.NS_URI_SOAP_ENC,
272             new org.apache.soap.util.xml.QName(
273                 Constants.NS_URI_1999_SCHEMA_XSD,
274                 "base64Binary"),
275             byte[].class,
276             null,
277             base64Ser);
278         // 2000 deserializer
279
smr.mapTypes(
280             Constants.NS_URI_SOAP_ENC,
281             new org.apache.soap.util.xml.QName(
282                 Constants.NS_URI_2000_SCHEMA_XSD,
283                 "base64Binary"),
284             byte[].class,
285             null,
286             base64Ser);
287         // 2001 deserializer
288
smr.mapTypes(
289             Constants.NS_URI_SOAP_ENC,
290             new org.apache.soap.util.xml.QName(
291                 Constants.NS_URI_2001_SCHEMA_XSD,
292                 "base64Binary"),
293             byte[].class,
294             null,
295             base64Ser);
296         // Use current serializer for serialization
297
smr.mapTypes(
298             Constants.NS_URI_SOAP_ENC,
299             new org.apache.soap.util.xml.QName(
300                 Constants.NS_URI_CURRENT_SCHEMA_XSD,
301                 "base64Binary"),
302             byte[].class,
303             base64Ser,
304             null);
305
306         Trc.exit(smr);
307         return smr;
308     }
309
310     public Call getCall() {
311         Trc.entry(this);
312         if ( call == null ) {
313            call = new Call();
314            call.setSOAPMappingRegistry(
315                new WSIFSOAPMappingRegistry(createSOAPMappingRegistry( call )));
316            prepareTypeMappings();
317         }
318         Trc.exit(call);
319         return call;
320     }
321
322     public SOAPMappingRegistry getSOAPMappingRegistry() {
323         Trc.entry(this);
324         SOAPMappingRegistry smr = getCall().getSOAPMappingRegistry();
325         Trc.exit(smr);
326         return smr;
327     }
328
329     protected HashMap JavaDoc getLocalTypeMap() {
330         if (localTypeMap == null ) {
331             localTypeMap = new HashMap JavaDoc();
332             // need to ensure prepareTypeMappings is run
333
getCall();
334         }
335         return localTypeMap;
336     }
337
338     private void prepareTypeMappings() {
339         // If getSOAPMappingRegistry() as been called direcly then there
340
// is a possibility that the local type map has not yet been
341
// initialized so check now.
342
if (localTypeMap == null ) {
343             localTypeMap = new HashMap JavaDoc();
344         }
345         prepareTypeMappings(
346             getSOAPMappingRegistry(),
347             this.wsifTypeMap,
348             partSerializerName,
349             localTypeMap);
350     }
351
352     static void prepareTypeMappings(
353         SOAPMappingRegistry theSMR,
354         WSIFDynamicTypeMap theTypeMap,
355         String JavaDoc thePartSerializerName,
356         HashMap JavaDoc theLocalTypeMap) {
357             
358         BeanSerializer beanSer = new BeanSerializer();
359         PartSerializer partSer = null;
360         if (thePartSerializerName != null)
361             try {
362                 partSer =
363                     (PartSerializer) Class
364                         .forName(
365                             thePartSerializerName,
366                             true,
367                             Thread.currentThread().getContextClassLoader())
368                         .newInstance();
369             } catch (Throwable JavaDoc ignored) {
370                 Trc.ignoredException(ignored);
371             }
372
373         Serializer literalSerializer = partSer;
374         Deserializer literalDeserializer = partSer;
375         Serializer soapSerializer = beanSer;
376         Deserializer soapDeserializer = beanSer;
377         String JavaDoc soapEncoding = Constants.NS_URI_SOAP_ENC;
378
379         // initialize ApacheSOAP specific mappings here
380
for (Iterator JavaDoc i = theTypeMap.iterator(); i.hasNext();) {
381             WSIFDynamicTypeMapping mapping = (WSIFDynamicTypeMapping) i.next();
382
383             Class JavaDoc javaClass = mapping.getJavaType();
384             org.apache.soap.util.xml.QName typeName =
385                 new org.apache.soap.util.xml.QName(
386                     mapping.getXmlType().getNamespaceURI(),
387                     mapping.getXmlType().getLocalPart());
388                     
389             // Add mappings to a local hashmap for use in preparation of the operation
390
theLocalTypeMap.put(typeName, javaClass);
391
392             Serializer ser = null;
393             // Set up SOAP encoding mappings
394
try {
395                 ser = theSMR.querySerializer(javaClass, soapEncoding);
396             } catch (IllegalArgumentException JavaDoc iae) {
397                 Trc.ignoredException(iae);
398             }
399             // Only add a mapping if a serializer does not already exist
400
if (ser == null) {
401                 theSMR.mapTypes(
402                     soapEncoding,
403                     typeName,
404                     javaClass,
405                     soapSerializer,
406                     soapDeserializer);
407             }
408             
409             // Set up literal encoding mappings
410
try {
411                 ser = null;
412                 ser = theSMR.querySerializer(javaClass, LITERAL_ENCODING);
413             } catch (IllegalArgumentException JavaDoc iae) {
414                 Trc.ignoredException(iae);
415             }
416             // Only add a mapping if a serializer does not already exist
417
if (ser == null) {
418                 theSMR.mapTypes(
419                     LITERAL_ENCODING,
420                     typeName,
421                     javaClass,
422                     literalSerializer,
423                     literalDeserializer);
424             }
425         }
426     }
427
428     public URL JavaDoc getEndPoint() {
429         Trc.entry(this);
430         Trc.exit(url);
431         return url;
432     }
433
434     public void setEndPoint(URL JavaDoc url) {
435         Trc.entry(this, url);
436         this.url = url;
437         Trc.exit();
438     }
439
440     public SOAPTransport getSOAPTransport() {
441         Trc.entry(this);
442         Trc.exit(st);
443         return st;
444     }
445
446     public void setSOAPTransport(SOAPTransport st) {
447         Trc.entry(this, st);
448         this.st = st;
449         Trc.exit();
450     }
451
452     // where is WSDL defining this abstract mesage
453
public Definition getDefinition() {
454         Trc.entry(this);
455         Trc.exit(definition);
456         return definition;
457     }
458
459     public void setDefinition(Definition value) {
460         Trc.entry(this, value);
461         definition = value;
462         Trc.exit();
463     }
464
465     public Port getPort() {
466         Trc.entry(this);
467         Trc.exit(port);
468         return port;
469     }
470
471     public void setPort(Port value) {
472         Trc.entry(this, value);
473         port = value;
474         Trc.exit();
475     }
476
477     // WSIF: keep list of operations available in this port
478
public void setDynamicWSIFOperation(
479         String JavaDoc name,
480         String JavaDoc inputName,
481         String JavaDoc outputName,
482         WSIFOperation_ApacheSOAP value) {
483         Trc.entry(this, name, inputName, outputName, value);
484         operationInstances.put(getKey(name, inputName, outputName), value);
485         Trc.exit();
486     }
487
488     public WSIFOperation createOperation(String JavaDoc operationName)
489         throws WSIFException {
490         Trc.entry(this, operationName);
491         WSIFOperation wo = createOperation(operationName, null, null);
492         Trc.exit(wo);
493         return wo;
494     }
495
496     public WSIFOperation createOperation(
497         String JavaDoc operationName,
498         String JavaDoc inputName,
499         String JavaDoc outputName)
500         throws WSIFException {
501         Trc.entry(this, operationName, inputName, outputName);
502         WSIFOperation_ApacheSOAP op =
503             getDynamicWSIFOperation(operationName, inputName, outputName);
504         if (op == null) {
505             throw new WSIFException(
506                 "Could not create operation: "
507                     + operationName
508                     + ":"
509                     + inputName
510                     + ":"
511                     + outputName);
512         }
513         WSIFOperation wo = op.copy();
514         Trc.exit(wo);
515         return wo;
516     }
517
518     public WSIFOperation_ApacheSOAP getDynamicWSIFOperation(
519         String JavaDoc name,
520         String JavaDoc inputName,
521         String JavaDoc outputName)
522         throws WSIFException {
523         Trc.entry(this, name, inputName, outputName);
524
525         WSIFOperation_ApacheSOAP tempOp =
526             (WSIFOperation_ApacheSOAP) operationInstances.get(
527                 getKey(name, inputName, outputName));
528
529         WSIFOperation_ApacheSOAP operation = null;
530         if (tempOp != null) {
531             operation = tempOp.copy();
532         }
533         
534         if (operation == null) {
535             BindingOperation bop =
536                WSIFUtils.getBindingOperation(
537                   port.getBinding(), name, inputName, outputName );
538
539             if (bop != null) {
540                 operation =
541                     new WSIFOperation_ApacheSOAP(
542                         this,
543                         bop.getOperation(),
544                         wsifTypeMap);
545                 if (operation == null) {
546                     throw new WSIFException(
547                         "Operation not found from binding operation: "
548                             + bop.getName());
549                 }
550
551                 operation.setStyle(this.style);
552                 operation.setPartSerializerName(this.partSerializerName);
553
554                 if (jmsAddressPropVals != null
555                     && jmsAddressPropVals.size() > 0) {
556                     if (st instanceof SOAPJMSConnection)
557                         operation.addInputJmsPropertyValues(jmsAddressPropVals);
558                     else
559                         throw new WSIFException("jms:propertyValue found in non-jms address");
560                 }
561
562                 // get soapActionURI and style from soap:operation
563
SOAPOperation soapOperation =
564                     (SOAPOperation) getExtElem(bop,
565                         SOAPOperation.class,
566                         bop.getExtensibilityElements());
567                 if (soapOperation == null) {
568                     throw new WSIFException(
569                         "soapAction must be specified in "
570                             + " required by WSDL 1.1 soap:operation binding for "
571                             + bop.getName());
572                 }
573                 String JavaDoc soapActionURI = soapOperation.getSoapActionURI();
574                 operation.setSoapActionURI(soapActionURI);
575
576                 Trc.event(
577                     this,
578                     "setting actionURI ",
579                     soapActionURI,
580                     " for op ",
581                     operation.getName());
582                 String JavaDoc opStyle = soapOperation.getStyle();
583
584                 // try to get soap:body for input message
585
BindingInput binpt = bop.getBindingInput();
586                 SOAPBody soapInputBody =
587                     (SOAPBody) getExtElem(binpt,
588                         SOAPBody.class,
589                         binpt.getExtensibilityElements());
590                 if (soapInputBody != null) {
591                     String JavaDoc namespaceURI = soapInputBody.getNamespaceURI();
592
593                     Trc.event(
594                         this,
595                         "setting namespace ",
596                         namespaceURI,
597                         " for op ",
598                         operation.getName());
599
600                     operation.setInputNamespace(namespaceURI);
601                     String JavaDoc use = soapInputBody.getUse();
602                     operation.setInputUse(use);
603
604                     List JavaDoc encodingStyles = soapInputBody.getEncodingStyles();
605                     if (encodingStyles != null) {
606                         if (encodingStyles.size() == 0) {
607                         }
608                         operation.setInputEncodingStyle(
609                             (String JavaDoc) encodingStyles.get(0));
610                         // quietly ignore if encodingStyles.size() > 1 ...
611
}
612                     List JavaDoc parts = soapInputBody.getParts();
613                     if (parts != null)
614                         operation.setPartNames(parts);
615                 }
616
617                 SOAPHeader soapHeader =
618                     (SOAPHeader) getExtElem(binpt,
619                         SOAPHeader.class,
620                         binpt.getExtensibilityElements());
621                 if (soapHeader != null) {
622                     throw new WSIFException(
623                         "not supported input soap:header " + soapHeader);
624                 }
625
626                 List JavaDoc inJmsProps =
627                     getExtElems(
628                         binpt,
629                         JMSProperty.class,
630                         binpt.getExtensibilityElements());
631                 if (inJmsProps != null && inJmsProps.size() > 0) {
632                     if (st instanceof SOAPJMSConnection)
633                         operation.setInputJmsProperties(inJmsProps);
634                     else
635                         throw new WSIFException("jms:properties found in non-jms binding");
636                 }
637
638                 List JavaDoc inJmsPropVals =
639                     getExtElems(
640                         binpt,
641                         JMSPropertyValue.class,
642                         binpt.getExtensibilityElements());
643                 if (inJmsPropVals != null && inJmsPropVals.size() > 0) {
644                     if (st instanceof SOAPJMSConnection)
645                         operation.addInputJmsPropertyValues(inJmsPropVals);
646                     else
647                         throw new WSIFException("jms:propertyValue found in non-jms binding");
648                 }
649
650                 // try to get soap:body for output message
651
BindingOutput boutpt = bop.getBindingOutput();
652                 if (boutpt != null) {
653                     SOAPBody soapOutputBody =
654                         (SOAPBody) getExtElem(boutpt,
655                             SOAPBody.class,
656                             boutpt.getExtensibilityElements());
657                     if (soapOutputBody != null) {
658                         // NOTE: element ignored
659
//String namespaceURI = soapOutputBody.getNamespaceURI();
660
String JavaDoc use = soapOutputBody.getUse();
661                         operation.setOutputUse(use);
662
663                         // NOTE: element ignored
664
//List encodingStyles = soapInputBody.getEncodingStyles();
665
List JavaDoc parts = soapOutputBody.getParts();
666                         if (parts != null && parts.size() > 0) {
667                             operation.setReturnName((String JavaDoc) parts.get(0));
668                         }
669                     }
670                     soapHeader =
671                         (SOAPHeader) getExtElem(boutpt,
672                             SOAPHeader.class,
673                             boutpt.getExtensibilityElements());
674                     if (soapHeader != null) {
675                         throw new WSIFException(
676                             "not supported output soap:header " + soapHeader);
677                     }
678
679                     List JavaDoc outJmsProps =
680                         getExtElems(
681                             boutpt,
682                             JMSProperty.class,
683                             boutpt.getExtensibilityElements());
684                     if (outJmsProps != null && outJmsProps.size() > 0) {
685                         if (st instanceof SOAPJMSConnection)
686                             operation.setOutputJmsProperties(outJmsProps);
687                         else
688                             throw new WSIFException("jms:properties found in non-jms binding");
689                     }
690                 }
691
692                 // Only now the operation has enough information to initialize itself
693
// operation.prepare();
694

695                 // make this operation instance accessible
696
setDynamicWSIFOperation(name, inputName, outputName, operation);
697             }
698         }
699
700         Trc.exit(operation);
701         return operation;
702     }
703
704     /**
705      * Gets the partSerializerName.
706      * @return Returns a String
707      */

708     public String JavaDoc getPartSerializerName() {
709         Trc.entry(this);
710         Trc.exit(partSerializerName);
711         return partSerializerName;
712     }
713
714     /**
715      * Sets the partSerializerName.
716      * @param partSerializerName The partSerializerName to set
717      */

718     public void setPartSerializerName(String JavaDoc partSerializerName) {
719         Trc.entry(this, partSerializerName);
720         this.partSerializerName = partSerializerName;
721         Trc.exit();
722     }
723
724     /**
725      * Closes the port. All methods are invalid after calling this method.
726      */

727     public void close() throws WSIFException {
728         Trc.entry(this);
729         if (st != null && st instanceof SOAPJMSConnection)
730              ((SOAPJMSConnection) st).close();
731         Trc.exit();
732     }
733
734     /**
735      * Tests if this port supports asynchronous calls to operations.
736      *
737      * @return true if the port is using a JMS transport, otherwise false
738      */

739     public boolean supportsAsync() {
740         if (st instanceof SOAPJMSConnection) {
741             return true;
742         } else {
743             return false;
744         }
745     }
746
747     public String JavaDoc deep() {
748         String JavaDoc buff = "";
749         try {
750             buff = new String JavaDoc(super.toString() + ":\n");
751
752             if (operationInstances == null) {
753                 buff += " operationInstances: null";
754             } else {
755                 buff += " operationInstances: size:"
756                     + operationInstances.size();
757                 Iterator JavaDoc it = operationInstances.keySet().iterator();
758                 int i = 0;
759                 while (it.hasNext()) {
760                     String JavaDoc key = (String JavaDoc) it.next();
761                     WSIFOperation_ApacheSOAP woas =
762                         (WSIFOperation_ApacheSOAP) operationInstances.get(key);
763                     buff += "\noperationInstances["
764                         + i
765                         + "]:"
766                         + key
767                         + " "
768                         + woas.getName()
769                         + " ";
770                     i++;
771                 }
772             }
773
774             buff += "\nport:" + Trc.brief(port);
775             buff += " definition:" + Trc.brief(definition);
776             buff += " call:" + call;
777             buff += " soapTransport:" + st;
778             buff += " url:" + url;
779             buff += " style:" + style;
780             buff += " partSerializerName:" + partSerializerName;
781             buff += " wsifTypeMap:" + wsifTypeMap;
782             buff += " jmsAddressPropVals:" + jmsAddressPropVals;
783         } catch (Exception JavaDoc e) {
784             Trc.exceptionInTrace(e);
785         }
786
787         return buff;
788     }
789
790     private void writeObject(ObjectOutputStream JavaDoc oos) throws IOException JavaDoc {
791         oos.defaultWriteObject();
792     }
793
794     private void readObject(ObjectInputStream JavaDoc ois)
795         throws ClassNotFoundException JavaDoc, IOException JavaDoc {
796         ois.defaultReadObject();
797                 
798         // reset the operation instances
799
operationInstances = new HashMap JavaDoc();
800         
801         // The transient call reference does not need to be re-established here since it will
802
// be taken care of when getCall is next invoked. However, the SOAPTransport needs to
803
// be set again
804
JMSAddress ja =
805             (JMSAddress) getExtElem(port,
806                 JMSAddress.class,
807                 port.getExtensibilityElements());
808         SOAPAddress sa =
809             (SOAPAddress) getExtElem(port,
810                 SOAPAddress.class,
811                 port.getExtensibilityElements());
812
813         if (sa != null && ja != null)
814             throw new WSIFException(
815                 "Both soap:address and jms:address cannot be specified for port "
816                     + port.getName());
817
818         if (sa == null && ja == null)
819             throw new WSIFException(
820                 "Either soap:address or jms:address must be specified for port "
821                     + port.getName());
822
823         if (ja != null) {
824             // Port jms:address binding element
825
jmsAddressPropVals = ja.getJMSPropertyValues();
826             st = new SOAPJMSConnection(ja, port.getName());
827         } else {
828             // Port soap:address bindng element
829
st = new SOAPHTTPConnection();
830         }
831     }
832 }
Popular Tags