使用本地 WSDL 文件生成 Metro 客户端
我之前使用 wsimport 生成了 Metro 客户端,但在这种情况下,WSDL 是通过 https 访问的。我的命令看起来像这样:
wsimport https://service.net/services/Service?wsdl -d C:\ClientProject\src\main\java -keep
一切正常。现在我正在尝试生成一个客户端,但是,我只有 WSDL 文件的本地副本。我的项目目录设置如下(在 c:\Devel 中):
ClientProject
|- src
|- main
|- java
|- resources
|- META-INF
|- service.wsdl
|- wsimport.bat
wsimport.bat 文件如下所示:
wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl
它基于 Metro Guide 示例,但没有 -p 选项 (http://metro.java.net/指南/Developing_client_application_with_locally_packaged_WSDL.html)。但是,当我运行 bat 文件时,我会无限循环地将命令打印到控制台。例如,
C:\Devel\ClientProject>wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl
有人可以指出我做错了什么吗?
更新
我尝试使用绝对路径(并重新排列参数顺序但无济于事。我仍然得到无尽的命令控制台打印:
wsimport C:\Devel\ClientProject\src\resources\META-INF\service.wsdl -d C:\Devel\ClientProject\src\main\java -keep
I have generated a Metro client using wsimport before, but in that case the WSDL was accessed over https. My commaned looked like this:
wsimport https://service.net/services/Service?wsdl -d C:\ClientProject\src\main\java -keep
and everything worked fine. Now I am trying to generate a client, however, I only have a local copy of the WSDL file. My project directory is set up like this (in c:\Devel):
ClientProject
|- src
|- main
|- java
|- resources
|- META-INF
|- service.wsdl
|- wsimport.bat
The wsimport.bat file looks like this:
wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl
which was based on the Metro Guide example but without the -p option (http://metro.java.net/guide/Developing_client_application_with_locally_packaged_WSDL.html). However, when I run the bat file, I get an endless loop of of the command being printed to the console. E.g.
C:\Devel\ClientProject>wsimport -keep -d ../src/main/java -wsdlLocation ../src/resources/META-INF/service.wsdl
Can somebody point out what I'm doing wrong?
UPDATE
I have tried using absolute paths (and rearranging the param order to no avail. I still get the endless command console prints:
wsimport C:\Devel\ClientProject\src\resources\META-INF\service.wsdl -d C:\Devel\ClientProject\src\main\java -keep
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http:// www.java.net/forum/topic/glassfish/metro-and-jaxb/problems-generate-client-using-local-wsdl-file#comment-812705
如果使用 .bat 文件运行 wsimport 命令,不要将其命名为 wsimport,否则您将陷入调用该文件的无限递归循环中。
此外,“-wsdllocation”区分大小写。 “-wsdlLocation”不起作用(尽管我在搜索过程中看到过很多这样的例子)。
此 wsimport 命令从本地 WSDL 生成客户端代码,并在服务类的 @WebServiceClient 注释上设置“wsdlLocation”属性:
http://www.java.net/forum/topic/glassfish/metro-and-jaxb/problems-generating-client-using-local-wsdl-file#comment-812705
If using a .bat file to run the wsimport command, do not name it wsimport or you'll be in an endless recursive loop calling that file.
Also, "-wsdllocation" is case sensitive. "-wsdlLocation" will not work (although I've seen many examples of it during my searches).
This wsimport command generates the client code from the local WSDL and sets the "wsdlLocation" attribute on the Service class' @WebServiceClient annotation: