java 如何使用 WSDL 网址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6568956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How To Use WSDL Url
提问by AhmetEmre90
I wrote a java web service on Netbeans 6.9.1 and deployed on GlassFish 3.0.1
I have a wsdl url like this "http://localhost:8080/web2/service2Service?wsdl".
How can I use this url to access this web service from another java application.
Thanks
我在 Netbeans 6.9.1 上编写了一个 Java Web 服务并部署在 GlassFish 3.0.1
我有一个像这样“http://localhost:8080/web2/service2Service?wsdl”的 wsdl url。如何使用此 url 从另一个 Java 应用程序访问此 Web 服务。
谢谢
回答by djna
You need to generate some Java that represents the client's view of the Web Service and then invoke that Java. Here's an article which explains some of the detail.
您需要生成一些代表 Web 服务的客户端视图的 Java,然后调用该 Java。这里有一篇文章解释了一些细节。
Generating client from WSDL in Eclipse
The general idea is that you generate some Java classes from the WSDL. Those classes act as a proxy for the service you want to call. Your java invokes methods on the proxy objects, the generated code creates the appropriate SOAP messages, sends the HTTP request, interprets the response and your code just sees a Java result.
总体思路是从 WSDL 生成一些 Java 类。这些类充当您要调用的服务的代理。您的 java 调用代理对象上的方法,生成的代码创建适当的 SOAP 消息,发送 HTTP 请求,解释响应,您的代码只看到 Java 结果。
I just use the tooling built into Eclipse, but you will also find other suitable generators, for example in Apache's Axis
我只使用 Eclipse 中内置的工具,但您也会找到其他合适的生成器,例如在 Apache 的Axis
回答by Adolfo García
1o U must save the content in a "myWebServices.wsdl" file
1o 您必须将内容保存在“myWebServices.wsdl”文件中
2o Run your Wsdl converter, all compilers have one of this, normally the name is WDSL.EXE This process will create a new file with NameSpace or Package with the definitions of webservices built in.
2o 运行你的 Wsdl 转换器,所有编译器都有一个,通常名称是 WDSL.EXE 这个过程将创建一个带有 NameSpace 或 Package 的新文件,其中包含内置的 webservices 定义。
3o Then imports this package or built a library.
3o 然后导入这个包或者建一个库。
回答by Niroshan Abayakoon
Develop web service Client in second application. You can use Netbeans to create web service client by giving your wsdl url
在第二个应用程序中开发 Web 服务客户端。您可以通过提供 wsdl url 使用 Netbeans 创建 Web 服务客户端
回答by Andreas Dolk
The document at this url is the actual wsdl(a description of the actual webservice, written in WebService Definfition Language).
这个 url 上的文档是实际的wsdl(对实际 web 服务的描述,用WebService 定义语言编写)。
The description includes information about the services url, the protocol(s), the method names and and data objects. Your application will use that information to call the remote methods of that service.
描述包括有关服务 url、协议、方法名称和数据对象的信息。您的应用程序将使用该信息来调用该服务的远程方法。
The protocol may or may not be SOAP, and without knowing the webservice details, it's quite impossible to recommend a toolset or methodology to use the webservice, there is no general approach. In most cases we see SOAP, for those services I recomment soapUIas a general tool to useand test SOAP based webservices and apache axisto implement java based service consumers.
协议可能是也可能不是 SOAP,并且在不知道 Web 服务详细信息的情况下,推荐使用 Web 服务的工具集或方法论是不可能的,没有通用的方法。在大多数情况下,我们会看到 SOAP,对于这些服务,我建议使用soapUI作为通用工具来使用和测试基于 SOAP 的 Web 服务和apache 轴来实现基于 Java 的服务消费者。