“无法从...初始化默认的wsdl". - 为什么? [英] "Can not initialize the default wsdl from..." -- Why?
问题描述
我的pom.xml
包含以下内容,以自动为具有下面指定的WSDL的正常工作的Web服务生成客户端:
My pom.xml
contains the following to auto generate a client for a working web service having the WSDL specified below:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>generate-sources</id>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/myclient.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
<wsdlLocation>wsdl/myclient.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
项目构建良好,没有任何错误或警告,我可以在wsdl
文件夹下看到JAR文件中的文件myclient.wsdl
.
The project builds fine, without any errors or warnings and I can see the the file myclient.wsdl
in the JAR file right under a wsdl
folder.
但是当我尝试运行该JAR时:
But when I try running that JAR:
java -Xmx1028m -jar myclient-jar-with-dependencies.jar
它抱怨无法从wsdl/myclient.wsdl初始化默认的wsdl"
It complains that "Can not initialize the default wsdl from wsdl/myclient.wsdl"
为什么?
我想念什么?
如何找到pom.xml中的wsdl/myclient.wsdl
转换为的路径,使客户端的JAR在运行时抱怨?
How can I find out what path that wsdl/myclient.wsdl
in pom.xml translates into, that makes the client's JAR complain at run time?
更新:我知道一些涉及修改自动生成代码的解决方案/解决方法:
Update: I am aware of some solutions/workarounds that involve modifying the auto-generated code:
- 为wsdl URL传递"null",然后使用((BindingProvider)port).getRequestContext().放入(BindingProvider. ENDPOINT_ADDRESS_PROPERTY ," http://example.com/ ....)设置地址
- 将WSDL作为Java资源加载,并将其位置传递到服务的构造函数中.
- Pass "null" for the wsdl URL and then use the ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://example.com/....") to set the address.
- load the WSDL as a Java resource and pass its location into your service's constructor.
但是,我对这样的解决方案更感兴趣,该解决方案要求在pom.xml
中输入正确的值,例如 classpath方法 (但不幸的是,由于某种原因,classpath对我不起作用).
But I am more interested in a solution that requires entering the right values into the pom.xml
like the classpath approach (but unfortunately classpath didn't work for me for some reason).
有什么主意我应该在那输入什么吗?显然,这是为该特定插件找出正确路径规则的一种非常简单的情况,但我遗漏了一些东西,我不知道它是什么.
Any ideas what I should be typing there instead? Apparently this is a very simply case of figuring out the correct path rules for that particular plugin, but I am missing something and I don't know what it is.
推荐答案
I notice the cfx examples use slightly different locations for sourceRoot
, wsdl
and wsdlLocation
.
请记住,通常,src/main/resources
中的文件包含在生成的工件中.为了包含src/main/wsdl
中的文件,需要将其作为资源添加到pom.xml中:
Remember that typically, files in src/main/resources
are included in the produced artifact. In order for files in src/main/wsdl
to be included, it needs to be added as a resource in the pom.xml:
<resources>
<resource>
<directory>src/main/wsdl</directory>
</resource>
</resources>
提示:
- 将您怀疑的路径设置为已知的错误路径,并查看是否收到相同的错误消息.
- 解压缩生成的
*.jar
文件,并检查是否包含wsdl,以及路径是什么.
- Set the paths you suspect to known bad paths and see if you get the same error-message.
- Unzip the produced
*.jar
-file(s) and check if the wsdl is included, and what the path is.
这篇关于“无法从...初始化默认的wsdl". - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!