Invalid code generated in JavaServiceImplWriter w/multiple ports
----------------------------------------------------------------

         Key: AXIS-1978
         URL: http://issues.apache.org/jira/browse/AXIS-1978
     Project: Axis
        Type: Bug
  Components: WSDL processing  
 Environment: N/A
    Reporter: Eric Hardesty


The code generated by writeSetEndpointAddress in JavaServiceImplWriter is 
incorrect if multiple ports are included for a service.  The code needs to be 
similar to writeGetPortQNameClass where the else is included at the end of the 
if statement.  Below I have a sample an example of the WSDL, generated Locator 
& patch file(untested at this time):

WSDL:
   <service name="HooXEndpointInterfaceService">
      <port binding="impl:HooXEndpointHooxBinding" name="hooxEndpoint3">
         <wsdlsoap:address 
location="http://localhost:9000/hooxsample/hooxEndpoint1/hooxEndpoint1"/>
      </port>
      <port binding="impl:HooXEndpointHooxBinding" name="hooxEndpoint2">
         <wsdlsoap:address 
location="http://localhost:9000/hooxsample/hooxEndpoint1/hooxEndpoint1"/>
      </port>
      <port binding="impl:HooXEndpointSoapBinding" name="hooxEndpoint1">
         <wsdlsoap:address 
location="http://localhost:9000/hooxsample/hooxEndpoint1/hooxEndpoint1"/>
      </port>
   </service>

HooXEndpointInterfaceServiceLocator:
    /**
    * Set the endpoint address for the specified port name.
    */
    public void setEndpointAddress(java.lang.String portName, java.lang.String 
address) throws javax.xml.rpc.ServiceException {
        if ("hooxEndpoint3".equals(portName)) {
            sethooxEndpoint3EndpointAddress(address);
        }
        if ("hooxEndpoint1".equals(portName)) {
            sethooxEndpoint1EndpointAddress(address);
        }
        if ("hooxEndpoint2".equals(portName)) {
            sethooxEndpoint2EndpointAddress(address);
        }
        else { // Unknown Port Name
            throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint 
Address for Unknown Port" + portName);
        }

Patch:
Index: JavaServiceImplWriter.java
===================================================================
RCS file: 
/home/cvspublic/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java,v
retrieving revision 1.44
diff -u -r1.44 JavaServiceImplWriter.java
--- JavaServiceImplWriter.java  20 Jan 2005 21:35:22 -0000      1.44
+++ JavaServiceImplWriter.java  5 May 2005 22:54:48 -0000
@@ -601,15 +601,18 @@
                 "    public void setEndpointAddress(java.lang.String portName, 
java.lang.String address) throws "
                 + javax.xml.rpc.ServiceException.class.getName() + " {");
 
+        pw.print("        ");
         for (Iterator p = portNames.iterator(); p.hasNext();) {
             String name = (String) p.next();
 
-            pw.println("        if (\"" + name + "\".equals(portName)) {");
+            pw.println("if (\"" + name + "\".equals(portName)) {");
             pw.println("            set" + name + "EndpointAddress(address);");
             pw.println("        }");
+            pw.print("        else ");
         }
 
-        pw.println("        else { // Unknown Port Name");
+        pw.println(" { // Unknown Port Name");
+
         pw.println("            throw new "
                 + javax.xml.rpc.ServiceException.class.getName() + "(\" "
                 + Messages.getMessage("unknownPortName")


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to