The location property which is defined under the WSDL 2.0 HTTP Binding Namespace (http://www.w3.org/ns/wsdl/http) specifies a pattern for serializing input message instance data into the request URI.
Elements from the instance-data of the input message can be cited in the URL by enclosing the element name within curly braces. For example, "studentService/student/{name}". This would mean that the name element in the instance data should be serialized in the URL. Assuming the instance data had "<name>keith</name>" the URL would be “studentService /student/keith”.
Lets take another example where we have multiple input parameters, Here we are exposing an operation named getBooks which has three input parameters author, publisher and numberOfResults. The schema that defines this input message would be,
<xs:complexType name="getBooksType">
<xs:sequence>
<xs:element name="author" type="xs:string"/>
<xs:element name="publisher" type="xs:string"/>
<xs:element minOccurs="0" name="numberOfResults" type="xs:int"/>
</xs:sequence> </xs:complexType> <xs:element name="getBooks" type="ws:getBooksType"/>
Lets assume the instance data is
<getBooks>
<author>deepal</author>
<publisher>packtpub</publisher>
<numberOfResults>10</numberOfResults>
</getBooks>Assume that whttp:location=”bookService/books/{author}/{publisher}. In this case the request URL would be bookService/books/deepal/packtpub?numberOfResults=10. As the http location property explicitly stated that author and publisher should appear in the path segment of the URL they are serialized as such. Nothing was mentioned about numberOfResults, hence it appears as a query parameter.
Assume that whttp:location=”bookService/books/{author}. In this case the request URL corresponding to this would be bookService/books/deepal?publisher=packtpub&numberOfResults=10. Here both publisher and numberOfResults appear as query parameters.
This essentially shows how you make your operation available at a dynamic URL using the whttp:location property.
Author: Keith Chapmon, Senior Software Engineer, WSO2 Inc. keith at wso2 dot com