scheu       2002/06/21 07:37:40

  Modified:    java/src/org/apache/axis/providers/java JavaProvider.java
               java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
  Log:
  Problem:
    When using Service?wsdl, the generated wsdl may not have
    the same targetNamespace, portType, service element name, or
    service port name as the original wsdl.  This problem has
    been reported by users and is a TCK issue.
  
  Solution:
    Four optional parameters are added to the deploy.wsdd and
    queried by the JavaProvider (wsdlTargetNamespace, wsdlServiceElement,
    wsdlServicePort and wsdlPortType).
  
    Here is an example deploy.wsdd with the new parameters.
  
  <deployment
      xmlns="http://xml.apache.org/axis/wsdd/";
      xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
  
    <!-- Services from AddressBookService WSDL service -->
  
    <service name="AddressBook" provider="java:RPC">
        <parameter name="wsdlTargetNamespace" value="urn:AddressFetcher2"/>
        <parameter name="wsdlServiceElement" value="AddressBookService"/>
        <parameter name="wsdlServicePort" value="AddressBook"/>
        <parameter name="className" 
value="samples.addr.AddressBookSOAPBindingSkeleton"/>
        <parameter name="wsdlPortType" value="AddressBook"/>
        <parameter name="allowedMethods" value="*"/>
        <parameter name="scope" value="Session"/>
    ...
  
  Revision  Changes    Path
  1.62      +32 -3     
xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
  
  Index: JavaProvider.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- JavaProvider.java 19 Jun 2002 15:39:20 -0000      1.61
  +++ JavaProvider.java 21 Jun 2002 14:37:40 -0000      1.62
  @@ -102,7 +102,11 @@
       public static final String OPTION_ALLOWEDMETHODS = "allowedMethods";
       public static final String OPTION_IS_STATIC = "isStatic";
       public static final String OPTION_CLASSPATH = "classPath";
  -    
  +    public static final String OPTION_WSDL_PORTTYPE="wsdlPortType";
  +    public static final String OPTION_WSDL_SERVICEELEMENT="wsdlServiceElement";
  +    public static final String OPTION_WSDL_SERVICEPORT="wsdlServicePort";
  +    public static final String OPTION_WSDL_TARGETNAMESPACE="wsdlTargetNamespace";
  +
       public static final String OPTION_SCOPE = "scope";
   
       /**
  @@ -341,8 +345,9 @@
               String url = msgContext.getStrProp(MessageContext.TRANS_URL);
               String interfaceNamespace = 
                       msgContext.getStrProp(MessageContext.WSDLGEN_INTFNAMESPACE);
  -            if (interfaceNamespace == null) 
  +            if (interfaceNamespace == null) {
                   interfaceNamespace = url;
  +            }
               String locationUrl = 
                       msgContext.getStrProp(MessageContext.WSDLGEN_SERV_LOC_URL);
               
  @@ -387,13 +392,37 @@
   
               emitter.setClsSmart(cls,url);
               emitter.setAllowedMethods(allowedMethods);
  -            emitter.setIntfNamespace(interfaceNamespace);
  +
  +            // If a wsdl target namespace was provided, use the targetNamespace.
  +            // Otherwise use the interfaceNamespace constructed above.
  +            String targetNamespace = (String) 
service.getOption(OPTION_WSDL_TARGETNAMESPACE);
  +            if (targetNamespace == null || 
  +                targetNamespace.length() == 0) {
  +                targetNamespace = interfaceNamespace;
  +            }            
  +            emitter.setIntfNamespace(targetNamespace);
  +
               emitter.setLocationUrl(locationUrl);
               
emitter.setServiceDesc(msgContext.getService().getInitializedServiceDesc(msgContext));
               emitter.setTypeMapping((TypeMapping)msgContext.getTypeMappingRegistry().
                                      getTypeMapping(Constants.URI_DEFAULT_SOAP_ENC));
               
emitter.setDefaultTypeMapping((TypeMapping)msgContext.getTypeMappingRegistry().
                                             getDefaultTypeMapping());
  +
  +            String wsdlPortType = (String) service.getOption(OPTION_WSDL_PORTTYPE);
  +            String wsdlServiceElement = (String) 
service.getOption(OPTION_WSDL_SERVICEELEMENT);
  +            String wsdlServicePort = (String) 
service.getOption(OPTION_WSDL_SERVICEPORT);
  +
  +            if (wsdlPortType != null && wsdlPortType.length() > 0) {
  +                emitter.setPortTypeName(wsdlPortType);
  +            }
  +            if (wsdlServiceElement != null && wsdlServiceElement.length() > 0) {
  +                emitter.setServiceElementName(wsdlServiceElement);
  +            }
  +            if (wsdlServicePort != null && wsdlServicePort.length() > 0) {
  +                emitter.setServicePortName(wsdlServicePort);
  +            }
  +
               Document  doc = emitter.emit(Emitter.MODE_ALL);
   
               msgContext.setProperty("WSDL", doc);
  
  
  
  1.50      +13 -2     
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- JavaDeployWriter.java     20 Jun 2002 20:35:47 -0000      1.49
  +++ JavaDeployWriter.java     21 Jun 2002 14:37:40 -0000      1.50
  @@ -177,7 +177,7 @@
                   if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
                       continue;
                   }
  -                writeDeployPort(pw, myPort);
  +                writeDeployPort(pw, myPort, myService);
               }
           }
       } //writeDeployServices
  @@ -264,7 +264,7 @@
       /**
        * Write out deployment and undeployment instructions for given WSDL port
        */
  -    protected void writeDeployPort(PrintWriter pw, Port port) throws IOException {
  +    protected void writeDeployPort(PrintWriter pw, Port port, Service service) 
throws IOException {
           Binding binding = port.getBinding();
           BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
           String serviceName = port.getName();
  @@ -286,6 +286,13 @@
                   + "\" provider=\"" + prefix +":RPC"
                   + "\"" + styleStr + ">");
   
  +        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 + "\"/>");
  +
           writeDeployBinding(pw, binding);
           writeDeployTypes(pw, hasLiteral);
   
  @@ -305,6 +312,10 @@
   
           pw.println("      <parameter name=\"className\" value=\""
                            + className + "\"/>");
  +
  +        pw.println("      <parameter name=\"wsdlPortType\" value=\""
  +                         + binding.getPortType().getQName().getLocalPart() + 
"\"/>");
  +
   
           String methodList = "";
           if (!emitter.isSkeletonWanted()) {
  
  
  


Reply via email to