📄 burlap-notes.xtp
字号:
<p>XML has two main use patterns: a static syntax described by a DTD (documenttype descriptor), and an extensible syntax using XML namespaces andpresumably defined by an XML schema. XML-RPC choose the DTDand SOAP choose XML schema. Burlap choose the DTD.</p><p>A major advantage of the DTD choice is that any Burlap request orresponse is verifiable without any external schema. The DTD definesthe entire grammar for Burlap. So a tester can use that grammar to validatethat a Burlap client or server is conformant. The grammar serves asa testplan.</p><p>The schema route gives more flexibility without adding expressive power.The same object might have two different serializations if theXML schema differs. With Burlap or XML-RPC, the class has aunique serialization. With SOAP the different representations leave openthe possibility of interoperability issues.</p></s2><s2 title="Object Identifiers (URL)"><p>Burlap uses a URL to locate the server object. Usually, this willbe an HTTP url, but nothing in the Burlap protocol requires theuse of HTTP. Since URLs are sufficient and already familiar, it seemsobvious to use them.</p><p>An advantage of the particular encoding used forEJB is that intelligent load balancers can use it to direct therequest to an owning server. It's not required that the URL forBurlap servers follow the same conventions as the EJB encoding. Inthe EJB encoding, the bean home interface is also a URL, easilydetermined by removing the object identifier as the last name. Thismakes getting meta information easier.</p><p>XML-RPC, in contrast, uses a combination of an HTTP URL and anobject identifier embedded in the request. The object identifier ispart of the <methodName> item.</p><example title="http://host/RPC2"><?xml version="1.0"?><methodCall> <methodName>examples.getStateName</methodName> <params> <param> <value><i4>41</i4></value> </param> </params></methodCall></example><p>SOAP also uses the URL to identify the target object. The primarymodel for SOAP appears to be more service-based rather thanobject-based. In other words, it appears that most SOAP servers willonly have a single URL and not have separate URLs for objectinstances. In constrast, Burlap heavily uses sub-URLs (path-info) toidentify object instances. Nothing in the SOAP protocol precludesusing sub-URLs, so this isn't a limitation of the SOAP spec. It justappears to be counter to the culture of SOAP to use lots of URLs. Asthe SOAP spec says, objects-by-reference are not part ofthe SOAP specification.</p></s2><s2 title="Method Selection and Overloading"><p>Since EJB requires method overloading, Burlap supports it. Burlapimplements method overloading with "method name mangling". The typeof the method arguments becomes part of the method name. To supportsimpler clients, like script-based clients, one of the methods willalso typically respond to an unadorned method.</p><example title="add(2,3) call"><burlap:call> <method>add_int_int</method> <int>2</int> <int>3</int></burlap:call></example><p>Because Burlap's encoding is lossy, some overloaded methods areindistinguishable. For example <var>add(int)</var> and <var>add(short)</var>are both encoded as integer argument. So only the integer versionwill be callable. The main reason for the lossy limitation is tomake Burlap less Java-dependent. <var>int</var>, <var>long</var>, and<var>double</var> are supported by most languages. We expect this won'tbe a large limitation. Few objects have methods with aliased methods.</p><p>XML-RPC doesn't specifically address this issue. Since itsmethod selection is very similar to Burlap's, name mangling wouldbe easy to implement in XML-RPC.</p><p>SOAP's method selection is very different. Each method has itsown XML element and namespace, presumably defined in some externalschema. It could also support overloading with mangled elementnames. SOAP adds additional complexity to the method call with theaddition of a namespace. It's not clear what value this adds, otherthan additional complications, more tests, and interoperabilityissues.</p><p>Since a service/remote-object has a single set of methods,selecting the object implicitly selects the method set or objectsignature. In theory, namespaces would allow a client to choose adifferent object signature, but it's not clear what application wouldneed that. Java and EJB doesn't need that complexity.</p><example title="SOAP add(2,3) call">...<m:add xmlns:m="http://www.caucho.com/soap/calculator"> <a>2</a> <b>3</b></m:add>...</example></s2><s2 title="Method Parameters"><p>Burlap method parameters are order-based like Java and essentiallyevery major programming language. The number of parameters is fixedfor each method. Varying-length parameters and extra parameters areforbidden. It's easily tested, unambiguous, and it's easy to write a fastparsers. The choice seems obvious and hardly worth discussion, butSOAP dismissed position-based arguments.</p><p>SOAP's method arguments are named by scheme-defined elements andcan appear in any order:</p><example>...<m:myMethodCall xmlns:m="my-namespace"> <z>13</z> <a>4</a> <m>13</m></m:myMethodCall></example><p>For an EJB-implementation, the SOAP method arguments createsseveral problems. What name should the first argument be given? Doesa client need an external schema or IDL to map the SOAP argument tothe function call? How intelligent does a client or server have to beto handle all the possible argument name assignments? And how can allthis be tested? The SOAP designers must have had some reason for thischoice, but it directly opposes the needs of an EJB server and client.</p></s2><s2 title="Inheritance (<type>)"><p>Although most of Burlap's design avoids Java-specific requirements,solving the inheritance problem requires the deserializer know whatJava class to create. Burlap's solution makes Java implementationseasy, but doesn't significantly impede other languages and isno less language-independent than SOAP or XML-RPC.</p><p>Since Java is an object-oriented language, the type of a value may notequal the declared type. For example, an Object field might contain aCar object or a Truck object. To serialize the Car or Truck, Burlapneeds to add the object type in the protocol. XML-RPC, in contrast,has no accompanying type information, so a Java XML-RPC implementationcan't to create a Car from information in the protocol. The Java serializeralso need to know if an array will be a Java array, Vector, orArrayList. That's done with the <type> tag in <list> and <map>.</p><example><map><type>com.caucho.example.Car</type><string>color</string><string>red</string></map></example><p>This is a thorny problem. The serializer must know the Java type,but we'd prefer to keep Java-specific information out of theprotocol. Burlap's solution allows non-Java clients with alittle extra work, and makes Java implementations easy.</p><p>The heart of the problem how to map a type key in theprotocol to a language-specific type. That map might appear in arepository, in some external schema like IDL, or it can be encodedin the protocol itself for a specific language. Some simple clientsmay not need this mapping. A simple client in Perl, JavaScript orJava client might use generic types, like ArrayList and Hashtables toread the serialized values. When they write request to a Java server,they'll need to add the type, but protocol writing is much easier thanprotocol parsing.</p><p>It's not clear whether SOAP uses an external schema or arepository service (<a href="http://www.w3.org/TR/wsdl">WSDL</a>) tomap to language types, but it's clear something external is required.The following is a typical SOAP serialization of the Car:</p><example title="Car in SOAP"><e:Car xmlns:e="http://www.caucho.com/soap/cars.xml"><color>red</color></e:Car></example><p>How do you map from "e:Car" with namespace"http://www.caucho.com/soap/cars" to the Java classcom.caucho.example.Car? Since that's not part of the SOAP spec, theremust be an additional spec defining that mapping. Since ourrequirements required a testable implementation (repository is extrawork), no external IDL (so schema is out), the technique used by SOAPwas not appropriate for Burlap.</p><p>Burlap doesn't preclude clients in other languages from usingtheir own types. It would just require the addition of a repositoryservice or an external IDL. In other words, it's no more complicatedthan the type lookup SOAP requires for every language. So Burlapmakes Java implementation easy, but doesn't make other languages hard.When a Python client first encountered a "com.caucho.example.Car", it couldeither use "Car" as a Python type, or query some yet-to-be-definedservice mapping to Python. In other words, it's a trade-off, but it'sunavoidable and we believe the solution is fair to other languages.</p></s2><s2 title="Shared References (<ref>)"><p>Shared references are an integral vital for serializing anysignificant data structure. Serializing a tree, for example, needs tolink a node's children and the parent in a circular set ofreferences. Shared references are one of the necessary capabilitiesmissing from XML-RPC that Burlap adds.</p><p>Burlap implements shared references with an implicit array of all<list> and <map> objects. Linking to an old object can thenjust refer to the object's position in the array. An advantage ofBurlap's approach is that it only requires a single pass through theobject.</p><example title="Burlap References"><map> <type>com.muggle.Car</type> <string>model</string> <string>Ford Anglia</string></map>...<map> <type>com.muggle.Person</type> <string>name</string> <string>Arthur Weasley</string> <string>car</string> <ref>1</ref></e:Person></example><p>SOAP takes a different approach for shared references. Declaring an objectuses an <var>id</var> attribute and referring to the object uses a<var>href</var> attribute:</p><example title="SOAP references"><e:Car id="1"> <e:Model>Ford Anglia</e:Model></e:Car>...<e:Person> <e:Name>Arthur Weasley</e:Name> <e:Car href="1"/></e:Person></example><p>The SOAP approach has the advantage that the receiving serverdoesn't need to keep track of every object it's received. Inaddition, it can refer to any object, including strings. With Burlap,only <map> and <list> can share references, strings and bytearray can't be shared. As a disadvantage, SOAP requires two passesover the object before sending it and SOAP's approach requires theuse of XML attributes.</p></s2></s1><s1 title="Conclusion"><p>The Burlap design aimed at reducing the testing and implementationcomplexity, and should give decent performance. Because Burlap is awire protocol, EJB users don't care about the protocol details and wecould tailor Burlap to the specific requirements needed to supportEJB.</p><p>The small size of the Burlap specification should not be confusedwith its expressive power. Burlap is fully capable of handlingJava/EJB calls. The added complexity and "flexibility" of aspec like SOAP just introduces ambiguity and adds to the testingrequirements without adding expressive power.</p></s1> </body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -