Axis2
  1. Axis2
  2. AXIS2-3784

WSDL port address is not correctly generated for machines having multiple network interfaces

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3, 1.4
    • Fix Version/s: 1.5.4, 1.6.0
    • Component/s: kernel
    • Labels:
      None
    • Environment:
      Windows XP Pro, Java 5, Tomcat 6, Axis2 1.4 (release)

      Description

      WSDL portAddress is filled with one of the machine's IP addresses. The code to get the IP address seems to be org.apache.axis2.transport.http.sever.HTTPUtils.getIpAddress() which always takes the first available network interface's ip address.

      For example http://localhost:8080/axis2/services/Version?wsdl returns a WSDL containing
      ...
      <wsdl:service name="Version">
      <wsdl:port name="VersionHttpSoap11Endpoint" binding="ns:VersionSoap11Binding">
      <soap:address location="http://10.20.125.14:8080/axis2/services/Version.VersionHttpSoap11Endpoint"/>
      </wsdl:port>
      <wsdl:port name="VersionHttpSoap12Endpoint" binding="ns:VersionSoap12Binding">
      <soap12:address location="http://10.20.125.14:8080/axis2/services/Version.VersionHttpSoap12Endpoint"/>
      </wsdl:port>
      <wsdl:port name="VersionHttpEndpoint" binding="ns:VersionHttpBinding">
      <http:address location="http://10.20.125.14:8080/axis2/services/Version.VersionHttpEndpoint"/>
      </wsdl:port>
      </wsdl:service>
      ...

      This may not work on machines which have vmvare installed, or machines having multiple network interfaces or just a laptop which has wireless and wired lan.

      I think the correct way is to use the hostName instead of the ipAddress in the WSDL port address, for example
      ...
      <wsdl:service name="Version">
      <wsdl:port name="VersionHttpSoap11Endpoint" binding="ns:VersionSoap11Binding">
      <soap:address location="http://myhostname.company.com:8080/axis2/services/Version.VersionHttpSoap11Endpoint"/>
      </wsdl:port>
      <wsdl:port name="VersionHttpSoap12Endpoint" binding="ns:VersionSoap12Binding">
      <soap12:address location="http://myhostname.company.com:8080/axis2/services/Version.VersionHttpSoap12Endpoint"/>
      </wsdl:port>
      <wsdl:port name="VersionHttpEndpoint" binding="ns:VersionHttpBinding">
      <http:address location="http://myhostname.company.com:8080/axis2/services/Version.VersionHttpEndpoint"/>
      </wsdl:port>
      </wsdl:service>
      ...

      Regards, Dietmar

      1. AXIS2-3784.patch
        5 kB
        Boris Milanov

        Activity

        Hide
        Dietmar Gaertner added a comment -
        Show
        Dietmar Gaertner added a comment - See also: AXIS2-2990 , AXIS2-3719
        Hide
        Sanka Samaranayake added a comment -

        Hi Dietmar,

        You can do that by setting <parameter name="hostname" value="myhostname.company.com" /> in the axis2.xml

        Sanka

        Show
        Sanka Samaranayake added a comment - Hi Dietmar, You can do that by setting <parameter name="hostname" value="myhostname.company.com" /> in the axis2.xml Sanka
        Hide
        Sanka Samaranayake added a comment -

        It seems like Deepal has already suggested that.

        Sanka

        Show
        Sanka Samaranayake added a comment - It seems like Deepal has already suggested that. Sanka
        Hide
        Dietmar Gaertner added a comment -

        Hi Sanka,

        I saw the possibility to set the hostname parameter. However, this has the drawback that you need to re-configure axis2.xml from axis2.war and hardwire a hostname into it. It would be much more flexible if the hostname is determined at runtime and used instead of the plain IP address in the WSDL.

        Regards, Dietmar

        Show
        Dietmar Gaertner added a comment - Hi Sanka, I saw the possibility to set the hostname parameter. However, this has the drawback that you need to re-configure axis2.xml from axis2.war and hardwire a hostname into it. It would be much more flexible if the hostname is determined at runtime and used instead of the plain IP address in the WSDL. Regards, Dietmar
        Hide
        Nandana Mihindukulasooriya added a comment -

        Changed to take the ip from the request rather than picking the ip of the first network card

        Show
        Nandana Mihindukulasooriya added a comment - Changed to take the ip from the request rather than picking the ip of the first network card
        Hide
        Juan added a comment -

        I just downloaded the new Axis2 version 1.4.1 and I'm still getting the IP of the machine instead of the request. Was this fixed in that version? If not, can someone tell me what I need to do to fix it? I have a deadline in my project and I need this resolved as soon as possible.

        Thank you.

        Show
        Juan added a comment - I just downloaded the new Axis2 version 1.4.1 and I'm still getting the IP of the machine instead of the request. Was this fixed in that version? If not, can someone tell me what I need to do to fix it? I have a deadline in my project and I need this resolved as soon as possible. Thank you.
        Hide
        Nandana Mihindukulasooriya added a comment -

        Juan,
        Nope, I fixed this in the trunk. Just go to Subversion Commits in this issue and you will be able to see the commits.

        Thanks,
        nandana

        Show
        Nandana Mihindukulasooriya added a comment - Juan, Nope, I fixed this in the trunk. Just go to Subversion Commits in this issue and you will be able to see the commits. Thanks, nandana
        Hide
        Juan added a comment -

        Thanks for your reply, does this mean that once I check out the code I have to compile and then use that jar created?

        I've been looking at other posts, I found something interesting that worked but it's more of a hack. In the axis2.xml file, I added a parameter
        <parameter name="hostname" locked="true">(dev server dsn)</parameter> and this will take the port from the URL so I dont worry about it.

        Where can I find your committed code btw?

        Show
        Juan added a comment - Thanks for your reply, does this mean that once I check out the code I have to compile and then use that jar created? I've been looking at other posts, I found something interesting that worked but it's more of a hack. In the axis2.xml file, I added a parameter <parameter name="hostname" locked="true">(dev server dsn)</parameter> and this will take the port from the URL so I dont worry about it. Where can I find your committed code btw?
        Hide
        Nandana Mihindukulasooriya added a comment -

        Hi Juan,
        Yeah, you can use the "hostname" parameter and it will work with Axis2 1.4/1.4.1 without any changes. The code I committed is here [1] . But not sure it is 100% compatible with 1.4 branch. You have to merge these changes to checkout Axis2 1.4 branch and then make a build for this to work with Axis2 1.4.1.

        thanks,
        nandana

        [1] - http://svn.apache.org/viewvc?view=rev&revision=686828

        Show
        Nandana Mihindukulasooriya added a comment - Hi Juan, Yeah, you can use the "hostname" parameter and it will work with Axis2 1.4/1.4.1 without any changes. The code I committed is here [1] . But not sure it is 100% compatible with 1.4 branch. You have to merge these changes to checkout Axis2 1.4 branch and then make a build for this to work with Axis2 1.4.1. thanks, nandana [1] - http://svn.apache.org/viewvc?view=rev&revision=686828
        Hide
        Boris Milanov added a comment -

        Hi Nandana,

        I checked out the trunk and did some testing but I came across a problem.
        If I set the "hostname" parameter in axis2.xml, it does not have effect on the generated wsdl port address.

        Is this intentional?

        Thanks,
        Boris

        Show
        Boris Milanov added a comment - Hi Nandana, I checked out the trunk and did some testing but I came across a problem. If I set the "hostname" parameter in axis2.xml, it does not have effect on the generated wsdl port address. Is this intentional? Thanks, Boris
        Hide
        Nandana Mihindukulasooriya added a comment -

        Boris,
        Nope, this shouldn't be the case. I will have look and see whether this is broken in the trunk.

        thanks,
        nandana

        Show
        Nandana Mihindukulasooriya added a comment - Boris, Nope, this shouldn't be the case. I will have look and see whether this is broken in the trunk. thanks, nandana
        Hide
        Nandana Mihindukulasooriya added a comment -

        Hi Boris,
        Fixed this in the trunk and you take an update and check ?

        thanks,
        nandana

        Show
        Nandana Mihindukulasooriya added a comment - Hi Boris, Fixed this in the trunk and you take an update and check ? thanks, nandana
        Hide
        Boris Milanov added a comment -

        Hi Nandana,

        It works. Thanks.

        Regards,
        Boris

        Show
        Boris Milanov added a comment - Hi Nandana, It works. Thanks. Regards, Boris
        Hide
        Boris Milanov added a comment -

        Hi,

        The fix does not cover the case of user provided wsdl. When requesting a wsdl for a service that has userOriginalWsdl = true, I always receive an ip address for the host.
        Seems to me this JIRA should be reopened.

        Show
        Boris Milanov added a comment - Hi, The fix does not cover the case of user provided wsdl. When requesting a wsdl for a service that has userOriginalWsdl = true, I always receive an ip address for the host. Seems to me this JIRA should be reopened.
        Hide
        Boris Milanov added a comment -

        I can provide a patch for the issue.

        Show
        Boris Milanov added a comment - I can provide a patch for the issue.
        Hide
        Boris Milanov added a comment -

        This patch makes sure that hostname from the request is used when printing a user-defined wsdl.

        Show
        Boris Milanov added a comment - This patch makes sure that hostname from the request is used when printing a user-defined wsdl.
        Hide
        Andreas Veithen added a comment -

        Reopening this issue since the original fix was apparently not complete.

        Show
        Andreas Veithen added a comment - Reopening this issue since the original fix was apparently not complete.
        Hide
        Andreas Veithen added a comment -

        Boris,

        I committed your patch. Thanks for contributing!

        Show
        Andreas Veithen added a comment - Boris, I committed your patch. Thanks for contributing!

          People

          • Assignee:
            Andreas Veithen
            Reporter:
            Dietmar Gaertner
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development