User login

Things to note when deciding on values to use for whttp:location (xmlns:whttp="http://www.w3.org/ns/wsdl/http")

Story :

Level :

This KB gives you a few guidelines to for selecting whttp:locations for your operations. Please refer [1] to find out what a whttp:location is.

  • Always have some constant at the start of the template. Axis2 uses this constant along with the HTTP method to dispatch the request to the correct operation. For e.g, do not use templates such as “{name}/{age}”, rather use “someConstant/{name}/{age}”
  • Always have a constant between parameters in the path segment of the URL. For e.g, do not use templates such as “someConstant/{name}{age}” rather use “rxsomeConstant/{name}someSeparator{age}”.
  • Choose the separator such that it will not appear in instance data. For e.g, do not use templates such as “someConstant/{name}abc{age}” rather use “someConstant/{name}/{age}”. Its more likely that “abc” will appear in instance data rather than “/”.
  • Do not include optional parameters into the path segment, rather have them as query parameters. For e.g, if age is an optional parameter do not use a template such as “someConstant/{name}/{age}” rather use “someConstant/{name}” so that age will be in the query part of the URL.
  • Do not expose two operations over the same HTTP method when they have the same constant part at the start of the template. For e.g, “someConstant/{foo}” and “someConstant/{bar}”. Do not expose the above operations over the same HTTP method. Either change the HTTP method or the constant. 

Following these guidelines will ensure that the server is able to dispatch the request to the correct operation depending on the HTTP method and the request URL.

[1] http://wso2.org/library/3715

Author: Keith Chapmon, Senior Software Engineer, WSO2 Inc. keith at wso2 dot com

 

0
No votes yet
Tags :