如何从 Java 调用 .net webservice

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22346624/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 15:06:08  来源:igfitidea点击:

How to call .net webservice from Java

javaweb-services

提问by Sagar Zala

I have created one Java Software in that I want to call .net webservice.

我创建了一个 Java 软件,我想在其中调用 .net webservice。

How to make it possible ?

如何使它成为可能?

I see some examples but I don't find any perfect solution.

我看到了一些例子,但我没有找到任何完美的解决方案。

回答by Sukane

Web services are universal operating system and language independent. It doesn't matter where the services is or in what language it is written,you just invoke it and it gives you "replay".Probably you must refer to java consuming web services.

Web 服务与通用操作系统和语言无关。服务在哪里或用什么语言编写都无关紧要,您只需调用它,它就会为您提供“重播”。可能您必须参考使用 Java 的 Web 服务。

Here are two references ;-

这里有两个参考;-

1.From MSDN Java/.NET Interoperability with the Microsoft.com Web Service

1.来自 MSDN Java/.NET Interoperability with the Microsoft.com Web Service

2.Integrating .NET Web Services with Java and classic ASP Clients for Interoperability

2.将 .NET Web 服务与 Java 和经典 ASP 客户端集成以实现互操作性

回答by Mikkel L?kke

There are lots of ways you can do this, depending on what kind of .Net Webservice, you have (WCF / SOAP / RESTful JSON / XML-RPC / etc.), likewise how you interact with it from Java may be as easy as HttpClient + Gson/Castor, or as less simple as setting up WSIT.

有很多方法可以做到这一点,具体取决于您拥有的 .Net Web 服务类型(WCF / SOAP / RESTful JSON / XML-RPC / 等),同样,您如何从 Java 与其交互可能就像HttpClient + Gson/Castor,或者像设置 WSIT 一样简单。

回答by Petter Nordlander

It's pretty simple as long as you don't get into any strange jaxws/WCF interop issues.

只要您不陷入任何奇怪的 jaxws/WCF 互操作问题,这非常简单。

  1. Get hold of the WSDL from the WCF service. (i.e. http://example.org/service.svc?WSDLusually gets you the WSDL).

  2. Generate Web service client from WSDL. You can use wsimport from JDK to do this, there are other options as well, CXF wsdl2java. Plenty of SO threads cover this already: Java Webservice Client (Best way)

  3. Use the java client from plain code to call your .NET service.

  1. 从 WCF 服务获取 WSDL。(即http://example.org/service.svc?WSDL通常为您提供 WSDL)。

  2. 从 WSDL 生成 Web 服务客户端。您可以使用 JDK 中的 wsimport 来执行此操作,还有其他选项,CXF wsdl2java。很多 SO 线程已经涵盖了这一点:Java Webservice Client (Best way)

  3. 使用纯代码的 java 客户端调用您的 .NET 服务。