我试图使我的wsdl位置在生成的客户端中不再是静态的(使用jaxws-maven-plugin),但我没有获得太多成功。
我发现了以下内容..
我的插件(放在pom构建中的插件中):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<id>ecad-ws</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<sourceDestDir>${basedir}/target/generated-sources</sourceDestDir>
<keep>true</keep>
<verbose>true</verbose>
<extension>true</extension>
<wsdlDirectory>src/main/resources</wsdlDirectory>
<wsdlFiles>
<wsdlFile>CBS.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>http://localhost/wsdl/msw/cbs?wsdl</wsdlLocation>
<catalog>
${basedir}/src/main/resources/META-INF/jax-ws-catalog.xml
</catalog>
</configuration>
</execution>
</executions>
</plugin>和一个jax-ws-resources文件(放在src/main/resources/META-INF中):
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<system
systemId="http://localhost/wsdl/msw/cbs?wsdl"
uri="../CBS.wsdl" />
</catalog>CBS.wsdl放在src/main/resouces中。就我所了解的研究而言,上面的代码将生成的客户端中的URL更改为http://localhost/wsdl/msw/cbs?wsdl (这是有效的),然后,当客户端被调用时,它将查找目录并将上面的url与../CBS.wsdl匹配。最后一部分不起作用,因为我得到了以下异常:
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:94)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:148)
... 118 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://localhost/wsdl/msw/cbs?wsdl'.: java.net.ConnectException: Connection refused: connect
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:244)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:191)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
... 120 more
Caused by: java.net.ConnectException: Connection refused: connect我真的找不到另一个解决方案。如果我没有在生成的客户端中更改wsdl的位置,我总是会得到类似"Failed to access the WSDL at: file: XXXXX“的信息(这是完全正常的)
我使用的是jdk 7 btw。
发布于 2021-03-11 20:51:39
这个答案大约晚了6年,但是...
当我在搜索如何在我自己的存储库中设置编目文件时,我遇到了这个问题。2021年..使用Java11。我设法让它在我的存储库中工作,并将上面的配置与我的配置进行比较,我唯一能说的是,您可能需要将${basedir}添加到<wsdlDirectory>部分。
...
<wsdlDirectory>${basedir}src/main/resources</wsdlDirectory>
...我将把这篇文章留给下一个疲惫的开发人员(像我一样),他们必须在REST时代实现wsdl连接。
https://stackoverflow.com/questions/31726306
复制相似问题