View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.geronimo.ews.ws4j2ee.toWs.ws;
17  
18  import org.apache.axis.Constants;
19  import org.apache.axis.deployment.wsdd.WSDDConstants;
20  import org.apache.axis.constants.Scope;
21  import org.apache.axis.constants.Style;
22  import org.apache.axis.constants.Use;
23  import org.apache.axis.utils.JavaUtils;
24  import org.apache.axis.utils.Messages;
25  import org.apache.axis.wsdl.symbolTable.BindingEntry;
26  import org.apache.axis.wsdl.symbolTable.CollectionTE;
27  import org.apache.axis.wsdl.symbolTable.Element;
28  import org.apache.axis.wsdl.symbolTable.FaultInfo;
29  import org.apache.axis.wsdl.symbolTable.Parameter;
30  import org.apache.axis.wsdl.symbolTable.Parameters;
31  import org.apache.axis.wsdl.symbolTable.SchemaUtils;
32  import org.apache.axis.wsdl.symbolTable.SymbolTable;
33  import org.apache.axis.wsdl.symbolTable.TypeEntry;
34  import org.apache.axis.wsdl.toJava.Emitter;
35  import org.apache.axis.wsdl.toJava.JavaWriter;
36  import org.apache.axis.wsdl.toJava.Utils;
37  import org.apache.geronimo.ews.jaxrpcmapping.J2eeEmitter;
38  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
39  import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
40  import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
41  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFHandler;
42  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFInitParam;
43  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
44  import org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider;
45  
46  import javax.wsdl.Binding;
47  import javax.wsdl.BindingOperation;
48  import javax.wsdl.Definition;
49  import javax.wsdl.Operation;
50  import javax.wsdl.OperationType;
51  import javax.wsdl.Port;
52  import javax.wsdl.Service;
53  import javax.wsdl.extensions.UnknownExtensibilityElement;
54  import javax.wsdl.extensions.soap.SOAPBinding;
55  import javax.xml.namespace.QName;
56  import java.io.File;
57  import java.io.FileOutputStream;
58  import java.io.IOException;
59  import java.io.OutputStreamWriter;
60  import java.io.PrintWriter;
61  import java.util.ArrayList;
62  import java.util.Collection;
63  import java.util.HashSet;
64  import java.util.Iterator;
65  import java.util.Map;
66  import java.util.Vector;
67  
68  /***
69   * This is Wsdl2java's deploy Writer.  It writes the deploy.wsdd file.
70   */
71  public class J2eeDeployWriter extends JavaWriter {
72      protected boolean useProvider = false;
73      /***
74       * Field definition
75       */
76      protected Definition definition;
77  
78      /***
79       * Field symbolTable
80       */
81      protected SymbolTable symbolTable;
82      protected J2EEWebServiceContext wscontext;
83  
84      /***
85       * Constructor.
86       *
87       * @param emitter
88       * @param definition
89       * @param symbolTable
90       */
91      public J2eeDeployWriter(Emitter emitter, Definition definition,
92                              SymbolTable symbolTable) {
93          super(emitter, "deploy");
94          this.definition = definition;
95          this.symbolTable = symbolTable;
96          wscontext = ((J2eeEmitter) emitter).getWscontext();
97          if (wscontext == null) {
98              throw new RuntimeException("wscontext can not be null");
99          }
100         String val = System.getProperty("useProvider");
101         if(val != null){
102             useProvider = true;
103         }
104         
105     }    // ctor
106 
107     /***
108      * Generate deploy.wsdd.  Only generate it if the emitter
109      * is generating server-side mappings.
110      *
111      * @throws IOException
112      */
113     public void generate() throws IOException {
114         if (emitter.isServerSide()) {
115             super.generate();
116         }
117     }    // generate
118 
119     /***
120      * Return the fully-qualified name of the deploy.wsdd file
121      * to be generated.
122      *
123      * @return
124      */
125     protected String getFileName() {
126 //		String dir =
127 //				emitter.getNamespaces().getAsDir(definition.getTargetNamespace());
128         String dir =
129                 emitter.getNamespaces().getAsDir("");
130         return dir + "deploy.wsdd";
131     }    // getFileName
132 
133     /***
134      * Replace the default file header with the deployment doc file header.
135      *
136      * @param pw
137      * @throws IOException
138      */
139     protected void writeFileHeader(PrintWriter pw) throws IOException {
140         pw.println(Messages.getMessage("deploy00"));
141         pw.println(Messages.getMessage("deploy02"));
142         pw.println(Messages.getMessage("deploy03"));
143         pw.println(Messages.getMessage("deploy05"));
144         pw.println(Messages.getMessage("deploy06"));
145         pw.println(Messages.getMessage("deploy07"));
146         pw.println(Messages.getMessage("deploy09"));
147         pw.println();
148         pw.println("<deployment");
149         pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD + "\"");
150         pw.println("    xmlns:" + WSDDConstants.NS_PREFIX_WSDD_JAVA + "=\""
151                 + WSDDConstants.URI_WSDD_JAVA + "\">");
152     }    // writeFileHeader
153 
154     /***
155      * Write the body of the deploy.wsdd file.
156      *
157      * @param pw
158      * @throws IOException
159      */
160     protected void writeFileBody(PrintWriter pw) throws IOException {
161         writeDeployServices(pw);
162         pw.println("</deployment>");
163     }    // writeFileBody
164 
165     /***
166      * Write out deployment and undeployment instructions for each WSDL service
167      *
168      * @param pw
169      * @throws IOException
170      */
171     protected void writeDeployServices(PrintWriter pw) throws IOException {
172         // deploy the ports on each service
173         Map serviceMap = definition.getServices();
174         for (Iterator mapIterator = serviceMap.values().iterator();
175              mapIterator.hasNext();) {
176             Service myService = (Service) mapIterator.next();
177             pw.println();
178             pw.println("  <!-- "
179                     + Messages.getMessage("wsdlService00", myService.getQName().getLocalPart()) + " -->");
180             pw.println();
181             for (Iterator portIterator = myService.getPorts().values().iterator();
182                  portIterator.hasNext();) {
183                 Port myPort = (Port) portIterator.next();
184                 BindingEntry bEntry =
185                         symbolTable.getBindingEntry(myPort.getBinding().getQName());
186 
187                 // If this isn't an SOAP binding, skip it
188                 if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
189                     continue;
190                 }
191                 writeDeployPort(pw, myPort, myService, bEntry);
192             }
193         }
194     }    // writeDeployServices
195 
196     /***
197      * Write out bean mappings for each type
198      *
199      * @param pw
200      * @param binding
201      * @param hasLiteral
202      * @param hasMIME
203      * @param use
204      * @throws IOException
205      */
206     protected void writeDeployTypes(PrintWriter pw, Binding binding, boolean hasLiteral, boolean hasMIME, Use use)
207             throws IOException {
208         pw.println();
209         if (hasMIME) {
210             QName bQName = binding.getQName();
211             writeTypeMapping(pw, bQName.getNamespaceURI(), "DataHandler",
212                     "javax.activation.DataHandler",
213                     "org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory",
214                     "org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory",
215                     use.getEncoding());
216         }
217         Map types = symbolTable.getTypeIndex();
218         Collection typeCollection = types.values();
219         for (Iterator i = typeCollection.iterator(); i.hasNext();) {
220             TypeEntry type = (TypeEntry) i.next();
221 
222             // Note this same check is repeated in JavaStubWriter.
223             boolean process = true;
224 
225             // 1) Don't register types that are base (primitive) types.
226             // If the baseType != null && getRefType() != null this
227             // is a simpleType that must be registered.
228             // 2) Don't register the special types for collections
229             // (indexed properties) or element types
230             // 3) Don't register types that are not referenced
231             // or only referenced in a literal context.
232             if (((type.getBaseType() != null) && (type.getRefType() == null))
233                     || (type instanceof CollectionTE)
234                     || (type instanceof Element) || !type.isReferenced()
235                     || type.isOnlyLiteralReferenced()) {
236                 process = false;
237             }
238             if (process) {
239                 String namespaceURI = type.getQName().getNamespaceURI();
240                 String localPart = type.getQName().getLocalPart();
241                 String javaType = type.getName();
242                 String serializerFactory;
243                 String deserializerFactory;
244                 String encodingStyle = "";
245                 if (!hasLiteral) {
246                     encodingStyle = use.getEncoding();
247                 }
248                 if (javaType.endsWith("[]")) {
249                     if (SchemaUtils.isListWithItemType(type.getNode())) {
250                         serializerFactory =
251                                 "org.apache.axis.encoding.ser.SimpleListSerializerFactory";
252                         deserializerFactory =
253                                 "org.apache.axis.encoding.ser.SimpleListDeserializerFactory";
254                     } else {
255                         serializerFactory =
256                                 "org.apache.axis.encoding.ser.ArraySerializerFactory";
257                         deserializerFactory =
258                                 "org.apache.axis.encoding.ser.ArrayDeserializerFactory";
259                     }
260                 } else if ((type.getNode() != null) && (Utils.getEnumerationBaseAndValues(type.getNode(), symbolTable) != null)) {
261                     serializerFactory =
262                             "org.apache.axis.encoding.ser.EnumSerializerFactory";
263                     deserializerFactory =
264                             "org.apache.axis.encoding.ser.EnumDeserializerFactory";
265                 } else if (type.isSimpleType()) {
266                     serializerFactory =
267                             "org.apache.axis.encoding.ser.SimpleSerializerFactory";
268                     deserializerFactory =
269                             "org.apache.axis.encoding.ser.SimpleDeserializerFactory";
270                 } else if (type.getBaseType() != null) {
271                     serializerFactory =
272                             "org.apache.axis.encoding.ser.SimpleSerializerFactory";
273                     deserializerFactory =
274                             "org.apache.axis.encoding.ser.SimpleDeserializerFactory";
275                 } else {
276                     serializerFactory =
277                             "org.apache.axis.encoding.ser.BeanSerializerFactory";
278                     deserializerFactory =
279                             "org.apache.axis.encoding.ser.BeanDeserializerFactory";
280                 }
281                 writeTypeMapping(pw, namespaceURI, localPart, javaType,
282                         serializerFactory, deserializerFactory,
283                         encodingStyle);
284             }
285         }
286     }    // writeDeployTypes
287 
288     /***
289      * Raw routine that writes out the typeMapping.
290      *
291      * @param pw
292      * @param namespaceURI
293      * @param localPart
294      * @param javaType
295      * @param serializerFactory
296      * @param deserializerFactory
297      * @param encodingStyle
298      * @throws IOException
299      */
300     protected void writeTypeMapping(PrintWriter pw, String namespaceURI, String localPart, String javaType, String serializerFactory, String deserializerFactory, String encodingStyle)
301             throws IOException {
302         pw.println("      <typeMapping");
303         pw.println("        xmlns:ns=\"" + namespaceURI + "\"");
304         pw.println("        qname=\"ns:" + localPart + '"');
305         pw.println("        type=\"java:" + javaType + '"');
306         pw.println("        serializer=\"" + serializerFactory + "\"");
307         pw.println("        deserializer=\"" + deserializerFactory + "\"");
308         pw.println("        encodingStyle=\"" + encodingStyle + "\"");
309         pw.println("      />");
310     }
311 
312     /***
313      * Write out deployment and undeployment instructions for given WSDL port
314      *
315      * @param pw
316      * @param port
317      * @param service
318      * @param bEntry
319      * @throws IOException
320      */
321     protected void writeDeployPort(PrintWriter pw, Port port, Service service, BindingEntry bEntry)
322             throws IOException {
323         String serviceName = port.getName();
324         boolean hasLiteral = bEntry.hasLiteral();
325         boolean hasMIME = Utils.hasMIME(bEntry);
326         String prefix = WSDDConstants.NS_PREFIX_WSDD_JAVA;
327         String styleStr = "";
328         Use use = Use.DEFAULT;
329         Iterator iterator =
330                 bEntry.getBinding().getExtensibilityElements().iterator();
331 
332         //get the Name of the provider needed in the deploy.wsdd
333         String provider = null;
334         provider = GenerationConstants.WS4J2EE_PROVIDER;
335         while (iterator.hasNext()) {
336             Object obj = iterator.next();
337             if (obj instanceof SOAPBinding) {
338                 use = Use.ENCODED;
339             } else if (obj instanceof UnknownExtensibilityElement) {
340                 // TODO: After WSDL4J supports soap12, change this code
341                 UnknownExtensibilityElement unkElement =
342                         (UnknownExtensibilityElement) obj;
343                 QName name =
344                         unkElement.getElementType();
345                 if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP)
346                         && name.getLocalPart().equals("binding")) {
347                     use = Use.ENCODED;
348                 }
349             }
350         }
351         if (symbolTable.isWrapped()) {
352             styleStr = " style=\"" + Style.WRAPPED + "\"";
353             use = Use.LITERAL;
354         } else {
355             styleStr = " style=\"" + bEntry.getBindingStyle().getName() + "\"";
356             if (hasLiteral) {
357                 use = Use.LITERAL;
358             }
359         }
360         String useStr = " use=\"" + use + "\"";
361 //		if(provider!= null){
362 //			pw.println("  <service name=\"" + serviceName + "\" provider=\""
363 //					+ provider + "\"" + styleStr + useStr + ">");
364 //			WSCFHandler[] handlers = wscontext.getMiscInfo().getHandlers();	
365 //			for(int i = 0;i<handlers.length;i++){
366 //				writeHandler(pw,handlers[i]);
367 //			}	
368 //		}else{
369 //			pw.println("  <service name=\"" + serviceName + "\" provider=\""
370 //					+ prefix + ":RPC" + "\"" + styleStr + useStr + ">");
371 //		}
372         if (this.useProvider) {
373             String continer = wscontext.getMiscInfo().getTargetJ2EEContainer();
374             if (GenerationConstants.GERONIMO_CONTAINER.equals(continer)) {
375 //                pw.println("    <service name=\"" + serviceName + "\" provider=\"java:geronimo\""
376 //                        + styleStr + useStr + ">");
377                 pw.println("    <service name=\"" + serviceName + "\" provider=\"Handler\""
378                         + styleStr + useStr + ">");
379                 pw.println("      <parameter name=\"handlerClass\" value=\"org.apache.geronimo.axis.GeronimoProvider\"/>");
380             } else {
381 //                pw.println("  <service name=\"" + serviceName + "\" provider=\"java:ews\""
382 //                        + styleStr + useStr + ">");
383                 pw.println("    <service name=\"" + serviceName + "\" provider=\"Handler\"" 
384                       + styleStr + useStr + ">");
385                 pw.println("      <parameter name=\"handlerClass\" value=\"org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider\"/>");
386               //pw.println("        <java:provider  java:className=\"org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider\" java:isStatic=\"true\"/>\n");
387                         //
388                         //java:className
389             }
390         } else {
391             pw.println("  <service name=\"" + serviceName + "\" provider=\"java:j2ee\""
392                     + styleStr + useStr + ">");
393         }
394         EJBContext ejbcontext = wscontext.getEJBDDContext();
395         if (ejbcontext != null) {
396             pw.println("      <parameter name=\""+EWSProvider.OPTION_USE_EJB+"\" value=\"ejb\"/>");
397             if (ejbcontext.getEjbhomeInterface() != null) {
398                 pw.println("      <parameter name=\""+EWSProvider.OPTION_HOMEINTERFACE_NAME+"\" value=\""
399                         + ejbcontext.getEjbhomeInterface() + "\"/>");
400             }
401             if (ejbcontext.getEjbRemoteInterface() != null) {
402                 pw.println("      <parameter name=\""+EWSProvider.OPTION_REMOTEINTERFACE_NAME+"\" value=\""
403                         + ejbcontext.getEjbRemoteInterface() + "\"/>");
404             }
405             if (ejbcontext.getEjbLocalHomeInterfce() != null) {
406                 pw.println("      <parameter name=\""+EWSProvider.OPTION_LOCALHOMEINTERFACE_NAME+"\" value=\""
407                         + ejbcontext.getEjbLocalHomeInterfce() + "\"/>");
408             }
409             if (ejbcontext.getEjbLocalInterface() != null) {
410                 pw.println("      <parameter name=\""+EWSProvider.OPTION_LOCALINTERFACE_NAME+"\" value=\""
411                         + ejbcontext.getEjbLocalInterface() + "\"/>");
412             }
413             if (ejbcontext.getEjbRemoteInterface() != null) {
414                 pw.println("      <parameter name=\""+EWSProvider.OPTION_HOMEINTERFACE_NAME+"\" value=\""
415                         + "ejb/" + ejbcontext.getEjbName() + "\"/>");
416             }
417             if (ejbcontext.getEjbRemoteInterface() != null) {
418                 pw.println("      <parameter name=\""+EWSProvider.OPTION_EJB_NAME+"\" value=\""
419                         + ejbcontext.getEjbName() + "\"/>");
420             }
421         }else{
422             pw.println("      <parameter name=\""+EWSProvider.OPTION_USE_EJB+"\" value=\"web\"/>");
423         }
424         pw.println("      <parameter name=\"wsdlTargetNamespace\" value=\""
425                 + service.getQName().getNamespaceURI() + "\"/>");
426         pw.println("      <parameter name=\"wsdlServiceElement\" value=\""
427                 + service.getQName().getLocalPart() + "\"/>");
428         pw.println("      <parameter name=\"wsdlServicePort\" value=\""
429                 + serviceName + "\"/>");
430 
431         // MIME attachments don't work with multiref, so turn it off.
432         if (hasMIME) {
433             pw.println("      <parameter name=\"sendMultiRefs\" value=\"false\"/>");
434         }
435         writeDeployBinding(pw, bEntry);
436         writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME, use);
437         WSCFHandler[] handlers = this.wscontext.getMiscInfo().getHandlers();
438         if (handlers != null) {
439             for (int i = 0; i < handlers.length; i++) {
440                 writeHandler(pw, handlers[i]);
441             }
442         }
443         pw.println("  </service>");
444     }    // writeDeployPort
445 
446     /***
447      * Write out deployment instructions for given WSDL binding
448      *
449      * @param pw
450      * @param bEntry
451      * @throws IOException
452      */
453     protected void writeDeployBinding(PrintWriter pw, BindingEntry bEntry)
454             throws IOException {
455         Binding binding = bEntry.getBinding();
456         String className = bEntry.getName();
457         if (emitter.isSkeletonWanted()) {
458             className += "Skeleton";
459         } else {
460             className += "Impl";
461         }
462         if (this.useProvider) {
463             WebContext webContext = wscontext.getWebDDContext();
464             if (webContext != null) {
465                 pw.println("      <parameter name=\"className\" value=\"" + webContext.getServletClass()
466                         + "\"/>");
467             }
468         } else {
469             pw.println("      <parameter name=\"className\" value=\"" + className
470                     + "\"/>");
471         }
472         pw.println("      <parameter name=\"wsdlPortType\" value=\""
473                 + binding.getPortType().getQName().getLocalPart() + "\"/>");
474         HashSet allowedMethods = new HashSet();
475         if (!emitter.isSkeletonWanted()) {
476             Iterator operationsIterator =
477                     binding.getBindingOperations().iterator();
478             for (; operationsIterator.hasNext();) {
479                 BindingOperation bindingOper =
480                         (BindingOperation) operationsIterator.next();
481                 Operation operation = bindingOper.getOperation();
482                 OperationType type = operation.getStyle();
483                 String javaOperName =
484                         JavaUtils.xmlNameToJava(operation.getName());
485 
486                 // These operation types are not supported.  The signature
487                 // will be a string stating that fact.
488                 if ((type == OperationType.NOTIFICATION)
489                         || (type == OperationType.SOLICIT_RESPONSE)) {
490                     continue;
491                 }
492                 allowedMethods.add(javaOperName);
493 
494                 // We pass "" as the namespace argument because we're just
495                 // interested in the return type for now.
496                 Parameters params =
497                         symbolTable.getOperationParameters(operation, "", bEntry);
498                 if (params != null) {
499                     // Get the operation QName
500                     QName elementQName = Utils.getOperationQName(bindingOper,
501                             bEntry, symbolTable);
502 
503                     // Get the operation's return QName and type
504                     QName returnQName = null;
505                     QName returnType = null;
506                     if (params.returnParam != null) {
507                         returnQName = params.returnParam.getQName();
508                         returnType = Utils.getXSIType(params.returnParam);
509                     }
510 
511                     // Get the operations faults
512                     Map faultMap = bEntry.getFaults();
513                     ArrayList faults = null;
514                     if (faultMap != null) {
515                         faults = (ArrayList) faultMap.get(bindingOper);
516                     }
517 
518                     // Write the operation metadata
519                     writeOperation(pw, javaOperName, elementQName, returnQName,
520                             returnType, params, binding.getQName(),
521                             faults);
522                 }
523             }
524         }
525         pw.print("      <parameter name=\"allowedMethods\" value=\"");
526         if (allowedMethods.isEmpty()) {
527             pw.println("*\"/>");
528         } else {
529             boolean first = true;
530             for (Iterator i = allowedMethods.iterator(); i.hasNext();) {
531                 String method = (String) i.next();
532                 if (first) {
533                     pw.print(method);
534                     first = false;
535                 } else {
536                     pw.print(" " + method);
537                 }
538             }
539             pw.println("\"/>");
540         }
541         Scope scope = emitter.getScope();
542         if (scope != null) {
543             pw.println("      <parameter name=\"scope\" value=\""
544                     + scope.getName() + "\"/>");
545         }
546     }    // writeDeployBinding
547 
548     /***
549      * Raw routine that writes out the operation and parameters.
550      *
551      * @param pw
552      * @param javaOperName
553      * @param elementQName
554      * @param returnQName
555      * @param returnType
556      * @param params
557      * @param bindingQName
558      * @param faults
559      */
560     protected void writeOperation(PrintWriter pw, String javaOperName,
561                                   QName elementQName, QName returnQName,
562                                   QName returnType, Parameters params,
563                                   QName bindingQName, ArrayList faults) {
564         pw.print("      <operation name=\"" + javaOperName + "\"");
565         if (elementQName != null) {
566             pw.print(" qname=\""
567                     + Utils.genQNameAttributeString(elementQName, "operNS")
568                     + "\"");
569         }
570         if (returnQName != null) {
571             pw.print(" returnQName=\""
572                     + Utils.genQNameAttributeStringWithLastLocalPart(returnQName, "retNS")
573                     + "\"");
574         }
575         if (returnType != null) {
576             pw.print(" returnType=\""
577                     + Utils.genQNameAttributeString(returnType, "rtns")
578                     + "\"");
579         }
580         if ((params.returnParam != null) && params.returnParam.isOutHeader()) {
581             pw.print(" returnHeader=\"true\"");
582         }
583         pw.println(" >");
584         Vector paramList = params.list;
585         for (int i = 0; i < paramList.size(); i++) {
586             Parameter param = (Parameter) paramList.elementAt(i);
587 
588             // Get the parameter name QName and type QName
589             QName paramQName = param.getQName();
590             QName paramType = Utils.getXSIType(param);
591             pw.print("        <parameter");
592             if ((paramQName == null)
593                     || "".equals(paramQName.getNamespaceURI())) {
594                 pw.print(" name=\"" + param.getName() + "\"");
595             } else {
596                 pw.print(" qname=\""
597                         + Utils.genQNameAttributeStringWithLastLocalPart(paramQName, "pns")
598                         + "\"");
599             }
600             pw.print(" type=\""
601                     + Utils.genQNameAttributeString(paramType, "tns") + "\"");
602 
603             // Get the parameter mode
604             if (param.getMode() != Parameter.IN) {
605                 pw.print(" mode=\"" + getModeString(param.getMode()) + "\"");
606             }
607 
608             // Is this a header?
609             if (param.isInHeader()) {
610                 pw.print(" inHeader=\"true\"");
611             }
612             if (param.isOutHeader()) {
613                 pw.print(" outHeader=\"true\"");
614             }
615             pw.println("/>");
616         }
617         if (faults != null) {
618             for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
619                 FaultInfo faultInfo = (FaultInfo) iterator.next();
620                 QName faultQName = faultInfo.getQName();
621                 if (faultQName != null) {
622                     String className =
623                             Utils.getFullExceptionName(faultInfo.getMessage(),
624                                     symbolTable);
625                     pw.print("        <fault");
626                     pw.print(" name=\"" + faultInfo.getName() + "\"");
627                     pw.print(" qname=\""
628                             + Utils.genQNameAttributeString(faultQName, "fns")
629                             + "\"");
630                     pw.print(" class=\"" + className + "\"");
631                     pw.print(" type=\""
632                             + Utils.genQNameAttributeString(faultInfo.getXMLType(), "tns") + "\"");
633                     pw.println("/>");
634                 }
635             }
636         }
637         pw.println("      </operation>");
638     }
639 
640     /***
641      * Method getModeString
642      *
643      * @param mode
644      * @return
645      */
646     public String getModeString(byte mode) {
647         if (mode == Parameter.IN) {
648             return "IN";
649         } else if (mode == Parameter.INOUT) {
650             return "INOUT";
651         } else {
652             return "OUT";
653         }
654     }
655 
656     /***
657      * Method getPrintWriter
658      *
659      * @param filename
660      * @return
661      * @throws IOException
662      */
663     protected PrintWriter getPrintWriter(String filename) throws IOException {
664         File file = new File(filename);
665         File parent = new File(file.getParent());
666         parent.mkdirs();
667         FileOutputStream out = new FileOutputStream(file);
668         OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
669         return new PrintWriter(writer);
670     }
671 
672     private void writeHandler(PrintWriter pw, WSCFHandler handler) {
673         pw.println("      <handler name=\"" + handler.getHandlerName() + "\"type=\"" + handler.getHandlerClass() + "\">");
674         WSCFInitParam[] param = handler.getInitParam();
675         for (int i = 0; i < param.length; i++) {
676             pw.println("      <parameter name=\"" + param[i].getParamName() + "\" value=\"" + param[i].getParamValue() + "\"/>");
677         }
678         //TODO handle soap role and soaphandlers 
679         pw.println("      </handler>");
680     }
681 }    // class JavaDeployWriter