What is whttp:location? (xmlns:whttp="http://www.w3.org/ns/wsdl/http")

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”.

Date: Wed, 18th Jun, 2008
Level: Intermediate
Reads: 8173 Comments: 3 | Login or register to post comments
Kieth Chapman

WSO2 Inc.

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

 

gavinwilliams's picture

The blog is going to be very

The blog is going to be very much helpful for all I guess. The WSDL is the model for describing the web service and as far as I know WSDL2.0 is quite different than WSDL 1.1 as it’s much simpler to use. Here some very simple and easy examples are made which has shown us how we can make our operation available at a dynamic URL using the WHTTP: location property. Thanks a lot for this useful post. ____________________ Gavin @ koozie
johnthomas's picture

Great you giving tips to

Great you giving tips to make operations available at a dynamic URL using the whttp:location property. It’ll be of great help of many. Thanks for using examples for clarification, specially thanks for showing the process how to deal with when there are multiple input parameters. ------------------John@ apostille
restnewbie's picture

URL for a complextype input argument

Hi,   My service has a method with signature :   String getProducts(SearchParams params);  where SearchParams is made up of simple Strings, like : <pre> <xs:complexType name="SearchParams">       <xs:sequence>    <xs:element name="srcsystem" type="xs:string"/>           <xs:element minOccurs="0"name="productcodes" type="xs:string"/>           <xs:element minOccurs="0"name="producttype" type="xs:string"/>           <xs:element minOccurs="0" name="numberOfQuotes" type="xs:int"/>       </xs:sequence>   </xs:complexType> <pre> I've followed the REST with Axis2 tutorial and whttp:location=products/{srcsystem}/{productcodes}.. etc   Going by the definition, the URL should be http://mysite.com/ProductService/products/abc?productcodes=X&producttype=Y  etc.   However, on invoking the service like this, it gives an "index out of bound" error <faulstring>   I've another getAllProducts() operation on this service with whttp:location=products - and this works fine.   Please let me know what i may be missing in the mapping?  
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)