简体   繁体   English

用Java代码从wsdl调用Web服务

[英]Calling a webservice from wsdl in java code

I am new in working with web services.I have got this WSDL file URL 我是使用Web服务的新手。我有此WSDL文件URL

**http://localhost:7101/MyWebServices-Webservices-context-root/ThePort?WSDL**

I know there are tools to call method from this web service just like HTTP ANALYZER . 我知道有一些工具可以从此Web服务调用方法,就像HTTP ANALYZER I want to user above url to call method from the web service from java code. 我想使用url以上的用户从Java代码从Web服务中调用方法。 can i do that? 我能做到吗? if yes can someone please guide me how to?? 如果是,有人可以指导我怎么做吗? Thanks. 谢谢。 . . .

This is what i am trying 这就是我正在尝试的

URL url = new URL("http://localhost:7101/MyWebServices-Webservices-context-root/ThePort?WSDL");
            QName qname = new QName("http://example.com/", "HelloWorldService");
            Service service = Service.create(url, qname);

Check out this link . 查看此链接 There's a complete step-by-step tutorial. 有完整的分步教程。

If you are using the Eclipse IDE, the JavaEE perspective provides a suitable environment for developing web services and their clients. 如果使用的是Eclipse IDE,则JavaEE透视图为开发Web服务及其客户端提供了合适的环境。

Right-click the Project Explorer > New > Other > Web Service Client. 右键单击项目资源管理器>新建>其他> Web Service客户端。

The Web Service Client window should appear. 将出现“ Web Service客户端”窗口。 In the 'Service Definition' box, paste the WSDL file. 在“服务定义”框中,粘贴WSDL文件。 If the file is valid, you should be able to create a client application where you will be able to call and execute the appropriate methods. 如果该文件有效,则应该能够创建一个客户端应用程序,在其中可以调用并执行适当的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM