简体   繁体   English

通过SOAP从Java Swing应用程序调用.NET Web服务

[英]Calling .NET Web Service from Java Swing application via SOAP

I don't know how to call a .NET Web Service as there is a requirement in my application that calls the .NET Web Service and login in that by calling the login method which gives some token. 我不知道如何调用.NET Web服务,因为在我的应用程序中需要调用.NET Web服务并通过调用提供一些令牌的login方法来登录。 Please provide me a link that solves this problem or give me a sample code for it. 请提供解决此问题的链接或给我一个示例代码。

您可以看一下Apache Axis ,它允许您使用SOAP Web服务,而无论使用哪种语言编写。

You must use the WSDL to communicate with the web service. 您必须使用WSDL与Web服务进行通信。
The most frequent approach is to use a framework (cxf, jax-ws or axis) to create client stubs from the WSDL and then use this stubs in your application code. 最常见的方法是使用框架(cxf,jax-ws或axis)从WSDL创建客户端存根,然后在应用程序代码中使用此存根。
Since you have a Swing application your user could press a button to log to the web service (as your requirement) and the action handler would call the service method that would communicate with the web service. 由于您具有Swing应用程序,因此您的用户可以按一个按钮登录到Web服务(根据您的要求),并且操作处理程序将调用与Web服务进行通信的服务方法。
If you check on any of the above frameworks there are a lot of tutorials. 如果您检查上述任何框架,都有很多教程。
As a trivial example in your case you could do a wsimport (shipped in java) on the WSDL of the .NET service to create the client stubs. 作为一个简单的示例,您可以在.NET服务的WSDL上执行wsimport (以Java装运)以创建客户端存根。 Check them out. 去看一下。 And then you could do something like 然后你可以做类似的事情

Service myService = Service.create(wsdl,serviceName);
MyPort port = myService.getPort(....);
//use port to call methods inside your GUI 
port.methodX();

Since you use a swing GUI make sure you do NOT call the methods from EDT otherwise GUI will freeze 由于您使用的是摆动GUI,请确保不要从EDT调用方法,否则GUI会冻结

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

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