Encoded vs Literal, RPC vs Document

我一直没有分清题目里所写的概念,看过JAX-RPC规范后还是模糊,原因主要是对XML本身就没有特别深入的理解。不过现在感觉好象明白了一些。

Encoded和Literal是两种Typing system,前者对应http://schemas.xmlsoap.org/soap/encoding/,后者利用XML Schema定义数据类型。

“Literal对应于types中的element只有一层,Encoded对应于types中element多层的。

用Literal描述的参数客户必须提供明确的参数名,用Encoded描述的参数客户可以用param1,param2,param3等代替。”

在Axis中,使用org.apache.axis.description.OperationDesc类指定自己要使用的方式,方法如下:

“oper.setStyle(org.apache.axis.enum.Style.DOCUMENT); oper.setUse(org.apache.axis.enum.Use.LITERAL);,这个是对于document方式的,如果是rpc方式应该设置为:oper.setStyle(org.apache.axis.enum.Style.RPC); oper.setUse(org.apache.axis.enum.Use.ENCODE);”,然后还要用call.setOperation(oper);把OperationDesc对象实例和Call对象联系起来。

----赵晓冬

关于RPC和Document的比较,这里有两篇不错的文章:Operation Style (Document/RPC) and Message format(literal/encoded)The Difference Between RPC and Document Style WSDL

搬家前链接:https://www.cnblogs.com/bjzhanghao/archive/2004/12/06/73517.html