简体   繁体   English

WCF与Java Web Service的通信

[英]WCF communication with java web service

Background I'm primarily a .Net developer with limited experience in Java. 背景我主要是.Net开发人员,对Java的经验有限。 I have a WCF web service that needs to communicate with a 3rd party Message Queue Server in order to send and receive files. 我有一个WCF Web服务,该服务需要与第三方Message Queue Server通信才能发送和接收文件。 The 3rd party has provided a Java API in order to access their Message Queue Server. 第三方提供了Java API,以便访问其Message Queue Server。

I've done some research into the best way to move forward and now I'd like to get some feedback from anyone with experience with a similar situation. 我已经对前进的最佳方法进行了一些研究,现在我想从任何有类似情况的人那里得到一些反馈。

After some digging I determined that one option is to create a java web service in Eclipse and host it on Glassfish. 经过一番挖掘后,我确定一个选择是在Eclipse中创建一个Java Web服务并将其托管在Glassfish上。 This java webservice would reference: 此Java Web服务将引用:

  1. The java api provided by the 3rd party thus allowing the 3rd party to send the xml files to us. 第三方提供的Java API,因此允许第三方将xml文件发送给我们。
  2. My existing WCF service in order to pass along the xml to be processed. 我现有的WCF服务是为了传递要处理的xml。

So the incoming xml file would flow as follows: 因此,传入的xml文件将如下所示流动:

3rd party -> Java WS -> WCF WS 第三方-> Java WS-> WCF WS

This incoming flow is only half the equation since my WCF web service can also initiate communiation with the third party. 由于我的WCF Web服务还可以启动与第三方的通信,因此传入的流量只是等式的一半。 So I need an outgoing flow as well. 所以我也需要一个外向流。

  1. One option would be to reference the Java WS from my WCF service. 一种选择是从我的WCF服务中引用Java WS。 However then the 2 web services would each be referencing each other. 但是,然后这2个Web服务将互相引用。 Is this considered a circular reference (bad practice) when 2 web services reference one another? 当2个Web服务相互引用时,这是否被视为循环引用(坏习惯)?
  2. If option 1. is considered bad practice, my other option would be to have one of the web services poll the other service. 如果选项1被认为是不好的做法,我的另一种选择是让一个Web服务轮询另一个服务。
  3. Other options? 还有其他选择吗?

Summary Questions 1. Any insight into the circular web reference question above? 概述问题 1.对上述圆形网络参考问题有何见解? 2. Am I on the right track in general? 2.我总体上走对了吗? 3. Any suggestions or personal experience you can provide? 3.您可以提供任何建议或个人经验吗?

Your insight is very much appreciated. 非常感谢您的见解。

My first thought would be that if it's a quick RPC type call, provided you're calling a different web services for the The call back, I wouldn't be too concerned about a circular reference. 我首先想到的是,如果这是一个快速的RPC类型调用,假设您要为The Call回叫一个不同的Web服务,那么我不会太在意循环引用。 Technically you're sending messages "by contract" So as a good practice put your contract definitions in a different project to your service implementation. 从技术上讲,您是按合同方式发送消息的,因此,作为一种好的做法,请将合同定义放在与服务实现不同的项目中。

If the .NET processing takes a bit of time it may be worth it to use a message queue and a worker service as well. 如果.NET处理需要一点时间,那么使用消息队列和辅助服务也是值得的。

The other consideration is to find out what MQ infrastructure they're actually using. 另一个考虑因素是找出他们实际使用的MQ基础结构。 You may be able to avoid the web services altogether as there are .NET connectors for a lot of MQ providers, like 您可能可以完全避免使用Web服务,因为许多MQ提供程序都有.NET连接器,例如

MSMQ (obviously) MSMQ(显然)

ActiveMQ http://activemq.apache.org/nms/ ActiveMQ http://activemq.apache.org/nms/

& WebSphere MQ http://www.redbooks.ibm.com/abstracts/sg247012.html &WebSphere MQ http://www.redbooks.ibm.com/abstracts/sg247012.html

Just to name a few. 仅举几个。 There are also MSMQ bridges. 也有MSMQ桥。

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

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