使用基本身份验证从wsdl url生成java类 [英] Generate java classes from a wsdl url with basic authentication
问题描述
我正在尝试从使用基本身份验证的WSLD文件生成java类。
I am trying to generate the java classes from a WSLD file, that uses basic authentication.
虽然有很多插件,但我必须使用以下内容一: org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
Although there are many plugins out there, I have to use the following one: org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
wsimport
或 wsdl2java
我找到了配置基本身份验证参数的方法。使用 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.
我的配置如下:
<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!
注意: https:// username:pass @ some-url?wsdl ,由于未经授权的请求,我仍然会收到IOException。
Note: https://username:pass@some-url?wsdl, i still get an IOException because of the unauthorized request.
推荐答案
wsimport
, wsdl2java
, maven-jaxb2
用于从Descriptor文件生成代理类。
由于您未获得授权(401),可能是由于错误的信用,或者您可能未在请求中发送凭证等。
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.
对于Basic Auth,请参考此处的另一个stackoverflow问题
For Basic Auth, refer another stackoverflow question here
此外,如果您可以在配置Creds的地方发布您的确切代码,将有助于确定原因
Also, if you can post your exact code here where you configure the Creds, it will be helpful in identifying the cause
这篇关于使用基本身份验证从wsdl url生成java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!