Java与.net异构平台上web service间复杂对象的互操作

     最经在忙于研究一个Java开源项目,此开源项目是基于SOA架构的,所有提供的服务需要由.net客户端来访问。一直以为web service是除了一点点性能问题,简直就是万能的,但经过这次的磨练,终于明白了,世界并没有想象中的那么完美。。。好了,入正题。本文主要描述如何通过Web Service实现在异构平台中访问平台特定的对象。以下是此次研究的一些零散总结。

     W3C XML模式标准定义了一系列内置的数据类型,其中包括各种不同长度的字符串,整型,布尔型,单精度,双精度,浮点型,时间型和其他类型。每种应用平台都支持一系列自己的数据类型。这些数据类型设置的交集定义了跨越不同平台的具有协同能力的类型。所以,一个.NET客户端能够将XML元素识别为记录集,这并不意味着一个用Java写的Web service客户端可以做同样的事情。

     首先,先说说web service的开发方式:1.执行优先"或者 "代码优先" ,即以代码完成功能入手,先开发接口功能,然后依靠.net或java的WSDL框架,生成wsdl描述文件。缺点:部分非公共类型难于映射到异构平台上。2."WSDL 优先"或"模式优先",即以wsdl文件入手,先构建wsdl文件,然后开发实现web service和客户端。这样可以一定程度上增加数据类型跨平台的可能性。

     开发.net web service,我们必须认识到ASMX文件是真实的Web service。你看到的页面源自于框架,它是为了证明Web service,并可以允许开发者不用手动创建客户端应用程序就可以测试Web service。这个测试的功能仅用于浏览本地页面,并且当向Web services输入复杂数据类型作为参数时此功能将不可用。

执行下列命令可以使得wsdl.exe产生Web service源代码文件。

wsdl.exe /server WebService1.wsdl

SOAP messages can have one of two encoding styles:

  • Encoded style follows the encoding rules specified in Section 7 of the SOAP specification; basically, these rules dictate the content of the SOAP <Body> element, and require that a data type be specified for each element included in a SOAP request or response message.
  • Literal style does not follow the rules in any particular specification. The content of the <Body> element must be agreed upon and implemented in both the service and client implementations. Literal-encoded SOAP messages do not necessarily specify a data type for each element, and it is usually up to the receiver to decide how each parameter should be translated into its own data types.

(待续)

 

参考文章:

http://msdn.microsoft.com/zh-cn/library/aa700847.aspx

http://msdn.microsoft.com/en-us/library/aa478995.aspx

http://wiki.apache.org/ws/FrontPage/Axis/DotNetInterop

http://wiki.apache.org/ws/FrontPage/Axis/DotNetInteropMapInfo(java中Map对象到C#)

原文地址:https://www.cnblogs.com/andy65007/p/1328488.html