没有Java EE应用服务器C#和Java使用Web服务互操作的? [英] Interoperate between C# and Java using web services without a Java EE application server?

查看:167
本文介绍了没有Java EE应用服务器C#和Java使用Web服务互操作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个困难的境地::我们有一个第三方企业制度暴露一个基于Java的API。但是,我们是一个100%的.Net导向的开发团队。从本质上讲,我需要的东西,C#代码可以调用来包装的Java API。

I'm in a difficult position: We have a 3rd party enterprise system that exposes a Java-based API. However, we are a 100% .Net oriented development team. Essentially, I need to wrap the Java API with something that C# code can call.

Web服务将是巨大的,但是支持我们的基础设施唯一的Java应用程序服务器的WebSphere 6.1。这意味着古老的(和不建议使用)JAX-RPC的Web服务框架是我们公开Web服务的唯一途径。刚开了一个简单的证明的概念在这里工作是一个噩梦(因为Java经验不足时,WebSphere是可怕的,JAX-RPC是笨重,和大量的JAR地狱)。

Web services would be great, but the only Java application server supported on our infrastructure is WebSphere 6.1. This means the ancient (and deprecated) JAX-RPC web service framework is the only way for us to expose web services. Just getting a simple proof-of-concept working here has been a nightmare (because of Java inexperience, WebSphere being awful, JAX-RPC being clunky, and lots of JAR hell).

在Java EE 5中新的JAX-WS 2.0 Web服务框架看起来great--有什么办法在没有一个完整的Java应用服务器上运行吗?例如,在.net中的WCF(Windows通信框架),你可以承载服务几乎任何你想要的(进程,Windows服务,IIS 6/7等等)。

The new JAX-WS 2.0 web service framework in JAVA EE 5 looks great-- is there any way to run this without an entire Java application server? For example, in .Net's WCF (Windows Communication Framework), you can host services pretty much anywhere you want (in-process, Windows Service, IIS 6/7 etc).

什么是包装这个库的一些Web服务的最轻量级的方式?

What is the most lightweight way to wrap this library with some web services?

推荐答案

我最终找到解决办法,这是远远大于任何上述的更容易。我们与 @ javax.jws.WebService @javax创建一些简单的类(比如在@托尔比约恩Ravn的安德森的回答掺杂()方法)。 jws.WebMethod 注释,那么他们部署使用:

I ended up finding a solution that was far easier than any of the above. We created some simple classes (like the doPing() method in @Thorbjørn Ravn Andersen's answer) with the @javax.jws.WebService and @javax.jws.WebMethod annotations, then deployed them using:

string url = "http://localhost:8282/MyService"
MyService serviceInstance = new MyService();
Endpoint svc = Endpoint.publish(url, serviceInstance);



当时我能够在 HTTP指向的Visual Studio://本地主机: 8282 /为MyService?WSDL 并生成一个客户端。易如反掌。

I was then able to point Visual Studio at http://localhost:8282/MyService?wsdl and generate a client. Easy as pie.

我们已通过此服务在大跨度的时间跑了很多请求,并且还没有发现任何问题。我们与Java服务包装包裹这使得它在重新启动/ JVM死机等穷人版的应用程序服务器回来了。

We have run a lot of requests through this service over a large span of time and have not noticed any problems. We wrapped this with the Java Service Wrapper so that it comes back up across reboots/JVM crashes, etc. A poor man's application server.

我希望这可以帮助任何其他.NET开发人员希望使用Java进行互操作,而无需重新映射你的大脑去做。

I hope this might help any other .NET developer looking to interoperate with Java without having to remap your brain to do it.

这篇关于没有Java EE应用服务器C#和Java使用Web服务互操作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆