简体   繁体   English

使用Java从WSDL文件中为现有Web服务创建客户端

[英]Creating a client for a existing web service out of a WSDL file with Java

I have a given WSDL file (a SOAP web service in the internet) and I want to use this service. 我有一个给定的WSDL文件(Internet上的SOAP Web服务),我想使用此服务。 For that I want to write a Java client, that sends the required datas (as XML) to the web service and the service itself sends an response. 为此,我想编写一个Java客户端,该客户端将所需的数据(作为XML)发送到Web服务,并且服务本身发送响应。

Unfortunately, I am totaly new in web services. 不幸的是,我完全不熟悉Web服务。 This is why I want you to ask for help. 这就是为什么我要您寻求帮助。

I found a lot of ways to use SOAP in Java. 我发现了许多在Java中使用SOAP的方法。 One way is the AXIS2 framework from Apache, another way is the Eclipse Web Tools Project (WTP). 一种方法是来自Apache的AXIS2框架,另一种方法是Eclipse Web工具项目(WTP)。 I've tried both but couldn't get it run.. 我都尝试过,但无法运行。

First of all.. What do I need to use such an SOAP web service? 首先..使用这样的SOAP Web服务需要什么?

I think: - generate Java source out of the WSDL file - write an client that uses this code - with this client you can send datas to the web service (the client itself sends the data via XML) and the client can process the response 我认为:-从WSDL文件中生成Java源代码-编写使用此代码的客户端-使用此客户端,您可以将数据发送到Web服务(客户端本身通过XML发送数据),并且客户端可以处理响应

Am I right or do I have a fallacy? 我是对的还是我有谬误?

Thank you for your help!! 谢谢您的帮助!!

I think: - generate Java source out of the WSDL file - write an client that uses this code - with this client you can send datas to the web service (the client itself sends the data via XML) and the client can process the response 我认为:-从WSDL文件中生成Java源代码-编写使用此代码的客户端-使用此客户端,您可以将数据发送到Web服务(客户端本身通过XML发送数据),并且客户端可以处理响应

That is correct. 那是对的。 You can use Axis2 as you mentioned, write a JAX-WS client , you can even write the SOAP message by hand (not that I would recommend that though). 您可以使用提到的Axis2,编写一个JAX-WS客户端 ,甚至可以手动编写SOAP消息(尽管我不建议这样做)。

You should try to get a successful call from SoapUI first then write your client application. 您应该首先尝试从SoapUI获得成功的调用,然后编写您的客户端应用程序。 Use wsimport to get a simple client working (if that's all you need a framework like Axis2 could be overkill). 使用wsimport可以使一个简单的客户端正常工作(如果仅此而已 ,那么您需要一个像Axis2这样的框架可能会显得过大)。

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

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