WSDLException:尝试解析引用的模式时发生错误

时间:2010-02-01 16:25:04

标签: eclipse wsdl axis2 axis wsdl2java

我正在尝试使用eclipse Galileo和Windows xp上的轴2 1.4从本地WSDL文件生成代理类。我的问题是由于WSDL中导入的模式而导致错误。困扰我的是:

<xsd:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="http://www.w3.org/2005/05/xmlmime"/>

我尝试按照以下命令运行wsdl2java:

wsdl2java.bat  -uri SOAService.wsdl -o D:\temp p test -d xmlbeans -a -s -ns2p -uw

我得到以下异常:

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 (at /wsdl:definitions/wsdl:ty
pes/xsd:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve sche
ma referenced at 'http://www.w3.org/2005/05/xmlmime', relative to 'file:/D:/Prog
rammi/axis2-1.4/bin/SOAService.wsdl'.: java.net.ConnectException: Connection tim
ed out: connect
        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>(CodeGenerat
ionEngine.java:111)
        ... 2 more
Caused by: java.net.ConnectException: Connection timed out: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.Socket.connect(Socket.java:520)
        at java.net.Socket.connect(Socket.java:470)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
        at sun.net.www.http.HttpClient.New(HttpClient.java:304)
        at sun.net.www.http.HttpClient.New(HttpClient.java:321)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC
onnection.java:813)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:765)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:690)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:934)
        at java.net.URL.openStream(URL.java:1007)
        at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source)

我怀疑这是由于系统代理不允许将xsd检索到wsdl2java工具。事实上,我可以毫无问题地从浏览器下载文件。

有一个选项可以指定wsdl2java的代理或有人解决了这个问题吗? 目前我已经下载了XSD,将其添加到项目中并将WSDL更改为包含相关文件(而不是远程文件),但我更愿意避免这种情况,因为该文件是第三方服务WSDL

提前感谢您的任何提示。

2 个答案:

答案 0 :(得分:4)

我认为我有同样的问题,下面是我使用java -D选项

解决它的方法
java -Dhttp.proxySet=true -Dhttp.proxyHost={value} -Dhttp.proxyPort={value} org.apache.axis.wsdl.WSDL2Java {wsdlURL}

看看它是否对您有所帮助。此致

答案 1 :(得分:2)

此解决方案可能不起作用,具体取决于用户的安装。在解决方案中没有提及-Dhttp.nonProxyHosts = {要排除的主机列表}选项,如果运行webservices的服务器是本地的,并且存在对您环境之外托管的xml文件的引用,或者您的代理是没有设置回答本地请求。