简体   繁体   English

用WCF和Java编写的Web服务

[英]Web service written in both WCF and Java

Can I write a web service that implements the same methods and returns the same custom objects using both C#/WCF and also Java Web Services? 我可以编写使用C#/ WCF以及Java Web Services来实现相同方法并返回相同自定义对象的Web服务吗? And if so, can I then access the web services using a single web reference but with different addresses? 如果可以的话,我可以使用一个具有不同地址的Web参考来访问Web服务吗?

I'm asking because I have to host a web service that has a GetCitations and GetTerms method for publically exposing our database content. 我之所以这样问是因为我必须托管一个Web服务,该服务具有用于公开公开我们的数据库内容的GetCitations和GetTerms方法。 We are on IIS, so I was going to do it with WCF. 我们在IIS上,所以我打算用WCF来做。 However, other partners in the project also have to host an equivalent service and they are all Java based. 但是,该项目中的其他合作伙伴也必须托管等效服务,并且它们都基于Java。

We are then building a software app that needs to connect to any number of these services (as defined at runtime by a user). 然后,我们正在构建一个软件应用程序,该应用程序需要连接到任意数量的这些服务(由用户在运行时定义)。 I am expecting that we can have one set of classes to connect to these services (but with different endpoitn addresses), but am not sure whether I'm right in expecting this to work. 我期望我们可以有一组类来连接到这些服务(但是具有不同的endpoitn地址),但是不确定我是否期望它能正常工作。

Is this possible? 这可能吗? And what considerations/restrictions are there? 还有哪些考虑/限制?

Thanks. 谢谢。

It shouldn't be a problem, if you make sure that both services have equivalent wsdl files and you use http/soap binding. 如果您确保两个服务都具有等效的wsdl文件,并且您使用的是http / soap绑定,那么应该没问题。

I am not sure about using the binary (net.tcp) one with WCF, though. 不过,我不确定要在WCF中使用二进制(net.tcp)。 It might be a problem. 可能是个问题。

One way to do it is to use JAX-WS (Java 6) to expose a method as a web service. 一种方法是使用JAX-WS(Java 6)将方法公开为Web服务。

The JAX-WS stack allows for automatically generating the correct WSDL at runtime. JAX-WS堆栈允许在运行时自动生成正确的WSDL。

The .NET team can then take that WSDL, and use standard tools to create a mock implementation of that WSDL. 然后,.NET团队可以使用该WSDL,并使用标准工具来创建该WSDL的模拟实现。 This mock implementation is then used as the actual .NET implementation, and you then use standard tools to generate the WSDL for that web service. 然后将此模拟实现用作实际的.NET实现,然后使用标准工具为该 Web服务生成WSDL。

You now have to web services with the same semantics each with their own WSDL. 现在,您必须使用具有相同语义的Web服务,每个服务都具有自己的WSDL。

Java和.NET都可以实现SOAP兼容的Web服务,因此答案是肯定的,您可以编写实现相同WSDL的.NET和Java Webservice。

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

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