×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:HTTP service V2 in WidSets

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix links)
 
Line 26: Line 26:
  
 
== The service ==
 
== The service ==
With the HTTP service the script can execute HTTP GET and HTTP POST methods. If the MIME type of the response is human readable text ("text/..."), the response is a string, otherwise it is binary. The output of the HTTP service can be processed with a filter. (See [[Advanced filters]].)
+
With the HTTP service the script can execute HTTP GET and HTTP POST methods. If the MIME type of the response is human readable text ("text/..."), the response is a string, otherwise it is binary. The output of the HTTP service can be processed with a filter. (See [[Archived:Advanced filters]].)
  
 
'''The HTTP service can have the following ''service parameters'' that are configured in the XML configuration:'''
 
'''The HTTP service can have the following ''service parameters'' that are configured in the XML configuration:'''
Line 37: Line 37:
 
   <tr>
 
   <tr>
 
     <td>auth</td>
 
     <td>auth</td>
     <td>When using TOKEN authentication, the service id of the tokenauth type service must be set here. (See [[Integrating WidSets with Web Sites#Token authentication | Token Authentication]] for an example.)</td>
+
     <td>When using TOKEN authentication, the service id of the tokenauth type service must be set here. (See [[Archived:Integrating WidSets with Web Sites#Token authentication]] for an example.)</td>
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
Line 199: Line 199:
  
 
== See also ==
 
== See also ==
* [[WidSets - Getting content with Services]]
+
* [[Archived:WidSets - Getting content with Services]]
 
* [[Archived:Available content fetching services]]
 
* [[Archived:Available content fetching services]]
** [[Syndication service]]
+
** [[Archived:Syndication service in WidSets]]
** [[Webfeed service]]
+
** [[Archived:Webfeed service in WidSets]]
** [[HTTP service]]
+
** [[Archived:HTTP service in WidSets]]
 
* [[Archived:Fetcher details in WidSets]]
 
* [[Archived:Fetcher details in WidSets]]
 
** [[Archived:Feed formats in WidSets]]
 
** [[Archived:Feed formats in WidSets]]
** [[HTTP authentication]]
+
** [[Archived:HTTP authentication in WidSets]]
 
* [[Archived:Advanced filters]]
 
* [[Archived:Advanced filters]]
** [[WidSets Filter expressions reference]]
+
** [[Archived:WidSets Filter expressions reference]]
  
 
[[Category:WidSets]]
 
[[Category:WidSets]]

Latest revision as of 09:31, 29 June 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Article
Created: User:Mirsilla (28 May 2008)
Last edited: hamishwillee (29 Jun 2012)
FNWID.gif

This is version 2 of HTTP service. To use it in non-generic calls you must specify the attribute version="2" in widget.xml:/widget/services/service or in generic calls directly in the call (see call documentation.)

Contents

[edit] The service

With the HTTP service the script can execute HTTP GET and HTTP POST methods. If the MIME type of the response is human readable text ("text/..."), the response is a string, otherwise it is binary. The output of the HTTP service can be processed with a filter. (See Archived:Advanced filters.)

The HTTP service can have the following service parameters that are configured in the XML configuration:

Service parameter Function
auth When using TOKEN authentication, the service id of the tokenauth type service must be set here. (See Archived:Integrating WidSets with Web Sites#Token authentication for an example.)
url When using the exec action the URL must be specified here.
method When using the exec action the METHOD can be specified here. If it is not specified, the default method will be GET.


HTTP service has three actions that are called from the script code:

Service action Function
exec Exec executes a pre-specified HTTP GET or POST to an URL given in the widget.xml. The method can be specified there also.
get Get executes a HTTP GET to the URL specified.
post Post executes a HTTP POST to the URL specified.

With get, post, and exec actions, additional request parameters can be added. In get only the string type parameters are appended to the querystring, and in post depending on the nature of the parameters they are either sent as:

Content-Type: application/x-www-form-urlencoded; charset=utf-8

when all parameter values are strings

OR

Content-Type: multipart/form-data

when there are also other types of parameter values than strings. The values of other types must be accompanied with the MIME type of the data.

[edit] exec action

The exec action maps to either HTTP GET or HTTP POST depending on its configuration. The exec action differs from get and post actions so that the URL cannot be given in the request (the call coming from the WidSets client). It has to be pre-specified in the widget.xml. The only input exec takes is the request parameters.

With the exec action it is possible to hide the URL to the destination. The URL can contain a token or some credentials to identify the call coming from WidSets. If the parameter in widget.xml is specified as visible=false, editable=false and sendmobile=false it will not be visible or delivered to the mobile client. A certain business-to-business API could be implemented this way.

[edit] get and post actions

Both get and post actions take the same kind of input. Get maps to HTTP GET and post maps to HTTP POST. The only required parameter in both actions is url. Other optional parameters are:

  • enccharset - The charset used for URLEncoding.
  • returnheaders - The result will contain the HTTP headers the remote server sent.
  • returnstatus - The result will contain the HTTP status code the remote server responed with.
  • headers - Custom headers can be included in this list.

[edit] Service actions

The following are the specifications for the available service actions.

#!format=registry; charset=ISO-8859-1


namespace "2" is ContentHandler
{

  ActualContent = (choice (string textContent)
                          (bytes dataContent)
                          (any filteredData)
                          (null noData))

  Headers = (list (repeat (bind (string name) (string value))))

  Content = (list (bag (required (bind (const content) (use ActualContent)))
                       (optional (bind (const status) (int statusCode)))
                       (optional (bind (const headers) (use Headers)))))


  FetchInput = (list (bag (bind (const url)
                                (string urlToFetch))
                          (optional (bind (const params)
                                          (list (repeat (use RequestParameter)))))
                          (optional (bind (const enccharset)
                                          (string urlEncCharset)))
                          (optional (bind (const returnheaders)
                                          (boolean returnHeaders)))
                          (optional (bind (const returnstatus)
                                          (boolean returnStatus)))
                          (optional (bind (const headers)
                                          (use Headers)))))


  RequestParameter = (bind (string paramName)
                           (choice (string paramValue)
                                   (int paramValue)
                                   (boolean paramValue)
                                   (list (string mimeType)
                                         (bytes data))))


  namespace exec is ContentAction
  {
    input = (list (repeat (use ../RequestParameter)))
    output = (use ../Content)
    generic = false
  }


  namespace get is ContentAction
  {
    input = (use ../FetchInput)
    output = (use ../Content)
    generic = true
  }


  namespace post is ContentAction
  {
    input = (use ../FetchInput)
    output = (use ../Content)
    generic = true
  }


}

[edit] Example widget.xml configuration for the exec action

<services>
  <service type="http" version="2" id="docall">
    <reference from="url" to="url" />
    <reference from="method" to="method" />
  </service>
</services>

<parameters>
  <parameter name="url" visible="false" editable="false" protected="true" sendmobile="false">
    <value>http://www.widsets.com/secret_test.php?username=antti</value>
  </parameter>
  
  <parameter name="method" value="get" /> 
</parameters>

[edit] Changes to the previous version

  • exec action added
  • In get and post actions there is the option to receive HTTP headers and the status code.

[edit] See also

This page was last modified on 29 June 2012, at 09:31.
44 page views in the last 30 days.
×