Axis2
  1. Axis2
  2. AXIS2-4060

wsdl2java is unable to retrieve a WSDL when basic authentication is required

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4, 1.4.1
    • Fix Version/s: 1.7.0
    • Component/s: codegen
    • Labels:
      None

      Description

      When access to the WSDL requires basic authentication, wsdl2java fails to send the credentials in version 1.4.1
      while version 1.3 works fine.

      Using version 1.4.1:

      > wsdl2java -uri http://ssmith:password@myapp.example.com:8080/webservices/mywsdl.wsdl -s -uw -u

      you will get HTTP error 401 as shown below, while the same command works fine when using version 1.3.

      ------ ---- — --- — --- — ---

      Retrieving document at 'http://ssmith:password@myapp.example.com:8080/company-webservices/mywsdl.wsdl'.

      Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException

      : Error parsing WSDL

      at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerat

      ionEngine.java:156)

      at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)

      at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)

      Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=OTHER_ERROR: Unabl

      e to resolve imported document at 'http://ssmith:password@myapp.example.com:8

      080/webservices/mywsdl.wsdl'.: java.io.IOException: Server retu

      rned HTTP response code: 401 for URL: http://ssmith:password@sdk.eng.e-dialog.co

      m:8080/webservices/mywsdl.wsdl

      at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)

      at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)

      at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.readInTheWSDLFile(

      CodeGenerationEngine.java:288)

      at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerat

      ionEngine.java:111)

      ... 2 more

      Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL:

      http://ssmith:password@myapp.example.com:8080/webservices/mailingCru

      dWsdl.wsdl

      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon

      nection.java:1241)

      at java.net.URL.openStream(URL.java:1009)

      at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source)

      ... 6 more

        Activity

        Jorge Medina created issue -
        Hide
        Amila Chinthaka Suriarachchi added a comment -

        how you specify the credentials in Axis2 1.3?

        Show
        Amila Chinthaka Suriarachchi added a comment - how you specify the credentials in Axis2 1.3?
        Dimuthu Leelarathne made changes -
        Field Original Value New Value
        Assignee Dimuthu Leelarathne [ muthulee ]
        Hide
        Jorge Medina added a comment -

        I specified it in the URL to the WSDL:

        http://user:password@server:8080/mywebservice/mywsdl.wsdl

        -Jorge

        Show
        Jorge Medina added a comment - I specified it in the URL to the WSDL: http://user:password@server:8080/mywebservice/mywsdl.wsdl -Jorge
        Hide
        Steve Cohen added a comment -

        I wonder why the syntax in Axis 1.1

        Wsdl2Java -U username -P password

        was dropped.

        Show
        Steve Cohen added a comment - I wonder why the syntax in Axis 1.1 Wsdl2Java -U username -P password was dropped.
        Hide
        Oliver Tupran added a comment -

        Actually there is also a problem on axis2-1.3. The problem manifested itself if the wsdl file was referencing or importing xsd files located on the same server specified through relative paths.

        ...
        <wsdl:types>
        <xsd:schema ...>
        <xsd:import namespace="namespace" schemaLocation="../../some_schema.xsd"/>
        ...
        </xsd:schema>
        </wsdl:types>
        ...

        As I see it, it looks like the authentication worked for the wsdl url, but not for the rest of the files.

        Show
        Oliver Tupran added a comment - Actually there is also a problem on axis2-1.3. The problem manifested itself if the wsdl file was referencing or importing xsd files located on the same server specified through relative paths. ... <wsdl:types> <xsd:schema ...> <xsd:import namespace="namespace" schemaLocation="../../some_schema.xsd"/> ... </xsd:schema> </wsdl:types> ... As I see it, it looks like the authentication worked for the wsdl url, but not for the rest of the files.
        Hide
        Sbremal added a comment -

        Is this issue going to be fixed? Is there any workaround?

        In enterprise environments it is quite common that the WSDL is stored at a password protected HTTP location. Would be good not to discurage people to use AXIS2 in business environments...

        Can someone give a boost to the fix of this incident? Hotfix would also be fine...

        Cheers,
        Balazs

        Show
        Sbremal added a comment - Is this issue going to be fixed? Is there any workaround? In enterprise environments it is quite common that the WSDL is stored at a password protected HTTP location. Would be good not to discurage people to use AXIS2 in business environments... Can someone give a boost to the fix of this incident? Hotfix would also be fine... Cheers, Balazs
        Hide
        Ammar Fakhruddin added a comment -

        Its been almost 2 years with the issue. Can you please fix this.

        Show
        Ammar Fakhruddin added a comment - Its been almost 2 years with the issue. Can you please fix this.
        Mark Kinsella made changes -
        Comment [ I reproduced this error and tested it with a quick-and-dirty PHP page that logs all sent credentials -- indeed, there are no credentials at all being passed from wsdl2java to my page.

        I'm not sure I'm following the source correctly, but per my initial investigation, this looks like an issue with the associated wsdl4j-1.6.2 library, specifically the getContentAsInputStream(URL url) function in the com.ibm.wsdl.util.StringUtils class.

        I can't see that there is any credential passing going on here, nor any reading of credentials from the URL via url.getUserInfo() or anything similar.

        Not sure what might have changed here, as I can't find a copy of wsdl4j prior to a 1.6.2 release, and I'm not sure what libs axis2 was using in the functioning version. ]
        Hide
        Mark Kinsella added a comment -

        I was able to reproduce (read: I struggled with) this error, so I tested it with a quick-and-dirty PHP page to view what (if any) credentials were being passed. None were.

        So, I looked into the source a bit to see what I could find.

        I'm a little rusty on how java.net.URL is intended to work these days, but it seemed that the root of this issue lies in the wsdl4j-1.6.2 library, used by axis2, as it doesn't appear to subclass the Authenticator class anywhere. Specifically, the class com.ibm.wsdl.util.StringUtils and its method getContentAsInputStream(URL url) doesn't seem to be sending any authentication when it calls url.openStream()

        I added an inner class within that class, and added one line to the getContentAsInputStream and was able to get access to the WSDL file using my credentials.
        ......
        Here's my inner class...
        .....

        static class WSDLAuthenticator extends Authenticator {

        public PasswordAuthentication getPasswordAuthentication()

        { String[] userInfoParts = uri.getUserInfo().split(":"); return (new PasswordAuthentication(userInfoParts[0], userInfoParts[1].toCharArray())); }

        }
        ......
        and I added this line after the if (url == null) block, to point the URL object to the Authenticator
        ......
        Authenticator.setDefault(new WSDLAuthenticator());
        .......

        Not sure what the protocol is for suggesting patches to the wsdl4j project , but I suppose I'll cross my fingers that good karma will come my way if I try.
        I believe the wsdl4j code is CPL'd.

        Anyway, thought I'd post this in case anyone finds it useful, or wishes to critique my approach.

        Show
        Mark Kinsella added a comment - I was able to reproduce (read: I struggled with) this error, so I tested it with a quick-and-dirty PHP page to view what (if any) credentials were being passed. None were. So, I looked into the source a bit to see what I could find. I'm a little rusty on how java.net.URL is intended to work these days, but it seemed that the root of this issue lies in the wsdl4j-1.6.2 library, used by axis2, as it doesn't appear to subclass the Authenticator class anywhere. Specifically, the class com.ibm.wsdl.util.StringUtils and its method getContentAsInputStream(URL url) doesn't seem to be sending any authentication when it calls url.openStream() I added an inner class within that class, and added one line to the getContentAsInputStream and was able to get access to the WSDL file using my credentials. ...... Here's my inner class... ..... static class WSDLAuthenticator extends Authenticator { public PasswordAuthentication getPasswordAuthentication() { String[] userInfoParts = uri.getUserInfo().split(":"); return (new PasswordAuthentication(userInfoParts[0], userInfoParts[1].toCharArray())); } } ...... and I added this line after the if (url == null) block, to point the URL object to the Authenticator ...... Authenticator.setDefault(new WSDLAuthenticator()); ....... Not sure what the protocol is for suggesting patches to the wsdl4j project , but I suppose I'll cross my fingers that good karma will come my way if I try. I believe the wsdl4j code is CPL'd. Anyway, thought I'd post this in case anyone finds it useful, or wishes to critique my approach.
        Hide
        vvarma added a comment -

        I am also facing the same issue. Any idea when can we expect the fix.

        Show
        vvarma added a comment - I am also facing the same issue. Any idea when can we expect the fix.
        Hide
        David Webb added a comment -

        This is crucial for using WSDL2CODE for consuming Enterprise Web Services.

        Show
        David Webb added a comment - This is crucial for using WSDL2CODE for consuming Enterprise Web Services.
        Hide
        carsten madsen added a comment -

        This is also an issue here!

        Show
        carsten madsen added a comment - This is also an issue here!
        Samisa Abeysinghe made changes -
        Component/s codegen [ 12311413 ]
        Hide
        John D'costa added a comment -

        Is this problem solved? This is really required for the Enterprise services. We are also stuck with this issue. Trying to figure how I can bypass the live check of the schema. Looked into almost all of the code base and could not figure out where it is coming from.

        axis2-wsdl2code-maven-plugin:1.4:wsdl2code (default) @ accessmanagerclient —
        Retrieving document at 'src/main/resources/AMServices.wsdl'.
        Retrieving schema at 'http://localhost:8001/am-services/AMServices?xsd=1', relative to 'file:/C:/ws/sso/accessmanagerclient/src/main/resources/AMServices.wsdl'.
        java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8001/am-services/AMServices?xsd=1
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1290)
        at java.net.URL.openStream(URL.java:1009)
        at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.readInTheWSDLFile(CodeGenerationEngine.java:288)
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:111)
        at org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo.execute(WSDL2CodeMojo.java:558)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD FAILURE
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 6.141s
        [INFO] Finished at: Thu Feb 02 10:53:34 PST 2012
        [INFO] Final Memory: 5M/9M
        [INFO] ------------------------------------------------------------------------
        [ERROR] Failed to execute goal org.apache.axis2:axis2-wsdl2code-maven-plugin:1.4:wsdl2code (default) on project accessmanagerclient: Error parsing WSDL: WSDLException (at /definitions/types/xsd:schema[1]): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'http://localhost:8001/am-services/AMServices?xsd=1', relative to 'file:/C:/ws/sso/accessmanagerclient/src/main/resources/AMServices.wsdl'.: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8001/am-services/AMServices?xsd=1 -> [Help 1]
        [ERROR]
        [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
        [ERROR]
        [ERROR] For more information about the errors and possible solutions, please read the following articles:
        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

        Show
        John D'costa added a comment - Is this problem solved? This is really required for the Enterprise services. We are also stuck with this issue. Trying to figure how I can bypass the live check of the schema. Looked into almost all of the code base and could not figure out where it is coming from. axis2-wsdl2code-maven-plugin:1.4:wsdl2code (default) @ accessmanagerclient — Retrieving document at 'src/main/resources/AMServices.wsdl'. Retrieving schema at 'http://localhost:8001/am-services/AMServices?xsd=1', relative to 'file:/C:/ws/sso/accessmanagerclient/src/main/resources/AMServices.wsdl'. java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8001/am-services/AMServices?xsd=1 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1290) at java.net.URL.openStream(URL.java:1009) at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.readInTheWSDLFile(CodeGenerationEngine.java:288) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:111) at org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo.execute(WSDL2CodeMojo.java:558) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) at org.codehaus.classworlds.Launcher.main(Launcher.java:47) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6.141s [INFO] Finished at: Thu Feb 02 10:53:34 PST 2012 [INFO] Final Memory: 5M/9M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.axis2:axis2-wsdl2code-maven-plugin:1.4:wsdl2code (default) on project accessmanagerclient: Error parsing WSDL: WSDLException (at /definitions/types/xsd:schema [1] ): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'http://localhost:8001/am-services/AMServices?xsd=1', relative to 'file:/C:/ws/sso/accessmanagerclient/src/main/resources/AMServices.wsdl'.: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8001/am-services/AMServices?xsd=1 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
        Sagara Gunathunga made changes -
        Assignee Dimuthu Leelarathne [ muthulee ] Sagara Gunathunga [ sagara ]
        Hide
        Sagara Gunathunga added a comment -

        I have fixed this issue on r1325736.

        Now it's possible to use following two options.

        -http-proxy-user <user name> Proxy user name for basic authentication if you are behind a firewall.

        -http-proxy-password <password> Proxy password for basic authentication if you are behind a firewall.

        Show
        Sagara Gunathunga added a comment - I have fixed this issue on r1325736. Now it's possible to use following two options. -http-proxy-user <user name> Proxy user name for basic authentication if you are behind a firewall. -http-proxy-password <password> Proxy password for basic authentication if you are behind a firewall.
        Sagara Gunathunga made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.7.0 [ 12316136 ]
        Resolution Fixed [ 1 ]
        Hide
        Hudson added a comment -

        Integrated in Axis2 #1346 (See https://builds.apache.org/job/Axis2/1346/)
        Fixed AXIS2-4060.
        Introduced two new command line parameters as http-proxy-user and http-proxy-password. (Revision 1325736)

        Result = SUCCESS
        sagara :
        Files :

        • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java
        • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
        • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java
        • /axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/CommandLineOptionConstants.java
        Show
        Hudson added a comment - Integrated in Axis2 #1346 (See https://builds.apache.org/job/Axis2/1346/ ) Fixed AXIS2-4060 . Introduced two new command line parameters as http-proxy-user and http-proxy-password. (Revision 1325736) Result = SUCCESS sagara : Files : /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java /axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/CommandLineOptionConstants.java

          People

          • Assignee:
            Sagara Gunathunga
            Reporter:
            Jorge Medina
          • Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development