简体   繁体   English

使用Java消费.NET Web服务

[英]Consume .NET web services in Java

I have created .NET web services. 我已经创建了.NET Web服务。 I want to run it on a remote server and have the Java Applications (clients) contact the server for data. 我想在远程服务器上运行它,并让Java应用程序(客户端)与服务器联系以获取数据。 How should I implement the Server such that the Clients can make use of the org.apache.xmlrpc.client.XmlRpcClient package? 我应该如何实现服务器,以使客户端可以使用org.apache.xmlrpc.client.XmlRpcClient包?

I just want the clients to generate a request for data and does not want to have any other dependencies. 我只希望客户端生成对数据的请求,并且不希望具有任何其他依赖关系。

Here is a good material on using eclipse for this purpose: http://wso2.org/library/tutorials/creating-web-service-client-3-steps-using-eclipse 这是有关为此目的使用eclipse的很好的材料: http : //wso2.org/library/tutorials/creating-web-service-client-3-steps-using-eclipse

Thanks. 谢谢。

如果您在.NET端具有Web服务,则必须具有Web服务描述语言(WSDL)(如果您不是在谈论REST),则可以轻松创建客户端类以使用IDE来使用此Web服务,请检查此链接在这里: http : //netbeans.org/kb/docs/websvc/client.html

If you are using Eclipse I suggest you this tutorial to build a simple WS client. 如果您使用的是Eclipse,则建议您教程构建一个简单的WS客户端。

You can adapt this example application to your real needs. 您可以使此示例应用程序适应您的实际需求。

NOTE the example uses an old version of Eclipse, but the wizard is very similar also in newer versions. 注意该示例使用的是旧版本的Eclipse,但该向导在新版本中也非常相似。

Although both are rightfully called "web services" the SOAP based web services usually created in .net are incompatible with web services following the older XML-RPC standard . 尽管两个都被正确地称为“ Web服务”,但是通常在.net中创建的基于SOAP的Web服务与遵循较旧的XML-RPC标准的 Web服务不兼容。

In my opinion you can follow 2 routes to solve your problem: 我认为您可以按照2条路线解决您的问题:

Both routes have advantages and disadvantages, it's hard to make that choice for you without knowing more about your project. 两种方法都有其优点和缺点,如果不了解您的项目,很难为您做出选择。 A priori choosing the SOAP route might look "safer" as there the entire communication will be based on standard components. 先验地选择SOAP路由可能看起来“更安全”,因为整个通信将基于标准组件。

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

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