6

I am trying to generate the java classes from a WSLD file, that uses basic authentication.

Although there are many plugins out there, I have to use the following one: org.jvnet.jaxb2.maven2:maven-jaxb2-plugin

With wsimport or wsdl2java i have found the way to configure the basic authentication parameters. Using the maven-jaxb2-plugin i had no luck.

My configuration follows:

       <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.13.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <packageName>com.mycompany</packageName>
                        <sourceType>wsdl</sourceType>
                        <specVersion>2.2</specVersion>
                        <schemas>
                            <schema>
                                <url>https://some-url?wsdl</url>
                            </schema>
                        </schemas>

                        <outputDirectory>target/generated-sources/xjb</outputDirectory>
                        <clearOutputDir>false</clearOutputDir>
                        <useActiveProxyAsHttpproxy>true</useActiveProxyAsHttpproxy>
                    </configuration>
                </execution>
            </executions>
        </plugin>

As expected, the build fails with the following message:

Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://some-url?wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2275)
... 36 more

Any ideas about the basic authentication configuration? Thank's in advance!

Note: https://username:pass@some-url?wsdl, i still get an IOException because of the unauthorized request.

Eirini Graonidou
  • 1,506
  • 16
  • 24

3 Answers3

2

I haven't found any way of solving this. I ended up downloading the .wsdl and the needed .xsd files and edited them (changed the import URL's) properly.

Note: For people that have the same issue, i would recommend the jaxws:wsimport plugin, that supports an xauthFile option for the configuration of the basic authentication.

Eirini Graonidou
  • 1,506
  • 16
  • 24
1

wsimport, wsdl2java, maven-jaxb2 are meant for generating Proxy classes out of the Descriptor file. Since you are getting Unauthorized (401), it could be either due to wrong creds or may be you are not sending credentials et all in a request.

For Basic Auth, refer another stackoverflow question here

Also, if you can post your exact code here where you configure the Creds, it will be helpful in identifying the cause

Sunil Singhal
  • 593
  • 3
  • 11
  • 2
    Hi Sunil, thank's for your answer! I am not sure if I was understood, though. I am trying to generate the code from a wsdl file. Accessing the needed files requires basic authentication. This should be set somehow during the execution of the maven plugin. – Eirini Graonidou Aug 21 '17 at 11:18
0

It took a while for me to understand what is there inside xauthfile. An xauthfile is nothing but, URL with basic authentication credentials.

https://username:pass@url:port/

Prabah
  • 807
  • 6
  • 12