EncodedvsLiteral,RPCvsDocument

青夜之衫發表於2017-12-06

我一直沒有分清題目裡所寫的概念,看過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

本文轉自部落格園八進位制的部落格,原文連結:Encoded vs Literal, RPC vs Document,如需轉載請自行聯絡原博主。