The Attribute Getter/Setter Pattern:

 

Roberto Chinnici, Steve Graham, Umit Yalcinalp, Oct 6, 2003

(edited by William Vambenepe on Oct 27, 2003)

 

The following are the rules associated with the attributes “style” of demarcating getter/setter operations in WSDL 2.0. These rules represent sgg’s notes and recollection of discussion on the ATF telecon of Oct 6, 2003.

 

Roberto posted an “example” collection of XML fragments [1].  The contents of this email are included here.

 

1.      The attribute itself can be any XML Global Element Definition.

// this is the attribute

 

<xs:schema targetNamespace="Attributes">

   <xs:element name="YYY">

     <xs:complexType>

       <xs:sequence>

         <xs:element name="a" type="xsd:int"/>

         <xs:element name="b" type="xsd:float"/>

       </xs:sequence>

     </xs:complexType>

   </xs:element>

</xs:schema>

 

2.      Attributes are exposed in the component model using specially marked Operations: 

// these are the operations

 

<ws:definitions targetNamespace="MyService">

 

   <ws:interface name="MyInterface"

            xmlns:wrappers="Wrappers">

 

     <ws:operation

          name="get_XXX"

          style="http://www.w3.org/@@@@/@@/wsdl/style/get-attribute"

          pattern="http://www.w3.org/@@@@/@@/wsdl/in-out">

       <ws:input name="in" body="wrappers:get_XXX"/>

       <ws:output name="out" body="wrappers:get_XXXResponse"/>

     </ws:operation>

 

     <ws:operation

          name="set_XXX"

          style="http://www.w3.org/@@@@/@@/wsdl/style/set-attribute"

          pattern="http://www.w3.org/@@@@/@@/wsdl/in-out">

       <ws:input name="in" body="wrappers:set_XXX"/>

       <ws:output name="out" body="wrappers:set_XXXResponse"/>

     </ws:operation>

 

   </ws:interface>

</ws:definitions>

 

a.       The name of the operations must follow a pattern:

                                                   i.      get_Ψ (for the getter operation) and set_Ψ (for the setter operation).

                                                 ii.      Ψ should be the name of the attribute, but need not be.  Reasons for this include: namespace collisions (same attribute, different namespaces would yield operation namespace collisions).

b.      The value for @style of the get operation must be:  "http://www.w3.org/@@@@/@@/wsdl/style/get-attribute"

c.       The value of the @style of the set operation must be:  "http://www.w3.org/@@@@/@@/wsdl/style/set-attribute"

d.      For both the get and set operation, the value of @pattern must be: "http://www.w3.org/@@@@/@@/wsdl/in-out"

These are the message definitions:

// these are the request and response messages for the getter

 

<xs:schema targetNamespace="Wrappers"

            xmlns:attrs="Attributes">

 

   <xs:element name="get_XXX">

   </xs:element>

 

   <xs:element name="get_XXXResponse">

     <xs:complexType>

       <xs:sequence>

         <xs:element ref="attrs:YYY"/>

       </xs:sequence>

     </xs:complexType>

   </xs:element>

 

   <xs:element name="set_XXX">

     <xs:complexType>

       <xs:sequence>

         <xs:element ref="attrs:YYY"/>

       </xs:sequence>

     </xs:complexType>

   </xs:element>

 

   <xs:element name="set_XXXResponse">

   </xs:element>

</xs:schema>

 

 

3.      The values of the in and out messages must follow these rules:

a.       The “attribute” associated with the get or set operation is identified by:

                                                   i.      The XML GED identified by the @ref of the element within the get response message or the @ref of the element within the set request message. The Qname value of the @ref in either case uniquely identifies the attribute

b.      For any given value of Ψ, the attribute associated with the get_Ψ and set_Ψ operation MUST be the same

                                                   i.      It is illegal to have operations named get_ Ψ and set_ Ψ where the attribute associated with those operations are different

                                                 ii.      If there is both a getter and a setter for an attribute, they must be called get_Ψ and set_Ψ  with the same value of Ψ.

                                                iii.      There cannot be more than one getter or more than setter associated with the same attribute.

4.      the actual messages of the get and set operations must follow these rules:

a.       The element corresponding to the get request body element must have empty content and must not include any XML attribute.

b.      The element corresponding to the get response body element must contain a single child element. The child element must reference the attribute’s XML global element definition. The child element contains the current value of the attribute. The child element must not include any XML attribute.

c.       The element corresponding to the set request body element must contain a single child element. The child element must reference the attribute’s XML global element definition. The child element contains the “new” value of the attribute which “replaces” any previous value. The child element must not include any XML attribute.

d.      The element corresponding to the set response body element must have empty content and must not include any XML attribute.

e.       The response of the get message or set message may contain outfault child elements.

 

 

 

 

 

 

 

 

[1] http://lists.w3.org/Archives/Public/public-ws-desc-state/2003Oct/0005.html