You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by he...@apache.org on 2004/10/14 08:26:58 UTC

cvs commit: ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/context/impl AxisEmitterBasedJaxRpcMapperContext.java

hemapani    2004/10/13 23:26:58

  Modified:    contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/context
                        JaxRpcMapperContext.java
               contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/context/impl
                        AxisEmitterBasedJaxRpcMapperContext.java
  Added:       contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/toWs/dd
                        JaxRpcMappingFileWriter.java
  Log:
  make the serialization independent of the binding method. Another stop towards
  removing JAXB-RI
  
  Revision  Changes    Path
  1.9       +1 -1      ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/context/JaxRpcMapperContext.java
  
  Index: JaxRpcMapperContext.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/context/JaxRpcMapperContext.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JaxRpcMapperContext.java	13 Oct 2004 10:56:34 -0000	1.8
  +++ JaxRpcMapperContext.java	14 Oct 2004 06:26:58 -0000	1.9
  @@ -26,7 +26,7 @@
   import org.apache.axis.wsdl.symbolTable.BindingEntry;
   import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
   import org.apache.axis.wsdl.symbolTable.ServiceEntry;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaWsdlMapping;
  +
   import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
   
   /**
  
  
  
  1.1                  ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/toWs/dd/JaxRpcMappingFileWriter.java
  
  Index: JaxRpcMappingFileWriter.java
  ===================================================================
  /*
   * Copyright 2003,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.dd;
  
  import java.io.IOException;
  import java.lang.reflect.Method;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Operation;
  import javax.wsdl.Part;
  import javax.wsdl.Port;
  import javax.wsdl.Service;
  import javax.xml.namespace.QName;
  
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.wsdl.fromJava.Emitter;
  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
  import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
  import org.apache.geronimo.ews.ws4j2ee.toWs.Writer;
  import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
  
  /**
   * @author Srinath Perera(hemapani@opensource.lk)
   */
  public class JaxRpcMappingFileWriter implements Writer {
      private SerializationContext sc;
      private String ns = "http://java.sun.com/xml/ns/j2ee";
      private Emitter emitter;
      private J2EEWebServiceContext j2eewscontext;
      
      public JaxRpcMappingFileWriter(java.io.Writer out,
          Emitter emitter,
          J2EEWebServiceContext j2eewscontext){
          if(out == null){
              throw new UnrecoverableGenerationFault(out + " The writer is null");
          }
          sc = new SerializationContext(out);
         
          sc.setPretty(true);
          this.emitter = emitter;
          this.j2eewscontext = j2eewscontext;        
      } 
      
      private void writePackageMapping()throws IOException{
  
              
          String jaxrpcsei = j2eewscontext.getMiscInfo().getJaxrpcSEI();
          Map map = emitter.getNamespaceMap();
          String val = null;
          if (map != null) {
              Iterator packages = map.keySet().iterator();
              while (packages.hasNext()) {
                  String pkg = (String) packages.next();
                  if(pkg == null){
                      //TODO this is temporrary work around to make sure 
                      //the mapping is defined.
                      String pkgName = Utils.getPackageNameFromQuallifiedName(jaxrpcsei);
                      val = (String)map.get(pkgName);
                      if(val == null){
                          val = Utils.javapkgToURI(pkgName);
                      }else{
                          continue;
                      }
                  }else if(pkg.equals(jaxrpcsei)){
                      continue;
                  }else{
                      val = (String) map.get(pkg);
              
                  }
                  //TODO FIX this code to simplfy. 
                  if(pkg != null){
                      sc.startElement(new QName(ns,"package-mapping"),null);//package-mapping
                      sc.startElement(new QName(ns,"package-type"),null);
                      sc.writeString(pkg);
                      sc.endElement();
                      sc.startElement(new QName(ns,"namespaceURI"),null);
                      sc.writeString(val);
                      sc.endElement();
                  
                      sc.endElement();//package-mapping                            
                  }
              }
          }
  
      }
      
      public void writeServiceMapping() throws IOException{
          Service service = j2eewscontext.getWSDLContext().gettargetService().getService();
                      
                      
          sc.startElement(new QName(ns,"service-interface-mapping"),null);//service-interface-mapping   
              
          String name = emitter.getCls().getName();
          int index = name.lastIndexOf('.');
          String packageName = "";
          if (index > 0)
              packageName = name.substring(0, index + 1);
              
          sc.startElement(new QName(ns,"service-interface"),null);
          sc.writeString(packageName + emitter.getServiceElementName());
          sc.endElement();
                      
          sc.registerPrefixForURI("ns1",service.getQName().getNamespaceURI());
          sc.startElement(new QName(ns,"wsdl-service-name"),null);
          sc.writeString("ns1:" + service.getQName().getLocalPart());
          sc.endElement();
              
          //port mapping
          Port wsdlport = j2eewscontext.getWSDLContext().getTargetPort();
                      
          sc.startElement(new QName(ns,"port-mapping"),null);//port-mapping
              
          sc.startElement(new QName(ns,"port-name"),null);
          sc.writeString(wsdlport.getName());
          sc.endElement();
          
          sc.startElement(new QName(ns,"java-port-name"),null);
          sc.writeString(emitter.getServicePortName());
          sc.endElement();
              
          sc.endElement();//port-mapping
                      
                        
          sc.endElement();//service-interface-mapping       
      
      }
      
      private void writeReturnTypes(HashMap methods,Operation op)throws IOException{
          //set return type
          Method mtd = (Method) methods.get(op.getName());
          Class ret = mtd.getReturnType();
          if(ret!= null && !("void".equals(ret.toString()))){
  
              //set return type info
              Map parts = op.getOutput().getMessage().getParts();
              if (parts != null) {
                  Iterator partIt = parts.values().iterator();
                  while (partIt.hasNext()) {
                      //set wsdl message type
                      QName messagename = op.getOutput().getMessage().getQName();
                          
                      //set wsdl message part type
                      sc.startElement(new QName(ns,"wsdl-return-value-mapping"),null);
  
                      sc.startElement(new QName(ns,"method-return-value"),null);
                      sc.writeString(ret.getName());
                      sc.endElement();
                  
                      sc.registerPrefixForURI("ns1",messagename.getNamespaceURI());
                      sc.startElement(new QName(ns,"wsdl-message"),null);
                      sc.writeString("ns1:" + messagename.getLocalPart());
                      sc.endElement();
  
  
                      sc.startElement(new QName(ns,"wsdl-message-part-name"),null);
                      sc.writeString(((Part) partIt.next()).getName());
                      sc.endElement();
                  
                      sc.endElement();//wsdl-return-value-mapping
  
                  }
              }
          }
      
      }
      
      private void writeParametParts(HashMap methods,Operation op)throws IOException{
          int position = 0;
          Class[] params = ((Method) methods.get(op.getName())).getParameterTypes();
  
          Iterator parmIt = null;
          Map parameters = op.getInput().getMessage().getParts();
          if (parameters != null) {
              parmIt = parameters.values().iterator();
          }
  
          while (parmIt != null && parmIt.hasNext()) {
              Part part = (Part) parmIt.next();
                      
              sc.startElement(new QName(ns,"method-param-parts-mapping"),null);
  
              //set parameter position
              sc.startElement(new QName(ns,"param-position"),null);
              sc.writeString(Integer.toString(position));
              sc.endElement();
              //set parameter java typr
              sc.startElement(new QName(ns,"param-type"),null);
              sc.writeString(params[position].getName());
              sc.endElement();
                  
              //set message mapping
              sc.startElement(new QName(ns,"wsdl-message-mapping"),null);
                      
              QName messagename = op.getInput().getMessage().getQName();
              sc.registerPrefixForURI("ns1",messagename.getNamespaceURI());
              sc.startElement(new QName(ns,"wsdl-message"),null);
              sc.writeString(messagename.getLocalPart());
              sc.endElement();
                      
              sc.startElement(new QName(ns,"wsdl-message-part-name"),null);
              sc.writeString(part.getName());
              sc.endElement();
                      
              sc.startElement(new QName(ns,"parameter-mode"),null);
              sc.writeString("IN");
              sc.endElement();
                      
              sc.endElement();//wsdl-message-mapping
  
              sc.endElement();//method-param-parts-mapping
          }
     
      }
      
      
      private void writeMethodMapping(Binding binding)throws IOException{
          //add the operation mappings
              Iterator ops = binding.getPortType().getOperations().iterator();
  
              while (ops.hasNext()) {
                  Operation op = (Operation) ops.next();
                  sc.startElement(new QName(ns,"service-endpoint-method-mapping"),null);//service-endpoint-method-mapping
  
                  //set the java method name
                  sc.startElement(new QName(ns,"java-method-name"),null);
                  sc.writeString(op.getName());
                  sc.endElement();
  
                  sc.startElement(new QName(ns,"wsdl-operation"),null);
                  sc.writeString(op.getName());
                  sc.endElement();
  
                  HashMap methods = new HashMap();
                  Method[] javamethods = emitter.getCls().getMethods();
                  for (int i = 0; i < javamethods.length; i++) {
                      methods.put(javamethods[i].getName(), javamethods[i]);
                  }
                  writeReturnTypes(methods,op);
                  //create method param parts mappings    
                  sc.endElement();//service-endpoint-method-mapping
              }
              
      }
      
      public void write() throws GenerationFault {
          try {
              sc.startElement(new QName(ns,"java-wsdl-mapping"),null);
              writePackageMapping();
              writeServiceMapping();
              //port mapping
              Port wsdlport = j2eewscontext.getWSDLContext().getTargetPort();
              Binding binding = wsdlport.getBinding();
              if (binding == null)
                  throw new UnrecoverableGenerationFault("no port discription not match with the wsdl file");
                  
              sc.startElement(new QName(ns,"service-endpoint-interface-mapping"),null);
              
              sc.startElement(new QName(ns,"service-endpoint-interface"),null);
              sc.writeString(emitter.getCls().getName());
              sc.endElement();
              
              sc.registerPrefixForURI("ns2",binding.getQName().getNamespaceURI());
              sc.startElement(new QName(ns,"wsdl-binding"),null);
              sc.writeString("ns2:"+binding.getQName().getLocalPart());
              sc.endElement();
  
              QName ptName = binding.getPortType().getQName();
              sc.registerPrefixForURI("ns3",ptName.getNamespaceURI());
              sc.startElement(new QName(ns,"wsdl-port-type"),null);
              sc.writeString("ns3:"+ptName.getLocalPart());
              sc.endElement();
              writeMethodMapping(binding);
              sc.endElement(); //service-endpoint-interface-mapping   
              sc.endElement();//java-wsdl-mapping
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  
  }
  
  
  
  1.14      +255 -250  ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/context/impl/AxisEmitterBasedJaxRpcMapperContext.java
  
  Index: AxisEmitterBasedJaxRpcMapperContext.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/context/impl/AxisEmitterBasedJaxRpcMapperContext.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AxisEmitterBasedJaxRpcMapperContext.java	13 Oct 2004 10:56:35 -0000	1.13
  +++ AxisEmitterBasedJaxRpcMapperContext.java	14 Oct 2004 06:26:58 -0000	1.14
  @@ -39,26 +39,27 @@
   import org.apache.axis.wsdl.symbolTable.BindingEntry;
   import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
   import org.apache.axis.wsdl.symbolTable.ServiceEntry;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.FullyQualifiedClassType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaTypeType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaWsdlMapping;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.MethodParamPartsMappingType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.ObjectFactory;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.PackageMappingType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.ParameterModeType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.PortMappingType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.ServiceEndpointMethodMappingType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlMessageMappingType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlMessagePartNameType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlMessageType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlReturnValueMappingType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.XsdAnyURIType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.XsdNonNegativeIntegerType;
  -import org.apache.geronimo.ews.jaxrpcmapping.descriptor.XsdQNameType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.FullyQualifiedClassType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaTypeType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaWsdlMapping;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.MethodParamPartsMappingType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.ObjectFactory;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.PackageMappingType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.ParameterModeType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.PortMappingType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.ServiceEndpointMethodMappingType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlMessageMappingType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlMessagePartNameType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlMessageType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.WsdlReturnValueMappingType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.XsdAnyURIType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.XsdNonNegativeIntegerType;
  +//import org.apache.geronimo.ews.jaxrpcmapping.descriptor.XsdQNameType;
   import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
   import org.apache.geronimo.ews.ws4j2ee.context.JaxRpcMapperContext;
   import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
   import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
  +import org.apache.geronimo.ews.ws4j2ee.toWs.dd.JaxRpcMappingFileWriter;
   import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
   
   /**
  @@ -185,240 +186,244 @@
       }
   
       public void serialize(Writer out) throws GenerationFault {
  -
  -        try {
  -            JAXBContext jc = JAXBContext.newInstance("org.apache.geronimo.ews.jaxrpcmapping.descriptor");
  -            ObjectFactory objFactory = new ObjectFactory();
  -
  -            JavaWsdlMapping jaxrpcmap = objFactory.createJavaWsdlMapping();
  -            jaxrpcmap.setVersion(new BigDecimal("1.0"));
  -            
  -//adding pckage mappings
  -            Map map = emitter.getNamespaceMap();
  -            if (map != null) {
  -                Iterator packages = map.keySet().iterator();
  -                while (packages.hasNext()) {
  -                    PackageMappingType pkgmap = objFactory.createPackageMappingType();
  -                    //set the package name
  -                    FullyQualifiedClassType packagename = objFactory.createFullyQualifiedClassType();
  -                    String pkg = (String) packages.next();
  -                    String jaxrpcsei = j2eewscontext.getMiscInfo().getJaxrpcSEI();
  -                    if(pkg == null){
  -                    	//TODO this is temporrary work around to make sure 
  -                    	//the mapping is defined.
  -                    	String pkgName = Utils.getPackageNameFromQuallifiedName(jaxrpcsei);
  -						String val = (String)map.get(pkgName);
  -						if(val == null){
  -							val = Utils.javapkgToURI(pkgName);
  -							packagename.setValue(pkgName);
  -							pkgmap.setPackageType(packagename);
  -							//set the namespace URI
  -							XsdAnyURIType nsuri = objFactory.createXsdAnyURIType();
  -							nsuri.setValue(val);
  -							pkgmap.setNamespaceURI(nsuri);
  -						}else{
  -							continue;
  -						}
  -                    }else if(pkg.equals(jaxrpcsei)){
  -                   		continue;
  -                    }else{
  -						packagename.setValue(pkg);
  -						pkgmap.setPackageType(packagename);
  -						//set the namespace URI
  -						XsdAnyURIType nsuri = objFactory.createXsdAnyURIType();
  -						nsuri.setValue((String) map.get(pkg));
  -						pkgmap.setNamespaceURI(nsuri);
  -
  -                    }
  -                    //done :) add the package type
  -                    jaxrpcmap.getPackageMapping().add(pkgmap);
  -                }
  -            }
  -            
  -//adding Service mappings
  -///////////////////////////
  -            Service service = j2eewscontext.getWSDLContext().gettargetService().getService();
  -            org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaWsdlMappingType.ServiceInterfaceMapping servciemaping = objFactory.createJavaWsdlMappingTypeServiceInterfaceMapping();
  -			
  -            	
  -            //get the sevice QName	
  -            XsdQNameType serviceName = objFactory.createXsdQNameType();
  -            serviceName.setValue(service.getQName());
  -            servciemaping.setWsdlServiceName(serviceName);
  -        	
  -            //set the service java Name 
  -            FullyQualifiedClassType serviceJavaName = objFactory.createFullyQualifiedClassType();
  -
  -            String name = emitter.getCls().getName();
  -            int index = name.lastIndexOf('.');
  -            String packageName = "";
  -            if (index > 0)
  -                packageName = name.substring(0, index + 1);
  -
  -            serviceJavaName.setValue(packageName + emitter.getServiceElementName());
  -
  -            servciemaping.setServiceInterface(serviceJavaName);
  -            jaxrpcmap.getServiceInterfaceMappingAndServiceEndpointInterfaceMapping().add(servciemaping);
  -
  -            Port wsdlport = j2eewscontext.getWSDLContext().getTargetPort();
  -            Binding binding = wsdlport.getBinding();
  -         	
  -            //create a portmap
  -            PortMappingType portmap = objFactory.createPortMappingType();
  -            //java port name 
  -            org.apache.geronimo.ews.jaxrpcmapping.descriptor.String javaportname = objFactory.createString();
  -            javaportname.setValue(emitter.getServicePortName());
  -            portmap.setJavaPortName(javaportname);
  -            //wsdl port name 
  -            org.apache.geronimo.ews.jaxrpcmapping.descriptor.String wsdlportname = objFactory.createString();
  -            wsdlportname.setValue(wsdlport.getName());
  -            portmap.setPortName(wsdlportname);
  -
  -            servciemaping.getPortMapping().add(portmap);
  -
  -            if (binding == null)
  -                throw new UnrecoverableGenerationFault("no port discription not match with the wsdl file");
  -
  -            org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaWsdlMappingType.ServiceEndpointInterfaceMapping seimapping = objFactory.createJavaWsdlMappingTypeServiceEndpointInterfaceMapping();
  -            
  -//set java SEI name
  -            FullyQualifiedClassType seijavaName = objFactory.createFullyQualifiedClassType();
  -            seijavaName.setValue(emitter.getCls().getName());
  -            seimapping.setServiceEndpointInterface(seijavaName);
  -//set the wsdl finding name
  -            XsdQNameType bindingQName = objFactory.createXsdQNameType();
  -            bindingQName.setValue(binding.getQName());
  -            seimapping.setWsdlBinding(bindingQName);
  -//set the wsdl port type
  -            XsdQNameType portTypeQName = objFactory.createXsdQNameType();
  -            portTypeQName.setValue(binding.getPortType().getQName());
  -            seimapping.setWsdlPortType(portTypeQName);
  -            
  -//add the operation mappings
  -            Iterator ops = binding.getPortType().getOperations().iterator();
  -
  -            while (ops.hasNext()) {
  -                ServiceEndpointMethodMappingType seimethodmapping = objFactory.createServiceEndpointMethodMappingType();
  -                Operation op = (Operation) ops.next();
  -            	
  -                //set the java method name
  -                org.apache.geronimo.ews.jaxrpcmapping.descriptor.String javamethodname = objFactory.createString();
  -                javamethodname.setValue(op.getName());
  -                seimethodmapping.setJavaMethodName(javamethodname);
  -            
  -                //TODO not sure what this WrappedElement do. FIXIT
  -                //seimethodmapping.setWrappedElement();
  -            	
  -                //set wsdl method name 
  -                org.apache.geronimo.ews.jaxrpcmapping.descriptor.String wsdlmethodname = objFactory.createString();
  -                wsdlmethodname.setValue(op.getName());
  -                seimethodmapping.setWsdlOperation(wsdlmethodname);
  -            
  -                //this work only when the method names are same
  -                //im printing it so that it is easier for user to change 
  -                //it am sure that no body will writing nor webservice.xml 
  -                //or jaxrpcmapping.xml files if there is a short cut.
  -				
  -            	
  -                //set return type
  -                Method mtd = (Method) methods.get(op.getName());
  -				Class ret = mtd.getReturnType();
  -				if(ret!= null && !("void".equals(ret.toString()))){
  -					//create return type  Map
  -					WsdlReturnValueMappingType retvalmap = objFactory.createWsdlReturnValueMappingType();
  -
  -					FullyQualifiedClassType retValjavaName = objFactory.createFullyQualifiedClassType();
  -					retValjavaName.setValue(ret.getName());
  -					retvalmap.setMethodReturnValue(retValjavaName);
  -					
  -					//set return type info
  -					Map parts = op.getOutput().getMessage().getParts();
  -					if (parts != null) {
  -						Iterator partIt = parts.values().iterator();
  -						if (partIt.hasNext()) {
  -							//set wsdl message type
  -							WsdlMessageType messageType = objFactory.createWsdlMessageType();
  -							messageType.setValue(op.getOutput().getMessage().getQName());
  -							retvalmap.setWsdlMessage(messageType);
  -            			
  -							//set wsdl message part type
  -							WsdlMessagePartNameType messagePartName = objFactory.createWsdlMessagePartNameType();
  -							messagePartName.setValue(((Part) partIt.next()).getName());
  -							retvalmap.setWsdlMessagePartName(messagePartName);
  -						}
  -
  -					}
  -
  -					seimethodmapping.setWsdlReturnValueMapping(retvalmap);
  -
  -				}
  -            
  -            
  -            	
  -                //create method param parts mappings	
  -                int position = 0;
  -                Class[] params = ((Method) methods.get(op.getName())).getParameterTypes();
  -
  -                Iterator parmIt = null;
  -                Map parameters = op.getInput().getMessage().getParts();
  -                if (parameters != null) {
  -                    parmIt = parameters.values().iterator();
  -                }
  -
  -                while (parmIt != null && parmIt.hasNext()) {
  -                    Part part = (Part) parmIt.next();
  -                    //create parts mapping
  -                    MethodParamPartsMappingType partsMapping = objFactory.createMethodParamPartsMappingType();
  -                    //set parameter position
  -                    XsdNonNegativeIntegerType pos = objFactory.createXsdNonNegativeIntegerType();
  -                    pos.setValue(new BigInteger(Integer.toString(position)));
  -                    partsMapping.setParamPosition(pos);
  -            		
  -                    //set parameter java typr
  -                    JavaTypeType javaType = objFactory.createJavaTypeType();
  -                    javaType.setValue(params[position].getName());
  -                    partsMapping.setParamType(javaType);
  -            		
  -                    //set message mapping
  -                    WsdlMessageMappingType msgmappingType = objFactory.createWsdlMessageMappingType();
  -                    //set mode
  -                    ParameterModeType mode = objFactory.createParameterModeType();
  -                    mode.setValue("IN");
  -                    msgmappingType.setParameterMode(mode);
  -                    //TODO Im a not sure what to do with the header 
  -                    //msgmappingType.setSoapHeader();
  -                    //set wsdl message type
  -                    WsdlMessageType messageType = objFactory.createWsdlMessageType();
  -                    messageType.setValue(op.getInput().getMessage().getQName());
  -                    msgmappingType.setWsdlMessage(messageType);
  -                    //set wsdl message part type
  -                    WsdlMessagePartNameType messagePartName = objFactory.createWsdlMessagePartNameType();
  -                    messagePartName.setValue(part.getName());
  -                    msgmappingType.setWsdlMessagePartName(messagePartName);
  -
  -                    partsMapping.setWsdlMessageMapping(msgmappingType);
  -                    seimethodmapping.getMethodParamPartsMapping().add(partsMapping);
  -                }
  -
  -                seimapping.getServiceEndpointMethodMapping().add(seimethodmapping);
  -
  -            }
  -            jaxrpcmap.getServiceInterfaceMappingAndServiceEndpointInterfaceMapping().add(seimapping);
  -                  
  -//axis do not support XML type mapping or Exception
  -//maping to be specifed so I do not brother tp print them out. 
  -//jaxrpcmap.getExceptionMapping();
  -//jaxrpcmap.getJavaXmlTypeMapping();
  -            
  -            Marshaller m = jc.createMarshaller();
  -            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
  -            m.marshal(jaxrpcmap, out);
  -
  -            Unmarshaller u = jc.createUnmarshaller();
  -        } catch (Exception e) {
  -        	e.printStackTrace();
  -            throw GenerationFault.createGenerationFault(e);
  -        }
  +        JaxRpcMappingFileWriter w = new JaxRpcMappingFileWriter(out,emitter,j2eewscontext);
  +        w.write();
  +//
  +//        try {
  +//            JAXBContext jc = JAXBContext.newInstance("org.apache.geronimo.ews.jaxrpcmapping.descriptor");
  +//            ObjectFactory objFactory = new ObjectFactory();
  +//
  +//            JavaWsdlMapping jaxrpcmap = objFactory.createJavaWsdlMapping();
  +//            jaxrpcmap.setVersion(new BigDecimal("1.0"));
  +//            
  +////adding pckage mappings
  +//            Map map = emitter.getNamespaceMap();
  +//            if (map != null) {
  +//                Iterator packages = map.keySet().iterator();
  +//                while (packages.hasNext()) {
  +//                    PackageMappingType pkgmap = objFactory.createPackageMappingType();
  +//                    //set the package name
  +//                    FullyQualifiedClassType packagename = objFactory.createFullyQualifiedClassType();
  +//                    String pkg = (String) packages.next();
  +//                    String jaxrpcsei = j2eewscontext.getMiscInfo().getJaxrpcSEI();
  +//                    if(pkg == null){
  +//                    	//TODO this is temporrary work around to make sure 
  +//                    	//the mapping is defined.
  +//                    	String pkgName = Utils.getPackageNameFromQuallifiedName(jaxrpcsei);
  +//						String val = (String)map.get(pkgName);
  +//						if(val == null){
  +//							val = Utils.javapkgToURI(pkgName);
  +//							packagename.setValue(pkgName);
  +//							pkgmap.setPackageType(packagename);
  +//							//set the namespace URI
  +//							XsdAnyURIType nsuri = objFactory.createXsdAnyURIType();
  +//							nsuri.setValue(val);
  +//							pkgmap.setNamespaceURI(nsuri);
  +//						}else{
  +//							continue;
  +//						}
  +//                    }else if(pkg.equals(jaxrpcsei)){
  +//                   		continue;
  +//                    }else{
  +//						packagename.setValue(pkg);
  +//						pkgmap.setPackageType(packagename);
  +//						//set the namespace URI
  +//						XsdAnyURIType nsuri = objFactory.createXsdAnyURIType();
  +//						nsuri.setValue((String) map.get(pkg));
  +//						pkgmap.setNamespaceURI(nsuri);
  +//
  +//                    }
  +//                    //done :) add the package type
  +//                    jaxrpcmap.getPackageMapping().add(pkgmap);
  +//                }
  +//            }
  +//            
  +////adding Service mappings
  +/////////////////////////////
  +//            Service service = j2eewscontext.getWSDLContext().gettargetService().getService();
  +//            org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaWsdlMappingType.ServiceInterfaceMapping servciemaping = objFactory.createJavaWsdlMappingTypeServiceInterfaceMapping();
  +//			
  +//            	
  +//            //get the sevice QName	
  +//            XsdQNameType serviceName = objFactory.createXsdQNameType();
  +//            serviceName.setValue(service.getQName());
  +//            servciemaping.setWsdlServiceName(serviceName);
  +//        	
  +//            //set the service java Name 
  +//            FullyQualifiedClassType serviceJavaName = objFactory.createFullyQualifiedClassType();
  +//
  +//            String name = emitter.getCls().getName();
  +//            int index = name.lastIndexOf('.');
  +//            String packageName = "";
  +//            if (index > 0)
  +//                packageName = name.substring(0, index + 1);
  +//
  +//            serviceJavaName.setValue(packageName + emitter.getServiceElementName());
  +//
  +//            servciemaping.setServiceInterface(serviceJavaName);
  +//            jaxrpcmap.getServiceInterfaceMappingAndServiceEndpointInterfaceMapping().add(servciemaping);
  +//
  +//
  +//
  +//            Port wsdlport = j2eewscontext.getWSDLContext().getTargetPort();
  +//            Binding binding = wsdlport.getBinding();
  +//         	
  +//            //create a portmap
  +//            PortMappingType portmap = objFactory.createPortMappingType();
  +//            //java port name 
  +//            org.apache.geronimo.ews.jaxrpcmapping.descriptor.String javaportname = objFactory.createString();
  +//            javaportname.setValue(emitter.getServicePortName());
  +//            portmap.setJavaPortName(javaportname);
  +//            //wsdl port name 
  +//            org.apache.geronimo.ews.jaxrpcmapping.descriptor.String wsdlportname = objFactory.createString();
  +//            wsdlportname.setValue(wsdlport.getName());
  +//            portmap.setPortName(wsdlportname);
  +//
  +//            servciemaping.getPortMapping().add(portmap);
  +//
  +//            if (binding == null)
  +//                throw new UnrecoverableGenerationFault("no port discription not match with the wsdl file");
  +//
  +//            org.apache.geronimo.ews.jaxrpcmapping.descriptor.JavaWsdlMappingType.ServiceEndpointInterfaceMapping seimapping = objFactory.createJavaWsdlMappingTypeServiceEndpointInterfaceMapping();
  +//            
  +////set java SEI name
  +//            FullyQualifiedClassType seijavaName = objFactory.createFullyQualifiedClassType();
  +//            seijavaName.setValue(emitter.getCls().getName());
  +//            seimapping.setServiceEndpointInterface(seijavaName);
  +////set the wsdl finding name
  +//            XsdQNameType bindingQName = objFactory.createXsdQNameType();
  +//            bindingQName.setValue(binding.getQName());
  +//            seimapping.setWsdlBinding(bindingQName);
  +////set the wsdl port type
  +//            XsdQNameType portTypeQName = objFactory.createXsdQNameType();
  +//            portTypeQName.setValue(binding.getPortType().getQName());
  +//            seimapping.setWsdlPortType(portTypeQName);
  +//            
  +////add the operation mappings
  +//            Iterator ops = binding.getPortType().getOperations().iterator();
  +//
  +//            while (ops.hasNext()) {
  +//                ServiceEndpointMethodMappingType seimethodmapping = objFactory.createServiceEndpointMethodMappingType();
  +//                Operation op = (Operation) ops.next();
  +//            	
  +//                //set the java method name
  +//                org.apache.geronimo.ews.jaxrpcmapping.descriptor.String javamethodname = objFactory.createString();
  +//                javamethodname.setValue(op.getName());
  +//                seimethodmapping.setJavaMethodName(javamethodname);
  +//            
  +//                //TODO not sure what this WrappedElement do. FIXIT
  +//                //seimethodmapping.setWrappedElement();
  +//            	
  +//                //set wsdl method name 
  +//                org.apache.geronimo.ews.jaxrpcmapping.descriptor.String wsdlmethodname = objFactory.createString();
  +//                wsdlmethodname.setValue(op.getName());
  +//                seimethodmapping.setWsdlOperation(wsdlmethodname);
  +//            
  +//                //this work only when the method names are same
  +//                //im printing it so that it is easier for user to change 
  +//                //it am sure that no body will writing nor webservice.xml 
  +//                //or jaxrpcmapping.xml files if there is a short cut.
  +//				
  +//            	
  +//                //set return type
  +//                Method mtd = (Method) methods.get(op.getName());
  +//				Class ret = mtd.getReturnType();
  +//				if(ret!= null && !("void".equals(ret.toString()))){
  +//					//create return type  Map
  +//					WsdlReturnValueMappingType retvalmap = objFactory.createWsdlReturnValueMappingType();
  +//
  +//					FullyQualifiedClassType retValjavaName = objFactory.createFullyQualifiedClassType();
  +//					retValjavaName.setValue(ret.getName());
  +//					retvalmap.setMethodReturnValue(retValjavaName);
  +//					
  +//					//set return type info
  +//					Map parts = op.getOutput().getMessage().getParts();
  +//					if (parts != null) {
  +//						Iterator partIt = parts.values().iterator();
  +//						if (partIt.hasNext()) {
  +//							//set wsdl message type
  +//							WsdlMessageType messageType = objFactory.createWsdlMessageType();
  +//							messageType.setValue(op.getOutput().getMessage().getQName());
  +//							retvalmap.setWsdlMessage(messageType);
  +//            			
  +//							//set wsdl message part type
  +//							WsdlMessagePartNameType messagePartName = objFactory.createWsdlMessagePartNameType();
  +//							messagePartName.setValue(((Part) partIt.next()).getName());
  +//							retvalmap.setWsdlMessagePartName(messagePartName);
  +//						}
  +//
  +//					}
  +//
  +//					seimethodmapping.setWsdlReturnValueMapping(retvalmap);
  +//
  +//				}
  +//            
  +//            
  +//            	
  +//                //create method param parts mappings	
  +//                int position = 0;
  +//                Class[] params = ((Method) methods.get(op.getName())).getParameterTypes();
  +//
  +//                Iterator parmIt = null;
  +//                Map parameters = op.getInput().getMessage().getParts();
  +//                if (parameters != null) {
  +//                    parmIt = parameters.values().iterator();
  +//                }
  +//
  +//                while (parmIt != null && parmIt.hasNext()) {
  +//                    Part part = (Part) parmIt.next();
  +//                    //create parts mapping
  +//                    MethodParamPartsMappingType partsMapping = objFactory.createMethodParamPartsMappingType();
  +//                    //set parameter position
  +//                    XsdNonNegativeIntegerType pos = objFactory.createXsdNonNegativeIntegerType();
  +//                    pos.setValue(new BigInteger(Integer.toString(position)));
  +//                    partsMapping.setParamPosition(pos);
  +//            		
  +//                    //set parameter java typr
  +//                    JavaTypeType javaType = objFactory.createJavaTypeType();
  +//                    javaType.setValue(params[position].getName());
  +//                    partsMapping.setParamType(javaType);
  +//            		
  +//                    //set message mapping
  +//                    WsdlMessageMappingType msgmappingType = objFactory.createWsdlMessageMappingType();
  +//                    //set mode
  +//                    ParameterModeType mode = objFactory.createParameterModeType();
  +//                    mode.setValue("IN");
  +//                    msgmappingType.setParameterMode(mode);
  +//                    //TODO Im a not sure what to do with the header 
  +//                    //msgmappingType.setSoapHeader();
  +//                    //set wsdl message type
  +//                    WsdlMessageType messageType = objFactory.createWsdlMessageType();
  +//                    messageType.setValue(op.getInput().getMessage().getQName());
  +//                    msgmappingType.setWsdlMessage(messageType);
  +//                    //set wsdl message part type
  +//                    WsdlMessagePartNameType messagePartName = objFactory.createWsdlMessagePartNameType();
  +//                    messagePartName.setValue(part.getName());
  +//                    msgmappingType.setWsdlMessagePartName(messagePartName);
  +//
  +//                    partsMapping.setWsdlMessageMapping(msgmappingType);
  +//                    seimethodmapping.getMethodParamPartsMapping().add(partsMapping);
  +//                }
  +//
  +//                seimapping.getServiceEndpointMethodMapping().add(seimethodmapping);
  +//
  +//            }
  +//            jaxrpcmap.getServiceInterfaceMappingAndServiceEndpointInterfaceMapping().add(seimapping);
  +//                  
  +////axis do not support XML type mapping or Exception
  +////maping to be specifed so I do not brother tp print them out. 
  +////jaxrpcmap.getExceptionMapping();
  +////jaxrpcmap.getJavaXmlTypeMapping();
  +//            
  +//            Marshaller m = jc.createMarshaller();
  +//            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
  +//            m.marshal(jaxrpcmap, out);
  +//
  +//            Unmarshaller u = jc.createUnmarshaller();
  +//        } catch (Exception e) {
  +//        	e.printStackTrace();
  +//            throw GenerationFault.createGenerationFault(e);
  +//        }
       }
       public String getPackageMappingClassName(int index) {
           throw new UnsupportedOperationException();