You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by he...@apache.org on 2004/09/21 06:46:59 UTC

cvs commit: ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/wsutils WSDDJavaEWSProvider.java EWSProvider.java

hemapani    2004/09/20 21:46:59

  Modified:    contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/toWs/ws
                        J2eeDeployWriter.java
               contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/wsutils
                        EWSProvider.java
  Added:       contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/wsutils
                        WSDDJavaEWSProvider.java
  Log:
  add the code to put the parmeters to wsdd file to have the parameters about the impl bean
  
  Revision  Changes    Path
  1.9       +742 -693  ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeDeployWriter.java
  
  Index: J2eeDeployWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/toWs/ws/J2eeDeployWriter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- J2eeDeployWriter.java	2 Sep 2004 13:03:13 -0000	1.8
  +++ J2eeDeployWriter.java	21 Sep 2004 04:46:59 -0000	1.9
  @@ -1,693 +1,742 @@
  -/*
  - * Copyright 2001-2004 The Apache Software Foundation.
  - * 
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - * 
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -package org.apache.geronimo.ews.ws4j2ee.toWs.ws;
  -
  -import java.io.File;
  -import java.io.FileOutputStream;
  -import java.io.IOException;
  -import java.io.OutputStreamWriter;
  -import java.io.PrintWriter;
  -import java.util.ArrayList;
  -import java.util.Collection;
  -import java.util.HashSet;
  -import java.util.Iterator;
  -import java.util.Map;
  -import java.util.Vector;
  -
  -import javax.wsdl.Binding;
  -import javax.wsdl.BindingOperation;
  -import javax.wsdl.Definition;
  -import javax.wsdl.Operation;
  -import javax.wsdl.OperationType;
  -import javax.wsdl.Port;
  -import javax.wsdl.Service;
  -import javax.wsdl.extensions.UnknownExtensibilityElement;
  -import javax.wsdl.extensions.soap.SOAPBinding;
  -import javax.xml.namespace.QName;
  -
  -import org.apache.axis.Constants;
  -import org.apache.axis.deployment.wsdd.WSDDConstants;
  -import org.apache.axis.enum.Scope;
  -import org.apache.axis.enum.Style;
  -import org.apache.axis.enum.Use;
  -import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.utils.Messages;
  -import org.apache.axis.wsdl.symbolTable.BindingEntry;
  -import org.apache.axis.wsdl.symbolTable.CollectionTE;
  -import org.apache.axis.wsdl.symbolTable.Element;
  -import org.apache.axis.wsdl.symbolTable.FaultInfo;
  -import org.apache.axis.wsdl.symbolTable.Parameter;
  -import org.apache.axis.wsdl.symbolTable.Parameters;
  -import org.apache.axis.wsdl.symbolTable.SchemaUtils;
  -import org.apache.axis.wsdl.symbolTable.SymbolTable;
  -import org.apache.axis.wsdl.symbolTable.TypeEntry;
  -import org.apache.axis.wsdl.toJava.Emitter;
  -import org.apache.axis.wsdl.toJava.JavaWriter;
  -import org.apache.axis.wsdl.toJava.Utils;
  -import org.apache.geronimo.ews.jaxrpcmapping.J2eeEmitter;
  -import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
  -import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFHandler;
  -import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFInitParam;
  -import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
  -
  -/**
  - * This is Wsdl2java's deploy Writer.  It writes the deploy.wsdd file.
  - */
  -public class J2eeDeployWriter  extends JavaWriter{
  -	
  -	/** Field definition */
  -	protected Definition definition;
  -
  -	/** Field symbolTable */
  -	protected SymbolTable symbolTable;
  -	protected J2EEWebServiceContext wscontext;
  -
  -	/**
  -	 * Constructor.
  -	 * 
  -	 * @param emitter     
  -	 * @param definition  
  -	 * @param symbolTable 
  -	 */
  -	public J2eeDeployWriter(Emitter emitter, Definition definition,
  -							SymbolTable symbolTable) {
  -
  -		super(emitter, "deploy");
  -		this.definition = definition;
  -		this.symbolTable = symbolTable;
  -		wscontext =((J2eeEmitter)emitter).getWscontext();
  -		if(wscontext == null){
  -			throw new RuntimeException("wscontext can not be null");
  -		} 
  -	}    // ctor
  -
  -	/**
  -	 * Generate deploy.wsdd.  Only generate it if the emitter
  -	 * is generating server-side mappings.
  -	 * 
  -	 * @throws IOException 
  -	 */
  -	public void generate() throws IOException {
  -
  -		if (emitter.isServerSide()) {
  -			super.generate();
  -		}
  -	}    // generate
  -	
  -
  -	/**
  -	 * Return the fully-qualified name of the deploy.wsdd file
  -	 * to be generated.
  -	 * 
  -	 * @return 
  -	 */
  -	protected String getFileName() {
  -//		String dir =
  -//				emitter.getNamespaces().getAsDir(definition.getTargetNamespace());
  -		String dir =
  -				emitter.getNamespaces().getAsDir("");
  -		return dir + "deploy.wsdd"; 
  -	}    // getFileName
  -
  -	/**
  -	 * Replace the default file header with the deployment doc file header.
  -	 * 
  -	 * @param pw 
  -	 * @throws IOException 
  -	 */
  -	protected void writeFileHeader(PrintWriter pw) throws IOException {
  -
  -		pw.println(Messages.getMessage("deploy00"));
  -		pw.println(Messages.getMessage("deploy02"));
  -		pw.println(Messages.getMessage("deploy03"));
  -		pw.println(Messages.getMessage("deploy05"));
  -		pw.println(Messages.getMessage("deploy06"));
  -		pw.println(Messages.getMessage("deploy07"));
  -		pw.println(Messages.getMessage("deploy09"));
  -		pw.println();
  -		pw.println("<deployment");
  -		pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD + "\"");
  -		pw.println("    xmlns:" + WSDDConstants.NS_PREFIX_WSDD_JAVA + "=\""
  -				+ WSDDConstants.URI_WSDD_JAVA + "\">");
  -	}    // writeFileHeader
  -
  -	/**
  -	 * Write the body of the deploy.wsdd file.
  -	 * 
  -	 * @param pw 
  -	 * @throws IOException 
  -	 */
  -	protected void writeFileBody(PrintWriter pw) throws IOException {
  -		writeDeployServices(pw);
  -		pw.println("</deployment>");
  -	}    // writeFileBody
  -
  -	/**
  -	 * Write out deployment and undeployment instructions for each WSDL service
  -	 * 
  -	 * @param pw 
  -	 * @throws IOException 
  -	 */
  -	protected void writeDeployServices(PrintWriter pw) throws IOException {
  -
  -		// deploy the ports on each service
  -		Map serviceMap = definition.getServices();
  -
  -		for (Iterator mapIterator = serviceMap.values().iterator();
  -			 mapIterator.hasNext();) {
  -			Service myService = (Service) mapIterator.next();
  -
  -			pw.println();
  -			pw.println(
  -					"  <!-- "
  -					+ Messages.getMessage(
  -							"wsdlService00", myService.getQName().getLocalPart()) + " -->");
  -			pw.println();
  -
  -			for (Iterator portIterator = myService.getPorts().values().iterator();
  -				 portIterator.hasNext();) {
  -				Port myPort = (Port) portIterator.next();
  -				BindingEntry bEntry =
  -						symbolTable.getBindingEntry(myPort.getBinding().getQName());
  -
  -				// If this isn't an SOAP binding, skip it
  -				if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
  -					continue;
  -				}
  -
  -				writeDeployPort(pw, myPort, myService, bEntry);
  -			}
  -		}
  -	}    // writeDeployServices
  -
  -	/**
  -	 * Write out bean mappings for each type
  -	 * 
  -	 * @param pw         
  -	 * @param binding    
  -	 * @param hasLiteral 
  -	 * @param hasMIME    
  -	 * @param use        
  -	 * @throws IOException 
  -	 */
  -	protected void writeDeployTypes(
  -			PrintWriter pw, Binding binding, boolean hasLiteral, boolean hasMIME, Use use)
  -			throws IOException {
  -
  -		pw.println();
  -
  -		if (hasMIME) {
  -			QName bQName = binding.getQName();
  -
  -			writeTypeMapping(
  -					pw, bQName.getNamespaceURI(), "DataHandler",
  -					"javax.activation.DataHandler",
  -					"org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory",
  -					"org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory",
  -					use.getEncoding());
  -		}
  -
  -		Map types = symbolTable.getTypeIndex();
  -		Collection typeCollection = types.values();
  -		for (Iterator i = typeCollection.iterator(); i.hasNext(); ) {
  -			TypeEntry type = (TypeEntry) i.next();
  -
  -			// Note this same check is repeated in JavaStubWriter.
  -			boolean process = true;
  -
  -			// 1) Don't register types that are base (primitive) types.
  -			// If the baseType != null && getRefType() != null this
  -			// is a simpleType that must be registered.
  -			// 2) Don't register the special types for collections
  -			// (indexed properties) or element types
  -			// 3) Don't register types that are not referenced
  -			// or only referenced in a literal context.
  -			if (((type.getBaseType() != null) && (type.getRefType() == null))
  -					|| (type instanceof CollectionTE)
  -					|| (type instanceof Element) || !type.isReferenced()
  -					|| type.isOnlyLiteralReferenced()) {
  -				process = false;
  -			}
  -
  -			if (process) {
  -				String namespaceURI = type.getQName().getNamespaceURI();
  -				String localPart = type.getQName().getLocalPart();
  -				String javaType = type.getName();
  -				String serializerFactory;
  -				String deserializerFactory;
  -				String encodingStyle = "";
  -
  -				if (!hasLiteral) {
  -					encodingStyle = use.getEncoding();
  -				}
  -
  -				if (javaType.endsWith("[]")) {
  -					if (SchemaUtils.isListWithItemType(type.getNode())) {
  -						serializerFactory =
  -						"org.apache.axis.encoding.ser.SimpleListSerializerFactory";
  -						deserializerFactory =
  -						"org.apache.axis.encoding.ser.SimpleListDeserializerFactory";
  -					} else {
  -						serializerFactory =
  -						"org.apache.axis.encoding.ser.ArraySerializerFactory";
  -						deserializerFactory =
  -						"org.apache.axis.encoding.ser.ArrayDeserializerFactory";
  -					}
  -				} else if ((type.getNode() != null) && (Utils.getEnumerationBaseAndValues(
  -						type.getNode(), symbolTable) != null)) {
  -					serializerFactory =
  -							"org.apache.axis.encoding.ser.EnumSerializerFactory";
  -					deserializerFactory =
  -							"org.apache.axis.encoding.ser.EnumDeserializerFactory";
  -				} else if (type.isSimpleType()) {
  -					serializerFactory =
  -							"org.apache.axis.encoding.ser.SimpleSerializerFactory";
  -					deserializerFactory =
  -							"org.apache.axis.encoding.ser.SimpleDeserializerFactory";
  -				} else if (type.getBaseType() != null) {
  -					serializerFactory =
  -							"org.apache.axis.encoding.ser.SimpleSerializerFactory";
  -					deserializerFactory =
  -							"org.apache.axis.encoding.ser.SimpleDeserializerFactory";
  -				} else {
  -					serializerFactory =
  -							"org.apache.axis.encoding.ser.BeanSerializerFactory";
  -					deserializerFactory =
  -							"org.apache.axis.encoding.ser.BeanDeserializerFactory";
  -				}
  -
  -				writeTypeMapping(pw, namespaceURI, localPart, javaType,
  -						serializerFactory, deserializerFactory,
  -						encodingStyle);
  -			}
  -		}
  -	}    // writeDeployTypes
  -
  -	/**
  -	 * Raw routine that writes out the typeMapping.
  -	 * 
  -	 * @param pw                  
  -	 * @param namespaceURI        
  -	 * @param localPart           
  -	 * @param javaType            
  -	 * @param serializerFactory   
  -	 * @param deserializerFactory 
  -	 * @param encodingStyle       
  -	 * @throws IOException 
  -	 */
  -	protected void writeTypeMapping(
  -			PrintWriter pw, String namespaceURI, String localPart, String javaType, String serializerFactory, String deserializerFactory, String encodingStyle)
  -			throws IOException {
  -
  -		pw.println("      <typeMapping");
  -		pw.println("        xmlns:ns=\"" + namespaceURI + "\"");
  -		pw.println("        qname=\"ns:" + localPart + '"');
  -		pw.println("        type=\"java:" + javaType + '"');
  -		pw.println("        serializer=\"" + serializerFactory + "\"");
  -		pw.println("        deserializer=\"" + deserializerFactory + "\"");
  -		pw.println("        encodingStyle=\"" + encodingStyle + "\"");
  -		pw.println("      />");
  -	}
  -
  -	/**
  -	 * Write out deployment and undeployment instructions for given WSDL port
  -	 * 
  -	 * @param pw      
  -	 * @param port    
  -	 * @param service 
  -	 * @param bEntry  
  -	 * @throws IOException 
  -	 */
  -	protected void writeDeployPort(
  -			PrintWriter pw, Port port, Service service, BindingEntry bEntry)
  -			throws IOException {
  -
  -		String serviceName = port.getName();
  -		boolean hasLiteral = bEntry.hasLiteral();
  -		boolean hasMIME = Utils.hasMIME(bEntry);
  -		String prefix = WSDDConstants.NS_PREFIX_WSDD_JAVA;
  -		String styleStr = "";
  -		Use use = Use.DEFAULT;
  -		Iterator iterator =
  -				bEntry.getBinding().getExtensibilityElements().iterator();
  -
  -		//get the Name of the provider needed in the deploy.wsdd
  -		String provider = null;
  -		provider = GenerationConstants.WS4J2EE_PROVIDER; 
  -
  -		while (iterator.hasNext()) {
  -			Object obj = iterator.next();
  -
  -			if (obj instanceof SOAPBinding) {
  -				use = Use.ENCODED;
  -			} else if (obj instanceof UnknownExtensibilityElement) {
  -
  -				// TODO: After WSDL4J supports soap12, change this code
  -				UnknownExtensibilityElement unkElement =
  -						(UnknownExtensibilityElement) obj;
  -				QName name =
  -						unkElement.getElementType();
  -
  -				if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP)
  -						&& name.getLocalPart().equals("binding")) {
  -					use = Use.ENCODED;
  -				}
  -			}
  -		}
  -
  -		if (symbolTable.isWrapped()) {
  -			styleStr = " style=\"" + Style.WRAPPED + "\"";
  -			use = Use.LITERAL;
  -		} else {
  -			styleStr = " style=\"" + bEntry.getBindingStyle().getName() + "\"";
  -
  -			if (hasLiteral) {
  -				use = Use.LITERAL;
  -			}
  -		}
  -
  -		String useStr = " use=\"" + use + "\"";
  -//		if(provider!= null){
  -//			pw.println("  <service name=\"" + serviceName + "\" provider=\""
  -//					+ provider + "\"" + styleStr + useStr + ">");
  -//			WSCFHandler[] handlers = wscontext.getMiscInfo().getHandlers();	
  -//			for(int i = 0;i<handlers.length;i++){
  -//				writeHandler(pw,handlers[i]);
  -//			}	
  -//		}else{
  -//			pw.println("  <service name=\"" + serviceName + "\" provider=\""
  -//					+ prefix + ":RPC" + "\"" + styleStr + useStr + ">");
  -//		}
  -		pw.println("  <service name=\"" + serviceName + "\" provider=\"java:j2ee\"" 
  -			+ styleStr + useStr + ">");
  -
  -		pw.println("      <parameter name=\"wsdlTargetNamespace\" value=\""
  -				+ service.getQName().getNamespaceURI() + "\"/>");
  -		pw.println("      <parameter name=\"wsdlServiceElement\" value=\""
  -				+ service.getQName().getLocalPart() + "\"/>");
  -		pw.println("      <parameter name=\"wsdlServicePort\" value=\""
  -				+ serviceName + "\"/>");
  -
  -		// MIME attachments don't work with multiref, so turn it off.
  -		if (hasMIME) {
  -			pw.println(
  -					"      <parameter name=\"sendMultiRefs\" value=\"false\"/>");
  -		}
  -
  -		writeDeployBinding(pw, bEntry);
  -		writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME, use);
  -		
  -		WSCFHandler[] handlers = this.wscontext.getMiscInfo().getHandlers();
  -		if(handlers != null){
  -			for(int i = 0;i<handlers.length;i++){
  -				writeHandler(pw,handlers[i]);
  -			}	
  -		}	
  -		pw.println("  </service>");
  -	}    // writeDeployPort
  -
  -	/**
  -	 * Write out deployment instructions for given WSDL binding
  -	 * 
  -	 * @param pw     
  -	 * @param bEntry 
  -	 * @throws IOException 
  -	 */
  -	protected void writeDeployBinding(PrintWriter pw, BindingEntry bEntry)
  -			throws IOException {
  -
  -		Binding binding = bEntry.getBinding();
  -		String className = bEntry.getName();
  -
  -		if (emitter.isSkeletonWanted()) {
  -			className += "Skeleton";
  -		} else {
  -			className += "Impl";
  -		}
  -
  -		pw.println("      <parameter name=\"className\" value=\"" + className
  -				+ "\"/>");
  -		pw.println("      <parameter name=\"wsdlPortType\" value=\""
  -				+ binding.getPortType().getQName().getLocalPart() + "\"/>");
  -
  -		HashSet allowedMethods = new HashSet();
  -
  -		if (!emitter.isSkeletonWanted()) {
  -			Iterator operationsIterator =
  -					binding.getBindingOperations().iterator();
  -
  -			for (; operationsIterator.hasNext();) {
  -				BindingOperation bindingOper =
  -						(BindingOperation) operationsIterator.next();
  -				Operation operation = bindingOper.getOperation();
  -				OperationType type = operation.getStyle();
  -				String javaOperName =
  -						JavaUtils.xmlNameToJava(operation.getName());
  -
  -				// These operation types are not supported.  The signature
  -				// will be a string stating that fact.
  -				if ((type == OperationType.NOTIFICATION)
  -						|| (type == OperationType.SOLICIT_RESPONSE)) {
  -					continue;
  -				}
  -
  -				allowedMethods.add(javaOperName);
  -
  -				// We pass "" as the namespace argument because we're just
  -				// interested in the return type for now.
  -				Parameters params =
  -						symbolTable.getOperationParameters(operation, "", bEntry);
  -
  -				if (params != null) {
  -
  -					// Get the operation QName
  -					QName elementQName = Utils.getOperationQName(bindingOper,
  -							bEntry, symbolTable);
  -
  -					// Get the operation's return QName and type
  -					QName returnQName = null;
  -					QName returnType = null;
  -
  -					if (params.returnParam != null) {
  -						returnQName = params.returnParam.getQName();
  -						returnType = Utils.getXSIType(params.returnParam);
  -					}
  -
  -					// Get the operations faults
  -					Map faultMap = bEntry.getFaults();
  -					ArrayList faults = null;
  -
  -					if (faultMap != null) {
  -						faults = (ArrayList) faultMap.get(bindingOper);
  -					}
  -
  -					// Write the operation metadata
  -					writeOperation(pw, javaOperName, elementQName, returnQName,
  -							returnType, params, binding.getQName(),
  -							faults);
  -				}
  -			}
  -		}
  -
  -		pw.print("      <parameter name=\"allowedMethods\" value=\"");
  -
  -		if (allowedMethods.isEmpty()) {
  -			pw.println("*\"/>");
  -		} else {
  -			boolean first = true;
  -
  -			for (Iterator i = allowedMethods.iterator(); i.hasNext();) {
  -				String method = (String) i.next();
  -
  -				if (first) {
  -					pw.print(method);
  -
  -					first = false;
  -				} else {
  -					pw.print(" " + method);
  -				}
  -			}
  -
  -			pw.println("\"/>");
  -		}
  -
  -		Scope scope = emitter.getScope();
  -
  -		if (scope != null) {
  -			pw.println("      <parameter name=\"scope\" value=\""
  -					+ scope.getName() + "\"/>");
  -		}
  -	}    // writeDeployBinding
  -
  -	/**
  -	 * Raw routine that writes out the operation and parameters.
  -	 * 
  -	 * @param pw           
  -	 * @param javaOperName 
  -	 * @param elementQName 
  -	 * @param returnQName  
  -	 * @param returnType   
  -	 * @param params       
  -	 * @param bindingQName 
  -	 * @param faults       
  -	 */
  -	protected void writeOperation(PrintWriter pw, String javaOperName,
  -								  QName elementQName, QName returnQName,
  -								  QName returnType, Parameters params,
  -								  QName bindingQName, ArrayList faults) {
  -
  -		pw.print("      <operation name=\"" + javaOperName + "\"");
  -
  -		if (elementQName != null) {
  -			pw.print(" qname=\""
  -					+ Utils.genQNameAttributeString(elementQName, "operNS")
  -					+ "\"");
  -		}
  -
  -		if (returnQName != null) {
  -			pw.print(" returnQName=\""
  -					+ Utils.genQNameAttributeStringWithLastLocalPart(returnQName, "retNS")
  -					+ "\"");
  -		}
  -
  -		if (returnType != null) {
  -			pw.print(" returnType=\""
  -					+ Utils.genQNameAttributeString(returnType, "rtns")
  -					+ "\"");
  -		}
  -
  -		if ((params.returnParam != null) && params.returnParam.isOutHeader()) {
  -			pw.print(" returnHeader=\"true\"");
  -		}
  -
  -		pw.println(" >");
  -
  -		Vector paramList = params.list;
  -
  -		for (int i = 0; i < paramList.size(); i++) {
  -			Parameter param = (Parameter) paramList.elementAt(i);
  -
  -			// Get the parameter name QName and type QName
  -			QName paramQName = param.getQName();
  -			QName paramType = Utils.getXSIType(param);
  -
  -			pw.print("        <parameter");
  -
  -			if ((paramQName == null)
  -					|| "".equals(paramQName.getNamespaceURI())) {
  -				pw.print(" name=\"" + param.getName() + "\"");
  -			} else {
  -				pw.print(" qname=\""
  -						+ Utils.genQNameAttributeStringWithLastLocalPart(paramQName, "pns")
  -						+ "\"");
  -			}
  -
  -			pw.print(" type=\""
  -					+ Utils.genQNameAttributeString(paramType, "tns") + "\"");
  -
  -			// Get the parameter mode
  -			if (param.getMode() != Parameter.IN) {
  -				pw.print(" mode=\"" + getModeString(param.getMode()) + "\"");
  -			}
  -
  -			// Is this a header?
  -			if (param.isInHeader()) {
  -				pw.print(" inHeader=\"true\"");
  -			}
  -
  -			if (param.isOutHeader()) {
  -				pw.print(" outHeader=\"true\"");
  -			}
  -
  -			pw.println("/>");
  -		}
  -
  -		if (faults != null) {
  -			for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
  -				FaultInfo faultInfo = (FaultInfo) iterator.next();
  -				QName faultQName = faultInfo.getQName();
  -
  -				if (faultQName != null) {
  -					String className =
  -							Utils.getFullExceptionName(faultInfo.getMessage(),
  -									symbolTable);
  -
  -					pw.print("        <fault");
  -					pw.print(" name=\"" + faultInfo.getName() + "\"");
  -					pw.print(" qname=\""
  -							+ Utils.genQNameAttributeString(faultQName, "fns")
  -							+ "\"");
  -					pw.print(" class=\"" + className + "\"");
  -					pw.print(
  -							" type=\""
  -							+ Utils.genQNameAttributeString(
  -									faultInfo.getXMLType(), "tns") + "\"");
  -					pw.println("/>");
  -				}
  -			}
  -		}
  -
  -		pw.println("      </operation>");
  -	}
  -
  -	/**
  -	 * Method getModeString
  -	 * 
  -	 * @param mode 
  -	 * @return 
  -	 */
  -	public String getModeString(byte mode) {
  -
  -		if (mode == Parameter.IN) {
  -			return "IN";
  -		} else if (mode == Parameter.INOUT) {
  -			return "INOUT";
  -		} else {
  -			return "OUT";
  -		}
  -	}
  -
  -	/**
  -	 * Method getPrintWriter
  -	 * 
  -	 * @param filename 
  -	 * @return 
  -	 * @throws IOException 
  -	 */
  -	protected PrintWriter getPrintWriter(String filename) throws IOException {
  -
  -		File file = new File(filename);
  -		File parent = new File(file.getParent());
  -
  -		parent.mkdirs();
  -
  -		FileOutputStream out = new FileOutputStream(file);
  -		OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
  -
  -		return new PrintWriter(writer);
  -	}
  -	
  -	private void writeHandler(PrintWriter pw,WSCFHandler handler){
  -		System.out.println("handler written");
  -		pw.println("      <handler name=\""+handler.getHandlerName()+"\"type=\""+handler.getHandlerClass()+"\">");
  -		WSCFInitParam[] param = handler.getInitParam();
  -		for(int i = 0;i<param.length;i++){
  -			pw.println("      <parameter name=\""+param[i].getParamName()+"\" value=\""+param[i].getParamValue()+"\"/>");
  -		}
  -		//TODO handle soap role and soaphandlers 
  -		pw.println("      </handler>");
  -	}
  -}    // class JavaDeployWriter
  +/*
  + * Copyright 2001-2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +package org.apache.geronimo.ews.ws4j2ee.toWs.ws;
  +
  +import java.io.File;
  +import java.io.FileOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStreamWriter;
  +import java.io.PrintWriter;
  +import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.Vector;
  +
  +import javax.wsdl.Binding;
  +import javax.wsdl.BindingOperation;
  +import javax.wsdl.Definition;
  +import javax.wsdl.Operation;
  +import javax.wsdl.OperationType;
  +import javax.wsdl.Port;
  +import javax.wsdl.Service;
  +import javax.wsdl.extensions.UnknownExtensibilityElement;
  +import javax.wsdl.extensions.soap.SOAPBinding;
  +import javax.xml.namespace.QName;
  +
  +import org.apache.axis.Constants;
  +import org.apache.axis.deployment.wsdd.WSDDConstants;
  +import org.apache.axis.enum.Scope;
  +import org.apache.axis.enum.Style;
  +import org.apache.axis.enum.Use;
  +import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.Messages;
  +import org.apache.axis.wsdl.symbolTable.BindingEntry;
  +import org.apache.axis.wsdl.symbolTable.CollectionTE;
  +import org.apache.axis.wsdl.symbolTable.Element;
  +import org.apache.axis.wsdl.symbolTable.FaultInfo;
  +import org.apache.axis.wsdl.symbolTable.Parameter;
  +import org.apache.axis.wsdl.symbolTable.Parameters;
  +import org.apache.axis.wsdl.symbolTable.SchemaUtils;
  +import org.apache.axis.wsdl.symbolTable.SymbolTable;
  +import org.apache.axis.wsdl.symbolTable.TypeEntry;
  +import org.apache.axis.wsdl.toJava.Emitter;
  +import org.apache.axis.wsdl.toJava.JavaWriter;
  +import org.apache.axis.wsdl.toJava.Utils;
  +import org.apache.geronimo.ews.jaxrpcmapping.J2eeEmitter;
  +import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
  +import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
  +import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
  +import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFHandler;
  +import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFInitParam;
  +import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
  +
  +/**
  + * This is Wsdl2java's deploy Writer.  It writes the deploy.wsdd file.
  + */
  +public class J2eeDeployWriter  extends JavaWriter{
  +	protected boolean useProvider = false;
  +	/** Field definition */
  +	protected Definition definition;
  +
  +	/** Field symbolTable */
  +	protected SymbolTable symbolTable;
  +	protected J2EEWebServiceContext wscontext;
  +
  +	/**
  +	 * Constructor.
  +	 * 
  +	 * @param emitter     
  +	 * @param definition  
  +	 * @param symbolTable 
  +	 */
  +	public J2eeDeployWriter(Emitter emitter, Definition definition,
  +							SymbolTable symbolTable) {
  +
  +		super(emitter, "deploy");
  +        this.definition = definition;
  +		this.symbolTable = symbolTable;
  +		wscontext =((J2eeEmitter)emitter).getWscontext();
  +		if(wscontext == null){
  +			throw new RuntimeException("wscontext can not be null");
  +		} 
  +	}    // ctor
  +
  +	/**
  +	 * Generate deploy.wsdd.  Only generate it if the emitter
  +	 * is generating server-side mappings.
  +	 * 
  +	 * @throws IOException 
  +	 */
  +	public void generate() throws IOException {
  +
  +		if (emitter.isServerSide()) {
  +			super.generate();
  +		}
  +	}    // generate
  +	
  +
  +	/**
  +	 * Return the fully-qualified name of the deploy.wsdd file
  +	 * to be generated.
  +	 * 
  +	 * @return 
  +	 */
  +	protected String getFileName() {
  +//		String dir =
  +//				emitter.getNamespaces().getAsDir(definition.getTargetNamespace());
  +		String dir =
  +				emitter.getNamespaces().getAsDir("");
  +		return dir + "deploy.wsdd"; 
  +	}    // getFileName
  +
  +	/**
  +	 * Replace the default file header with the deployment doc file header.
  +	 * 
  +	 * @param pw 
  +	 * @throws IOException 
  +	 */
  +	protected void writeFileHeader(PrintWriter pw) throws IOException {
  +
  +		pw.println(Messages.getMessage("deploy00"));
  +		pw.println(Messages.getMessage("deploy02"));
  +		pw.println(Messages.getMessage("deploy03"));
  +		pw.println(Messages.getMessage("deploy05"));
  +		pw.println(Messages.getMessage("deploy06"));
  +		pw.println(Messages.getMessage("deploy07"));
  +		pw.println(Messages.getMessage("deploy09"));
  +		pw.println();
  +		pw.println("<deployment");
  +		pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD + "\"");
  +		pw.println("    xmlns:" + WSDDConstants.NS_PREFIX_WSDD_JAVA + "=\""
  +				+ WSDDConstants.URI_WSDD_JAVA + "\">");
  +	}    // writeFileHeader
  +
  +	/**
  +	 * Write the body of the deploy.wsdd file.
  +	 * 
  +	 * @param pw 
  +	 * @throws IOException 
  +	 */
  +	protected void writeFileBody(PrintWriter pw) throws IOException {
  +		writeDeployServices(pw);
  +		pw.println("</deployment>");
  +	}    // writeFileBody
  +
  +	/**
  +	 * Write out deployment and undeployment instructions for each WSDL service
  +	 * 
  +	 * @param pw 
  +	 * @throws IOException 
  +	 */
  +	protected void writeDeployServices(PrintWriter pw) throws IOException {
  +
  +		// deploy the ports on each service
  +		Map serviceMap = definition.getServices();
  +
  +		for (Iterator mapIterator = serviceMap.values().iterator();
  +			 mapIterator.hasNext();) {
  +			Service myService = (Service) mapIterator.next();
  +
  +			pw.println();
  +			pw.println(
  +					"  <!-- "
  +					+ Messages.getMessage(
  +							"wsdlService00", myService.getQName().getLocalPart()) + " -->");
  +			pw.println();
  +
  +			for (Iterator portIterator = myService.getPorts().values().iterator();
  +				 portIterator.hasNext();) {
  +				Port myPort = (Port) portIterator.next();
  +				BindingEntry bEntry =
  +						symbolTable.getBindingEntry(myPort.getBinding().getQName());
  +
  +				// If this isn't an SOAP binding, skip it
  +				if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
  +					continue;
  +				}
  +
  +				writeDeployPort(pw, myPort, myService, bEntry);
  +			}
  +		}
  +	}    // writeDeployServices
  +
  +	/**
  +	 * Write out bean mappings for each type
  +	 * 
  +	 * @param pw         
  +	 * @param binding    
  +	 * @param hasLiteral 
  +	 * @param hasMIME    
  +	 * @param use        
  +	 * @throws IOException 
  +	 */
  +	protected void writeDeployTypes(
  +			PrintWriter pw, Binding binding, boolean hasLiteral, boolean hasMIME, Use use)
  +			throws IOException {
  +
  +		pw.println();
  +
  +		if (hasMIME) {
  +			QName bQName = binding.getQName();
  +
  +			writeTypeMapping(
  +					pw, bQName.getNamespaceURI(), "DataHandler",
  +					"javax.activation.DataHandler",
  +					"org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory",
  +					"org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory",
  +					use.getEncoding());
  +		}
  +
  +		Map types = symbolTable.getTypeIndex();
  +		Collection typeCollection = types.values();
  +		for (Iterator i = typeCollection.iterator(); i.hasNext(); ) {
  +			TypeEntry type = (TypeEntry) i.next();
  +
  +			// Note this same check is repeated in JavaStubWriter.
  +			boolean process = true;
  +
  +			// 1) Don't register types that are base (primitive) types.
  +			// If the baseType != null && getRefType() != null this
  +			// is a simpleType that must be registered.
  +			// 2) Don't register the special types for collections
  +			// (indexed properties) or element types
  +			// 3) Don't register types that are not referenced
  +			// or only referenced in a literal context.
  +			if (((type.getBaseType() != null) && (type.getRefType() == null))
  +					|| (type instanceof CollectionTE)
  +					|| (type instanceof Element) || !type.isReferenced()
  +					|| type.isOnlyLiteralReferenced()) {
  +				process = false;
  +			}
  +
  +			if (process) {
  +				String namespaceURI = type.getQName().getNamespaceURI();
  +				String localPart = type.getQName().getLocalPart();
  +				String javaType = type.getName();
  +				String serializerFactory;
  +				String deserializerFactory;
  +				String encodingStyle = "";
  +
  +				if (!hasLiteral) {
  +					encodingStyle = use.getEncoding();
  +				}
  +
  +				if (javaType.endsWith("[]")) {
  +					if (SchemaUtils.isListWithItemType(type.getNode())) {
  +						serializerFactory =
  +						"org.apache.axis.encoding.ser.SimpleListSerializerFactory";
  +						deserializerFactory =
  +						"org.apache.axis.encoding.ser.SimpleListDeserializerFactory";
  +					} else {
  +						serializerFactory =
  +						"org.apache.axis.encoding.ser.ArraySerializerFactory";
  +						deserializerFactory =
  +						"org.apache.axis.encoding.ser.ArrayDeserializerFactory";
  +					}
  +				} else if ((type.getNode() != null) && (Utils.getEnumerationBaseAndValues(
  +						type.getNode(), symbolTable) != null)) {
  +					serializerFactory =
  +							"org.apache.axis.encoding.ser.EnumSerializerFactory";
  +					deserializerFactory =
  +							"org.apache.axis.encoding.ser.EnumDeserializerFactory";
  +				} else if (type.isSimpleType()) {
  +					serializerFactory =
  +							"org.apache.axis.encoding.ser.SimpleSerializerFactory";
  +					deserializerFactory =
  +							"org.apache.axis.encoding.ser.SimpleDeserializerFactory";
  +				} else if (type.getBaseType() != null) {
  +					serializerFactory =
  +							"org.apache.axis.encoding.ser.SimpleSerializerFactory";
  +					deserializerFactory =
  +							"org.apache.axis.encoding.ser.SimpleDeserializerFactory";
  +				} else {
  +					serializerFactory =
  +							"org.apache.axis.encoding.ser.BeanSerializerFactory";
  +					deserializerFactory =
  +							"org.apache.axis.encoding.ser.BeanDeserializerFactory";
  +				}
  +
  +				writeTypeMapping(pw, namespaceURI, localPart, javaType,
  +						serializerFactory, deserializerFactory,
  +						encodingStyle);
  +			}
  +		}
  +	}    // writeDeployTypes
  +
  +	/**
  +	 * Raw routine that writes out the typeMapping.
  +	 * 
  +	 * @param pw                  
  +	 * @param namespaceURI        
  +	 * @param localPart           
  +	 * @param javaType            
  +	 * @param serializerFactory   
  +	 * @param deserializerFactory 
  +	 * @param encodingStyle       
  +	 * @throws IOException 
  +	 */
  +	protected void writeTypeMapping(
  +			PrintWriter pw, String namespaceURI, String localPart, String javaType, String serializerFactory, String deserializerFactory, String encodingStyle)
  +			throws IOException {
  +
  +		pw.println("      <typeMapping");
  +		pw.println("        xmlns:ns=\"" + namespaceURI + "\"");
  +		pw.println("        qname=\"ns:" + localPart + '"');
  +		pw.println("        type=\"java:" + javaType + '"');
  +		pw.println("        serializer=\"" + serializerFactory + "\"");
  +		pw.println("        deserializer=\"" + deserializerFactory + "\"");
  +		pw.println("        encodingStyle=\"" + encodingStyle + "\"");
  +		pw.println("      />");
  +	}
  +
  +	/**
  +	 * Write out deployment and undeployment instructions for given WSDL port
  +	 * 
  +	 * @param pw      
  +	 * @param port    
  +	 * @param service 
  +	 * @param bEntry  
  +	 * @throws IOException 
  +	 */
  +	protected void writeDeployPort(
  +			PrintWriter pw, Port port, Service service, BindingEntry bEntry)
  +			throws IOException {
  +
  +		String serviceName = port.getName();
  +		boolean hasLiteral = bEntry.hasLiteral();
  +		boolean hasMIME = Utils.hasMIME(bEntry);
  +		String prefix = WSDDConstants.NS_PREFIX_WSDD_JAVA;
  +		String styleStr = "";
  +		Use use = Use.DEFAULT;
  +		Iterator iterator =
  +				bEntry.getBinding().getExtensibilityElements().iterator();
  +
  +		//get the Name of the provider needed in the deploy.wsdd
  +		String provider = null;
  +		provider = GenerationConstants.WS4J2EE_PROVIDER; 
  +
  +		while (iterator.hasNext()) {
  +			Object obj = iterator.next();
  +
  +			if (obj instanceof SOAPBinding) {
  +				use = Use.ENCODED;
  +			} else if (obj instanceof UnknownExtensibilityElement) {
  +
  +				// TODO: After WSDL4J supports soap12, change this code
  +				UnknownExtensibilityElement unkElement =
  +						(UnknownExtensibilityElement) obj;
  +				QName name =
  +						unkElement.getElementType();
  +
  +				if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP)
  +						&& name.getLocalPart().equals("binding")) {
  +					use = Use.ENCODED;
  +				}
  +			}
  +		}
  +
  +		if (symbolTable.isWrapped()) {
  +			styleStr = " style=\"" + Style.WRAPPED + "\"";
  +			use = Use.LITERAL;
  +		} else {
  +			styleStr = " style=\"" + bEntry.getBindingStyle().getName() + "\"";
  +
  +			if (hasLiteral) {
  +				use = Use.LITERAL;
  +			}
  +		}
  +
  +		String useStr = " use=\"" + use + "\"";
  +//		if(provider!= null){
  +//			pw.println("  <service name=\"" + serviceName + "\" provider=\""
  +//					+ provider + "\"" + styleStr + useStr + ">");
  +//			WSCFHandler[] handlers = wscontext.getMiscInfo().getHandlers();	
  +//			for(int i = 0;i<handlers.length;i++){
  +//				writeHandler(pw,handlers[i]);
  +//			}	
  +//		}else{
  +//			pw.println("  <service name=\"" + serviceName + "\" provider=\""
  +//					+ prefix + ":RPC" + "\"" + styleStr + useStr + ">");
  +//		}
  +        if(useProvider){
  +            String continer = wscontext.getMiscInfo().getTargetJ2EEContainer();
  +            if(GenerationConstants.GERONIMO_CONTAINER.equals(continer)){
  +                pw.println("  <service name=\"" + serviceName + "\" provider=\"java:geronimo\"" 
  +                    + styleStr + useStr + ">");
  +            }else{
  +                pw.println("  <service name=\"" + serviceName + "\" provider=\"java:ews\"" 
  +                    + styleStr + useStr + ">");
  +            }
  +        }else{
  +            pw.println("  <service name=\"" + serviceName + "\" provider=\"java:j2ee\"" 
  +                + styleStr + useStr + ">");
  +        }
  +        EJBContext ejbcontext = wscontext.getEJBDDContext();
  +        if(ejbcontext != null){
  +            if(ejbcontext.getEjbhomeInterface()!= null){
  +                pw.println("      <parameter name=\"homeInterfaceName\" value=\""
  +                    + ejbcontext.getEjbhomeInterface() + "\"/>");
  +            }
  +            if(ejbcontext.getEjbRemoteInterface()!= null){
  +                pw.println("      <parameter name=\"remoteInterfaceName\" value=\""
  +                    + ejbcontext.getEjbRemoteInterface() + "\"/>");
  +            }
  +            if(ejbcontext.getEjbLocalHomeInterfce()!= null){
  +                pw.println("      <parameter name=\"localHomeInterfaceName\" value=\""
  +                    + ejbcontext.getEjbLocalHomeInterfce() + "\"/>");
  +            }
  +            if(ejbcontext.getEjbLocalInterface()!= null){
  +                pw.println("      <parameter name=\"localInterfaceName\" value=\""
  +                    + ejbcontext.getEjbLocalInterface() + "\"/>");
  +            }
  +            if(ejbcontext.getEjbRemoteInterface()!= null){
  +                pw.println("      <parameter name=\"beanJndiName\" value=\""
  +                    + "ejb/"+ejbcontext.getEjbName() + "\"/>");
  +            }
  +            if(ejbcontext.getEjbRemoteInterface()!= null){
  +                pw.println("      <parameter name=\"beanName\" value=\""
  +                    + ejbcontext.getEjbName() + "\"/>");
  +            }
  +        }
  +		pw.println("      <parameter name=\"wsdlTargetNamespace\" value=\""
  +				+ service.getQName().getNamespaceURI() + "\"/>");
  +		pw.println("      <parameter name=\"wsdlServiceElement\" value=\""
  +				+ service.getQName().getLocalPart() + "\"/>");
  +		pw.println("      <parameter name=\"wsdlServicePort\" value=\""
  +				+ serviceName + "\"/>");
  +
  +		// MIME attachments don't work with multiref, so turn it off.
  +		if (hasMIME) {
  +			pw.println(
  +					"      <parameter name=\"sendMultiRefs\" value=\"false\"/>");
  +		}
  +
  +		writeDeployBinding(pw, bEntry);
  +		writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME, use);
  +		
  +		WSCFHandler[] handlers = this.wscontext.getMiscInfo().getHandlers();
  +		if(handlers != null){
  +			for(int i = 0;i<handlers.length;i++){
  +				writeHandler(pw,handlers[i]);
  +			}	
  +		}	
  +		pw.println("  </service>");
  +	}    // writeDeployPort
  +
  +	/**
  +	 * Write out deployment instructions for given WSDL binding
  +	 * 
  +	 * @param pw     
  +	 * @param bEntry 
  +	 * @throws IOException 
  +	 */
  +	protected void writeDeployBinding(PrintWriter pw, BindingEntry bEntry)
  +			throws IOException {
  +
  +		Binding binding = bEntry.getBinding();
  +		String className = bEntry.getName();
  +
  +		if (emitter.isSkeletonWanted()) {
  +			className += "Skeleton";
  +		} else {
  +			className += "Impl";
  +		}
  +
  +        
  +        if(useProvider){
  +            WebContext webContext = wscontext.getWebDDContext();
  +            if(webContext != null){
  +                pw.println("      <parameter name=\"className\" value=\"" + webContext.getServletClass()
  +                        + "\"/>");
  +            }
  +        }else{
  +            pw.println("      <parameter name=\"className\" value=\"" + className
  +                    + "\"/>");
  +        }
  +                
  +		pw.println("      <parameter name=\"wsdlPortType\" value=\""
  +				+ binding.getPortType().getQName().getLocalPart() + "\"/>");
  +
  +		HashSet allowedMethods = new HashSet();
  +
  +		if (!emitter.isSkeletonWanted()) {
  +			Iterator operationsIterator =
  +					binding.getBindingOperations().iterator();
  +
  +			for (; operationsIterator.hasNext();) {
  +				BindingOperation bindingOper =
  +						(BindingOperation) operationsIterator.next();
  +				Operation operation = bindingOper.getOperation();
  +				OperationType type = operation.getStyle();
  +				String javaOperName =
  +						JavaUtils.xmlNameToJava(operation.getName());
  +
  +				// These operation types are not supported.  The signature
  +				// will be a string stating that fact.
  +				if ((type == OperationType.NOTIFICATION)
  +						|| (type == OperationType.SOLICIT_RESPONSE)) {
  +					continue;
  +				}
  +
  +				allowedMethods.add(javaOperName);
  +
  +				// We pass "" as the namespace argument because we're just
  +				// interested in the return type for now.
  +				Parameters params =
  +						symbolTable.getOperationParameters(operation, "", bEntry);
  +
  +				if (params != null) {
  +
  +					// Get the operation QName
  +					QName elementQName = Utils.getOperationQName(bindingOper,
  +							bEntry, symbolTable);
  +
  +					// Get the operation's return QName and type
  +					QName returnQName = null;
  +					QName returnType = null;
  +
  +					if (params.returnParam != null) {
  +						returnQName = params.returnParam.getQName();
  +						returnType = Utils.getXSIType(params.returnParam);
  +					}
  +
  +					// Get the operations faults
  +					Map faultMap = bEntry.getFaults();
  +					ArrayList faults = null;
  +
  +					if (faultMap != null) {
  +						faults = (ArrayList) faultMap.get(bindingOper);
  +					}
  +
  +					// Write the operation metadata
  +					writeOperation(pw, javaOperName, elementQName, returnQName,
  +							returnType, params, binding.getQName(),
  +							faults);
  +				}
  +			}
  +		}
  +
  +		pw.print("      <parameter name=\"allowedMethods\" value=\"");
  +
  +		if (allowedMethods.isEmpty()) {
  +			pw.println("*\"/>");
  +		} else {
  +			boolean first = true;
  +
  +			for (Iterator i = allowedMethods.iterator(); i.hasNext();) {
  +				String method = (String) i.next();
  +
  +				if (first) {
  +					pw.print(method);
  +
  +					first = false;
  +				} else {
  +					pw.print(" " + method);
  +				}
  +			}
  +
  +			pw.println("\"/>");
  +		}
  +
  +		Scope scope = emitter.getScope();
  +
  +		if (scope != null) {
  +			pw.println("      <parameter name=\"scope\" value=\""
  +					+ scope.getName() + "\"/>");
  +		}
  +	}    // writeDeployBinding
  +
  +	/**
  +	 * Raw routine that writes out the operation and parameters.
  +	 * 
  +	 * @param pw           
  +	 * @param javaOperName 
  +	 * @param elementQName 
  +	 * @param returnQName  
  +	 * @param returnType   
  +	 * @param params       
  +	 * @param bindingQName 
  +	 * @param faults       
  +	 */
  +	protected void writeOperation(PrintWriter pw, String javaOperName,
  +								  QName elementQName, QName returnQName,
  +								  QName returnType, Parameters params,
  +								  QName bindingQName, ArrayList faults) {
  +
  +		pw.print("      <operation name=\"" + javaOperName + "\"");
  +
  +		if (elementQName != null) {
  +			pw.print(" qname=\""
  +					+ Utils.genQNameAttributeString(elementQName, "operNS")
  +					+ "\"");
  +		}
  +
  +		if (returnQName != null) {
  +			pw.print(" returnQName=\""
  +					+ Utils.genQNameAttributeStringWithLastLocalPart(returnQName, "retNS")
  +					+ "\"");
  +		}
  +
  +		if (returnType != null) {
  +			pw.print(" returnType=\""
  +					+ Utils.genQNameAttributeString(returnType, "rtns")
  +					+ "\"");
  +		}
  +
  +		if ((params.returnParam != null) && params.returnParam.isOutHeader()) {
  +			pw.print(" returnHeader=\"true\"");
  +		}
  +
  +		pw.println(" >");
  +
  +		Vector paramList = params.list;
  +
  +		for (int i = 0; i < paramList.size(); i++) {
  +			Parameter param = (Parameter) paramList.elementAt(i);
  +
  +			// Get the parameter name QName and type QName
  +			QName paramQName = param.getQName();
  +			QName paramType = Utils.getXSIType(param);
  +
  +			pw.print("        <parameter");
  +
  +			if ((paramQName == null)
  +					|| "".equals(paramQName.getNamespaceURI())) {
  +				pw.print(" name=\"" + param.getName() + "\"");
  +			} else {
  +				pw.print(" qname=\""
  +						+ Utils.genQNameAttributeStringWithLastLocalPart(paramQName, "pns")
  +						+ "\"");
  +			}
  +
  +			pw.print(" type=\""
  +					+ Utils.genQNameAttributeString(paramType, "tns") + "\"");
  +
  +			// Get the parameter mode
  +			if (param.getMode() != Parameter.IN) {
  +				pw.print(" mode=\"" + getModeString(param.getMode()) + "\"");
  +			}
  +
  +			// Is this a header?
  +			if (param.isInHeader()) {
  +				pw.print(" inHeader=\"true\"");
  +			}
  +
  +			if (param.isOutHeader()) {
  +				pw.print(" outHeader=\"true\"");
  +			}
  +
  +			pw.println("/>");
  +		}
  +
  +		if (faults != null) {
  +			for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
  +				FaultInfo faultInfo = (FaultInfo) iterator.next();
  +				QName faultQName = faultInfo.getQName();
  +
  +				if (faultQName != null) {
  +					String className =
  +							Utils.getFullExceptionName(faultInfo.getMessage(),
  +									symbolTable);
  +
  +					pw.print("        <fault");
  +					pw.print(" name=\"" + faultInfo.getName() + "\"");
  +					pw.print(" qname=\""
  +							+ Utils.genQNameAttributeString(faultQName, "fns")
  +							+ "\"");
  +					pw.print(" class=\"" + className + "\"");
  +					pw.print(
  +							" type=\""
  +							+ Utils.genQNameAttributeString(
  +									faultInfo.getXMLType(), "tns") + "\"");
  +					pw.println("/>");
  +				}
  +			}
  +		}
  +
  +		pw.println("      </operation>");
  +	}
  +
  +	/**
  +	 * Method getModeString
  +	 * 
  +	 * @param mode 
  +	 * @return 
  +	 */
  +	public String getModeString(byte mode) {
  +
  +		if (mode == Parameter.IN) {
  +			return "IN";
  +		} else if (mode == Parameter.INOUT) {
  +			return "INOUT";
  +		} else {
  +			return "OUT";
  +		}
  +	}
  +
  +	/**
  +	 * Method getPrintWriter
  +	 * 
  +	 * @param filename 
  +	 * @return 
  +	 * @throws IOException 
  +	 */
  +	protected PrintWriter getPrintWriter(String filename) throws IOException {
  +
  +		File file = new File(filename);
  +		File parent = new File(file.getParent());
  +
  +		parent.mkdirs();
  +
  +		FileOutputStream out = new FileOutputStream(file);
  +		OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
  +
  +		return new PrintWriter(writer);
  +	}
  +	
  +	private void writeHandler(PrintWriter pw,WSCFHandler handler){
  +		System.out.println("handler written");
  +		pw.println("      <handler name=\""+handler.getHandlerName()+"\"type=\""+handler.getHandlerClass()+"\">");
  +		WSCFInitParam[] param = handler.getInitParam();
  +		for(int i = 0;i<param.length;i++){
  +			pw.println("      <parameter name=\""+param[i].getParamName()+"\" value=\""+param[i].getParamValue()+"\"/>");
  +		}
  +		//TODO handle soap role and soaphandlers 
  +		pw.println("      </handler>");
  +	}
  +}    // class JavaDeployWriter
  
  
  
  1.3       +103 -105  ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/wsutils/EWSProvider.java
  
  Index: EWSProvider.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/wsutils/EWSProvider.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EWSProvider.java	2 Sep 2004 13:03:13 -0000	1.2
  +++ EWSProvider.java	21 Sep 2004 04:46:59 -0000	1.3
  @@ -1,105 +1,103 @@
  -/*
  - * Copyright 2001-2004 The Apache Software Foundation.
  - * 
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - * 
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -package org.apache.geronimo.ews.ws4j2ee.wsutils;
  -
  -import java.io.InputStream;
  -import java.lang.reflect.Method;
  -
  -import org.apache.axis.AxisFault;
  -import org.apache.axis.MessageContext;
  -import org.apache.axis.providers.java.RPCProvider;
  -import org.apache.axis.utils.ClassUtils;
  -
  -/**
  - * register the MessageContext in the jax-rpc runtime of the JSR109 
  - * @author Srinath Perera(hemapani@opensource.lk)
  - */
  -public class EWSProvider extends RPCProvider{
  -    public static final String OPTION_BEANNAME = "beanJndiName";
  -    public static final String OPTION_HOMEINTERFACENAME = "homeInterfaceName";
  -    public static final String OPTION_REMOTEINTERFACENAME = "remoteInterfaceName";
  -    public static final String OPTION_LOCALHOMEINTERFACENAME = "localHomeInterfaceName";
  -    public static final String OPTION_LOCALINTERFACENAME = "localInterfaceName";
  -    
  -    public static final String OPTION_INITIAL_FACOTORY = "jndiContextClass";
  -    public static final String OPTION_JNDI_FACTORY = "jndiContextClass";
  -    public static final String OPTION_JNDI_URL = "jndiURL";
  -    public static final String OPTION_JNDI_USERNAME = "jndiUser";
  -    public static final String OPTION_JNDI_PASSWORD = "jndiPassword";
  -
  -    private String ejblookupName;
  -    private String localhome;
  -    private String home;
  -    private String remote;
  -    private String local;
  -    
  -    private String jndiUrl;
  -    private String jndiFactory;
  -    private String jndiUser;
  -    private String jndiPassword; 
  -    private boolean ejbbased = true;
  -
  -
  -    protected Object makeNewServiceObject(
  -        MessageContext msgContext,
  -        String clsName)
  -        throws Exception {
  -            if(ejbbased){
  -                java.util.Properties env = new java.util.Properties();
  -                InputStream jndiIn = getClass().getClassLoader().getResourceAsStream("jndi.properties");
  -                if(jndiIn != null){
  -                    env.load(jndiIn);
  -                }else{
  -                    env.setProperty("java.naming.factory.initial",(String)getOption(OPTION_INITIAL_FACOTORY));
  -                    env.setProperty("java.naming.factory.url.pkgs",(String)getOption(OPTION_JNDI_FACTORY));
  -                    env.setProperty("java.naming.provider.url",(String)getOption(OPTION_JNDI_URL));
  -                }
  -                javax.naming.Context initial = new javax.naming.InitialContext(env);
  -                if(remote != null && home != null && ejblookupName != null){
  -                    Object objref = initial.lookup(ejblookupName);
  -                    Class homeClass = ClassUtils.forName(home);
  -                    Object homeObj = javax.rmi.PortableRemoteObject.narrow(objref,homeClass);
  -                    Method method = homeClass.getMethod("create",new Class[]{}); 
  -                    return method.invoke(homeObj,new Object[]{});
  -                }else if(local != null && localhome != null && ejblookupName != null){
  -                    Object homeObj = initial.lookup("java:comp/"+ejblookupName);
  -                    Class homeClass = ClassUtils.forName(localhome);
  -                    Method method = homeClass.getMethod("create",new Class[]{}); 
  -                    return method.invoke(homeObj,new Object[]{});
  -                }
  -                throw new AxisFault("Wrong configuration");
  -            }else{
  -                return makeNewServiceObject(msgContext, clsName);
  -            
  -            }
  -
  -    }
  -
  -    /* (non-Javadoc)
  -     * @see org.apache.axis.providers.java.RPCProvider#invokeMethod(org.apache.axis.MessageContext, java.lang.reflect.Method, java.lang.Object, java.lang.Object[])
  -     */
  -    protected Object invokeMethod(
  -        MessageContext msgContext,
  -        Method method,
  -        Object obj,
  -        Object[] argValues)
  -        throws Exception {
  -            Method ejbMethod = obj.getClass().getMethod(method.getName(),method.getParameterTypes());
  -            return ejbMethod.invoke(obj,argValues);
  -    }
  -
  -}
  +/*
  + * Copyright 2001-2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +package org.apache.geronimo.ews.ws4j2ee.wsutils;
  +
  +import java.io.InputStream;
  +import java.lang.reflect.Method;
  +
  +import org.apache.axis.AxisFault;
  +import org.apache.axis.MessageContext;
  +import org.apache.axis.providers.java.RPCProvider;
  +import org.apache.axis.utils.ClassUtils;
  +
  +/**
  + * register the MessageContext in the jax-rpc runtime of the JSR109 
  + * @author Srinath Perera(hemapani@opensource.lk)
  + */
  +public class EWSProvider extends RPCProvider{
  +    public static final String OPTION_EJB_NAME = "beanName";
  +    public static final String OPTION_JNDI_LOOKUP_NAME = "beanJndiName";
  +    public static final String OPTION_HOMEINTERFACE_NAME = "homeInterfaceName";
  +    public static final String OPTION_REMOTEINTERFACE_NAME = "remoteInterfaceName";
  +    public static final String OPTION_LOCALHOMEINTERFACE_NAME = "localHomeInterfaceName";
  +    public static final String OPTION_LOCALINTERFACE_NAME = "localInterfaceName";
  +    
  +
  +    private String ejblookupName;
  +    private String localhome;
  +    private String home;
  +    private String remote;
  +    private String local;
  +    
  +    private boolean ejbbased = true;
  +
  +
  +    protected Object makeNewServiceObject(
  +        MessageContext msgContext,
  +        String clsName)
  +        throws Exception {
  +            if(ejbbased){
  +                java.util.Properties env = new java.util.Properties();
  +                InputStream jndiIn = ClassUtils.getResourceAsStream(getClass(),"jndi.properties");
  +
  +                if(jndiIn != null){
  +                    env.load(jndiIn);
  +                }else{
  +                    throw new AxisFault("Do not find the JNDI properties file in the class path");
  +                }
  +                javax.naming.Context initial = new javax.naming.InitialContext(env);
  +                
  +                ejblookupName = (String)getOption(OPTION_JNDI_LOOKUP_NAME);
  +                remote = (String)getOption(OPTION_REMOTEINTERFACE_NAME);
  +                home = (String)getOption(OPTION_HOMEINTERFACE_NAME);
  +                local = (String)getOption(OPTION_LOCALINTERFACE_NAME);
  +                localhome = (String)getOption(OPTION_LOCALHOMEINTERFACE_NAME);                
  +
  +                if(remote != null && home != null && ejblookupName != null){
  +                    Object objref = initial.lookup(ejblookupName);
  +                    Class homeClass = ClassUtils.forName(home);
  +                    Object homeObj = javax.rmi.PortableRemoteObject.narrow(objref,homeClass);
  +                    Method method = homeClass.getMethod("create",new Class[]{}); 
  +                    return method.invoke(homeObj,new Object[]{});
  +                }else if(local != null && localhome != null && ejblookupName != null){
  +                    Object homeObj = initial.lookup("java:comp/"+ejblookupName);
  +                    Class homeClass = ClassUtils.forName(localhome);
  +                    Method method = homeClass.getMethod("create",new Class[]{}); 
  +                    return method.invoke(homeObj,new Object[]{});
  +                }
  +                
  +                throw new AxisFault("Wrong configuration");
  +            }else{
  +                return makeNewServiceObject(msgContext, clsName);
  +            
  +            }
  +
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.axis.providers.java.RPCProvider#invokeMethod(org.apache.axis.MessageContext, java.lang.reflect.Method, java.lang.Object, java.lang.Object[])
  +     */
  +    protected Object invokeMethod(
  +        MessageContext msgContext,
  +        Method method,
  +        Object obj,
  +        Object[] argValues)
  +        throws Exception {
  +            Method ejbMethod = obj.getClass().getMethod(method.getName(),method.getParameterTypes());
  +            return ejbMethod.invoke(obj,argValues);
  +    }
  +}
  
  
  
  1.1                  ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/wsutils/WSDDJavaEWSProvider.java
  
  Index: WSDDJavaEWSProvider.java
  ===================================================================
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.geronimo.ews.ws4j2ee.wsutils;
  import org.apache.axis.EngineConfiguration;
  import org.apache.axis.Handler;
  import org.apache.axis.deployment.wsdd.WSDDProvider;
  import org.apache.axis.deployment.wsdd.WSDDService;
  
  
  /**
   * refering to axis comment of pluggable providers
   * 
   * Look for file META-INF/services/org.apache.axis.deployment.wsdd.Provider
   * in all the JARS, get the classes listed in those files and add them to 
   * providers list if they are valid providers. 
   *
   * Here is how the scheme would work.
   *
   * A company providing a new provider will jar up their provider related
   * classes in a JAR file. The following file containing the name of the new 
   * provider class is also made part of this JAR file. 
   *
   * META-INF/services/org.apache.axis.deployment.wsdd.Provider
   *
   * By making this JAR part of the webapp, the new provider will be 
   * automatically discovered. 
   * @author Srinath Perera(hemapani@opensource.lk)
   */
  public class WSDDJavaEWSProvider  extends WSDDProvider{
  	public static final String PROVIDER_EWS = "ews";
  
  	public String getName() {
  		return PROVIDER_EWS;
  	}
  
  	public Handler newProviderInstance(WSDDService service,
  									   EngineConfiguration registry)
  		throws Exception
  	{
  		return new org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider();
  	}
  }