Last week we announced Beta2 release of Project Siena where we unveiled our mission to make consuming services as easy as an Excel function. Please see S. Somasegar's blog post for more details. 
 
In this topic we want to share how we are simplifying consumption of these Services. If you are a developer of a REST-based service, this article is for you. It introduces the basic concepts and building blocks necessary to describe your service and its resources for your business users. Once described, business users can connect and consume these services as functions within Siena by simply importing them. This article assumes you have experience with basic HTTP and XML concepts involved in web development. 
 
A REST-based service comprises of a resource and the methods you can call on it. Below is a sample schema for a service description using Web Application Description Language (WADL): 


<application>
    <siena:header/>
    <resources>
        <resource>
            <method>
                <request/>
  
                <response/>
            </method>
        </resource>
    </resources>
</application>

Let's walk through describing the sample schema and it's components using WADL.
 
Application and Siena Header
The <application> element forms the root of a WADL description. This is how you start a WADL description for your service. Here's an example of a sample <application> element: 
 
             xmlns:siena="http://schemas.microsoft.com/MicrosoftProjectSiena/v1/WADL"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xh="http://www.w3.org/1999/xhtml"
             >

The <siena:header> element is used to describe the file and format version for the service description. Here's an example of a sample <siena:header> element:
 
<siena:header serviceid="BingTranslator" author="ProjectSiena" fileversion="1.0" formatversion="1.0" />

 Attribute   Description  Required/Optional
 serviceid  The namespace under which this functionality will be imported.   Required
 author  The creator of this file.  Required
 formatversion  The version of the current file format.   Optional
 fileversion  The version of the current file.  Optional

The <application> and <siena:header> elements are required.
 
Resources
When accessing a REST resource, a typical starting point is a Resource URI also known as a REST endpoint. For example, here are some REST service Resource URI's for Bing Translator:
  • http://api.microsofttranslator.com/v2/Http.svc/Speak
  • http://api.microsofttranslator.com/v2/Http.svc/Translate
In WADL, the <resources> and <resource> elements are used to describe a Resource URI. The complete path name of the resource is generated by concatenating the value of the base attribute in the <resources> element and the value of the path attribute in the <resource> element. 
 
The <resources> element contains one attribute, base, that defines the domain and the base path of the URI. Here's an example of a resources element for the Bing Search service:

</resources>

Resource
Each <resources> element contains one or more <resource> elements. A <resource> element has a path attribute that specifies the path to that resource, relative to the resources' base url. The following are two examples of <resource> elements for the Bing Translator service: 

   <resource path="Speak">…</resource>
   <resource path="Translate">…</resource>
</resources>


The above <resources> element and nested <resource> elements together describe the following Resource URI's:
http://api.microsofttranslator.com/v2/Http.svc/Speak
http://api.microsofttranslator.com/v2/Http.svc/Translate

 
<param> (as a child of <resource>)
The value of the path attribute on <resource> element can be static, or it can be templated and described using a <param> element.  Here's an example of a templated path attribute ({userid}) for describing Photo Albums for a specific Facebook user:

<resources base="https://graph.facebook.com">
  <resource path="{userid}/albums">
      <param style="template" name="userid" required="true" siena:sampledefault="me"/>
      
  </resource>
</resources>

The above describes the following Resource URI where userid is templated:
https://graph.facebook.com/{userid}/albums
 
The common attributes used for <param> elements directly under the <resource> element:

 Attribute                 Description  Required/Optional
 style Defines where the param's value should be placed in the corresponding HTTP request. Only "template" value is supported in Beta2.
- template: The value is placed in the path section of the <resource> element using the 'name' as the     key. 
 Required
 name The name of the template param.  Required
 type Defaults to string. The type of the value as expected by the server. Any value passed into the  function will be converted to a value of that type before being added to the HTTP request.
 Optional
 required Defaults to false. When true, it indicates that the param is required to be specified.
 
If no value is given to the param via the fixed attribute, Siena will require this param by adding an explicit parameter for the function.
 Optional

 fixed The value to use for the param. Siena will not allow the author to specify or override this value and will always be used when creating the HTTP request.  Optional

 siena:sampledefault 

Defaults to false. This is a custom flag that tells Siena to use as the default value for the 'Try It' functionality in the backstage.  Optional

We will talk more about <param> as part of the <request> element. 

Methods
Methods associated with a REST resource are described using the <method> element. A <resource> element can have one or more <method> elements as its children. 
 
The <method> element basically describes an HTTP protocol method that can be applied to the REST resource. 
 
 Attribute   Description  Required/Optional
 id  The unique identifies for this method  Required
 name  The type of HTTP method used. Supported values are: GET, POST, DELETE or PUT  Required

Here's an example of a <method> element for Bing Search:

    <resource path="Speak">
      <method name="GET" id="Speak">
       ….
      </method>
    </resource>
</resources>

Each described method is displayed as a function within Siena once the services description is imported. 
 
Request
A <request> element is used to describe the input for an HTTP Method. It is a required child element of a <method> element.
 
Param (as a child of <request>)
The <request> element contains 1 or more child <param> elements that are used to define the input parameters of an HTTP request. The following are two examples of <param> elements as children of a <request> element for Bing Translator and Bing Search: 

Translator
   <resource path="Speak">
     <method name="GET" id="Speak">
       <request>
         
         <param name="text" style="query" required="true" siena:sampledefault="welcome"/>
         <param name="language" style="query" required="true" siena:sampledefault="en"/>
         <param name="format" style="query" required="false"/>
         <param name="options" style="query" required="false"/>
       </request>
       ….
       </response>
     </method>
   </resource>
</resources>

Search
   <resource path="Web">
     <method name="GET" id="Web">
       <request>
         <param style="header" name="Authorization" required="true" fixed="l2kje2lejsorjsoefjsrlginsrfl8="/>
         <param style="header" name="Accept" required="true" fixed="application/json"/>
         <param style="header" name="Accept-Charset" required="true" fixed="UTF-8"/>
         <param style="query" name="Query" required="true" siena:quoted="single"/>
         <param style="query" name="$top" type="xs:int" required="false"/>
         <param style="query" name="$skip" type="xs:int" required="false"/>
       </request>
       ….
       </response>
     </method>
   </resource>
</resources>

 Attribute   Description  Required/Optional
 style Defines where the param's value should be placed in the corresponding HTTP request.
- header: The value is placed in the header section of the request using the 'name' as the key.
- query: The value is placed as a query parameter on the url sent to the server.
 Required
 name The name of the query parameter or header.  Required
 type Defaults to string. The type of the value as expected by the server. Any value passed into the function will be converted to a value of that type before being added to the HTTP request.
 Optional
 required Defaults to false. When true, it indicates that the param is required to be specified.

If no value is given to the param via the fixed attribute, Siena will require this param by adding an explicit parameter for the function.
 Optional

 fixed The value to use for the param. Siena will not allow the author to specify or override this value and will always  be used when creating the HTTP request.  Optional

 siena:quoted

This is a custom flag that tells Siena to wrap the value of the argument with single quotes.   Optional

Representation (as a child of <request>)
A <representation> element is used to describe the body of the input of a HTTP request. Here's an example of the <representation> element: 
 
<representation mediaType="application/json">
  <param style="plain" name="name" required="true" path="/name" fixed="John Doe" />
  <param style="plain" name="title" required="true" path="/title" fixed="Sales" />
  <param style="plain" name="homephone" required="true" path="/phones/home" fixed="555-0001" />
  <param style="plain" name="workphone" required="true" path="/phones/work" fixed="555-0002" />
</representation>

 
The above <representation> element would produce the following JSON data in the request body. This is how JSON data can be sent as the body of an HTTP request:
{
  "name": "John Doe",
  "title": "Sales",
  "phones": {
    "home": "555-0001"
    "work": "555-0002"
  }
}

 Attribute   Value   Description   Optional/Required
 mediatype    The HTTP media type (or content type) of the request.  
   multipart/form-data
  • This mediaType is the standard form used for POST requests. Each <param> must have a style attribute of "query". 
  • Each key-value pair is represented in the body of the request according to the HTTP standard for this content type.
 
   application/x-www- form-urlencoded

  • A representation with mediaType of "application/x-www-form-urlencoded" can only have child <param> element that has style values of "query".
  • Each key-value pair is represented in the body of the request according to the HTTP standard for this content type.
 
   application/json

  • Indicates the body of the request is JSON data. The data is composed from the values passed to the <param> elements defined in the representation.
  • Each of these <param> elements must have their style attribute set to "plain". They should also have the path attribute set to the location in the body where the value should be placed.
  • For JSON data, the param's path property is a JSON pointer. The structure of the body is determined by the implied structure expressed in the JSON pointers specified by each param.
  • For requests, the pointer syntax does not support arrays.
 


Here's an example of how to send multipart form-data as the body of the HTTP request for UploadPhoto method in Facebook:
 
   <resource path="{userid}/photos">
     <param name="userid" style="template" required="true"/>
     <method name="POST" id="UploadPhoto" siena:disabletryit="true">
       <request>
        ….
         <representation mediaType="multipart/form-data">
           <param name="source" style="query" type="xs:base64Binary" siena:type="image" required="true"/>
           <param name="message" style="query" required="false"/>
           <param name="placeid" style="query" required="false" />
           <param name="no_story" style="query" type="xs:boolean" required="false" />
         </representation>
       </request>
         …..      
     </method>
   </resource>
</resources>


 Attribute   Value   Description   Optional/Required
 siena:type    The type of the data as interpreted by Siena. This is required when the parameter type is Base64Binary  Required
   image ​ The data will be interpreted as an image binary data.  
   audio  The data will be interpreted as an audio binary data.   

Response
A response is the output that results from performing an HTTP method on a REST resource. A <response> element is used to describe the output. The following are two examples of a <response> element for Bing Search and Bing Translator: 
 
Search 
   <resource path="Web">
     <method name="GET" id="Web">
       <request>
         <param style="header" name="Authorization" required="true" fixed="l2kje2lejsorjsoefjsrlginsrfl8="/>
         <param style="header" name="Accept" required="true" fixed="application/json"/>
         <param style="header" name="Accept-Charset" required="true" fixed="UTF-8"/>
         <param style="query" name="Query" required="true" siena:quoted="single"/>
         <param style="query" name="$top" type="xs:int" required="false"/>
         <param style="query" name="$skip" type="xs:int" required="false"/>
       </request>
       <response siena:resultform="single">
        ……
       </response>
     </method>
   </resource>
</resources>

 Translator 
   <resource path="Speak">
     <method name="GET" id="Speak">
       <request>
         <siena:auth href="#dataMarketAuth"/>
         <param name="text" style="query" required="true" siena:sampledefault="welcome"/>
         <param name="language" style="query" required="true" siena:sampledefault="en"/>
         <param name="format" style="query" required="false"/>
         <param name="options" style="query" required="false"/>
       </request>
       <response siena:resultform="self">
         
       </response>
     </method>
   </resource>
 </resources>


 Attribute   Value   Description   Optional/Required
 siena:resultform   Indicates one of four forms the result of the function should take and how child param elements should be used.  Optional
   void Default. Used when the REST API is not expected to return any consumable data.  
   self The full response body is returned. For example, when the body returned is an image or media file.
Indicates a single typed value is extracted from the body of the response.
 
   single This value is specified via the single param element allowed within the response element.
Indicates multiple typed values should be extracted from the body of the response.
 
   aggregate  This uses one or more param elements to indicate the values to return.  

Representation (as a child of <response>)
A <response> element usually contains child <representation> element. A <representation> element is used to describe the body of the output of a HTTP response. The following are two examples of a <representation> element for Bing Search and Bing Translator:
 
Search
 
   <resource path="Web">
     <method name="GET" id="Web">
        
       <response siena:resultform="single">
         <representation mediaType="application/json">
          ….
         </representation>
       </response>
     </method>
   </resource>
</resources>

 Translator 
   <resource path="Speak">
     <method name="GET" id="Speak">
       <request>
         <siena:auth href="#dataMarketAuth"/>
         <param name="text" style="query" required="true" siena:sampledefault="welcome"/>
         <param name="language" style="query" required="true" siena:sampledefault="en"/>
         <param name="format" style="query" required="false"/>
         <param name="options" style="query" required="false"/>
       </request>
       <response siena:resultform="self">
         <representation mediaType="audio"/>
       </response>
     </method>
   </resource>
 </resources>

 Attribute   Value   Description   Optional/Required
 mediaType   The HTTP media type (or content type) of the response.
The values supported by Siena are: "image", "audio", "application/json", "application/xml"
 Optional
   image Indicates the response is expected to be an image file.
Supported resultform values: "self".
 
   audio Indicates the response is expected to be an audio file. Supported resultform values: "self".  
   application/json Indicates the body is JSON data. Supported resultform values: "aggregate", "single".  
   application/xml Indicates the body is XML data. Supported resultform values: "aggregate", "single".  

Siena:responsetype
For responses that return complex data, it's necessary to convey the types returned to Siena so it can be exposed to the end user of the function. A <siena:responsetype> element is used to convey this when the mediaType is application/json. The types returned by the response are specified via a CDATA section within the <siena:responsetype> element. Here's an example of CDATA section within a <siena:responsetype> element for Bing Search: 
 
<response siena:resultform="single">
  <representation mediaType="application/json">
    <siena:responsetype>
      <![CDATA[
        {
          "resultpath": "/d",
          "resulttype": "ResultsRoot",
          "types": [
            {
              "name": "Root",
              "type": "object",
              "fields": [
                {
                  "name": "d",
                  "type": "ResultsRoot"
                }
              ]
            },
            {
              "name": "ResultsRoot",
              "type": "object",
              "fields": [
                {
                  "name": "__next",
                  "type": "hyperlink"
                },
                {
                  "name": "results",
                  "type": "ResultArray"
                }
              ]
            },
            {
              "name": "ResultArray",
              "type": "array",
              "itemtype": "ResultEntry"
            },
            {
              "name": "Metadata",
              "type": "object",
              "fields": [
                {
                  "name": "uri",
                  "type": "hyperlink"
                },
                {
                  "name": "type",
                  "type": "string"
                }
              ]
            },
            {
              "name": "ResultEntry",
              "type": "object",
              "fields": [
                {
                  "name": "__metadata",
                  "type": "Metadata"
                },
                {
                  "name": "ID",
                  "type": "string"
                },
                {
                  "name": "Title",
                  "type": "string"
                },
                {
                  "name": "Description",
                  "type": "string"
                },
                {
                  "name": "DisplayUrl",
                  "type": "string"
                },
                {
                  "name": "Url",
                  "type": "hyperlink"
                }
              ]
            }
          ]
        }
      ]]>
    </siena:responsetype>
  </representation>
</response>
 
The following example JSON data could be returned in the response body, given the above <responsetype> element: 
 
{
    "d": {
        "results": [
            {
                "__metadata": {
                    "uri": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web?Query='Xbox One'&$skip=0&$top=1",
                    "type": "WebResult"
                },
                "ID": "365476c6-1db2-47fd-ace1-cf4212573dd6",
                "Title": "Xbox One | The All-in-one Entertainmernt System from Xbox ...",
                "Description": "The all-in-one entertainment system. Where the best games, multiplayer, and your favorite movies, music, sports, and live TV come together in one place.",
                "DisplayUrl": "www.xbox.com/xbox-one",
                "Url": "http://www.xbox.com/xbox-one/meet-xbox-one"
            },
            {
                "__metadata": {
                    "uri": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web?Query='Xbox One'&$skip=1&$top=1",
                    "type": "WebResult"
                },
                "ID": "0089a2e8-d676-4313-ac2d-6c609b8cfae5",
                "Title": "Xbox One - Wikipedia, the free encyclopedia",
                "Description": "Xbox One is the successor to Xbox 360, Microsoft's previous video game console, which was introduced in 2005 as part of the seventh generation of video game consoles.",
                "DisplayUrl": "en.wikipedia.org/wiki/Xbox_one",
                "Url": "http://en.wikipedia.org/wiki/Xbox_one"
            }
        ],
        "__next": "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web?Query='Xbox%20One'&$skip=50"
    }
}

Property Description
 Property  Type  Description
 resultpath  JSON Pointer A JSON pointer that identifies where in the body the result should come from. The empty string refers to the root JSON value.
 resulttype  string The type of the value referred to by the resultpath property.
 types  Array of JSON Object Type  Definitions
An array of type definitions for custom complex types used within the response.
 name  string The custom name for the type. This is used by other 'type' properties or the 'resulttype' property to refer to this type.
 type  string One of:
"object" - Indicates the type is an extension of a JSON Object.
 "array" - Indicates the type is an array of a primitive or custom type.

 itemtype

 string  Required when type="array". Specifies the type of each element within the array. It can be either a pre- defined type or a custom type name.
 fields   array Required when type="object". An array of object defining the name and type of each field for the object.
 fields[i].name  string Required. The name of the property on the object.
 fields[i].type  string Required. The name of the type of this property.

Siena:samplexml
For responses that return complex data, it's necessary to convey the types returned to Siena so it can be exposed to the end user of the function. A <siena:samplexml> element is used to convey this when the mediaType is application/xml. A sample xml returned by the response is specified within the <siena:samplexml> element. Here's an example of a <siena:samplexml> element for Bing Translator: 
 
        
<response siena:resultform="single">
          <representation mediaType="application/xml">
            <siena:samplexml>
              <GetTranslationsResponse xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <From>es</From>
                <Translations>
                  <TranslationMatch>
                    <Count>0</Count>
                    <MatchDegree>100</MatchDegree>
                    <MatchedOriginalText/>
                    <Rating>5</Rating>
                    <TranslatedText>an important contribution to the profitability of the company</TranslatedText>
                  </TranslationMatch>
                  <TranslationMatch>
                    <Count>7</Count>
                    <MatchDegree>100</MatchDegree>
                    <MatchedOriginalText>una importante contribución a la rentabilidad de la empresa</MatchedOriginalText>
                    <Rating>1</Rating>
                    <TranslatedText>an important contribution to the company profitability</TranslatedText>
                  </TranslationMatch>
                </Translations>
              </GetTranslationsResponse>
            </siena:samplexml>
          </representation>
       </response>
 
Authentication 
Certain services require the user to be authenticated in order to perform HTTP methods on REST resources. A <siena:auth> element can be used to describe the authentication mechanism. In Beta2, the support is currently limited to OAuth 2.0 client side flows (implicit and client credentials). 
 
Here's an example of a <siena:auth> element for Bing Translator using "clientcredentials": 
 
<siena:auth id="dataMarketAuth"
             type="oauth2"
             granttype="clientcredentials"
             accesstokenstyle="header"
             clientmethodref="#GetToken"/>

 Attribute   Description  Required/Optional
 id A unique identifier for this section  Required
 Type The type of authentication. Currently only "oauth2" is supported  Required

 granttype The OAuth2 grant type that the authentication method uses. Currently on "implicit" and "clientcredentials" is supported  Required
 accesstokenstyle The format of the access token that the service requires.  The format defaults to "Bearer:" when the accesstokenstyle value is "header". The format defaults to "access_token" when the accesstokenstyle value is "query".  Required
 clientmethodref ID of the method which describes the authentication. In the example above, the value "#GetToken" is referring the method "GetToken", which describes the authentication.   Optional

Here's an example of a <siena:auth> element for Yammer service using "implicit" flow:
 
<siena:auth id="yammerAuth"
            type="oauth2"
            granttype="implicit"
            accesstokenstyle="header"
            authurl="https://www.yammer.com/dialog/oauth"
            callbackurl="https://www.microsoft.com"
            clientid="1YV1vIZIFUlZYgd2LeZTg"
            scope="full"
            />

 Attribute   Description  Required/Optional
 id A unique identifier for this section  Required
 Type The type of authentication. Currently only "oauth2" is supported  Required

 granttype The OAuth2 grant type that the authentication method uses. Currently on "implicit" and "clientcredentials" is supported  Required
 accesstokenstyle The format of the access token that the service requires.  The format defaults to "Bearer:" when the accesstokenstyle value is "header". The format defaults to "access_token" when the accesstokenstyle value is "query".  Required
 authurl The URL for the authorization Resource.  Required
 callbackurl The redirect URL used to return the access_token   Required
 clientid The client identifier issued to the client during the registration process with the service.  Required
 scope The scope of the access request  Depends on the  service

Authentication Method (only required when granttype="clientcredentials")
An authentication method is described similar to a normal REST method using the <method> element. Like any other method, the Resource URI needs to be defined using the <resources> and <resource> parent element. A <request> child element is used to describe the input parameters for service authentication and a <response> child element is used to describe the output returned by the service authentication. In most cases the service authentication returns an access_token along with some other useful information about the token itself such expires_in information regarding the token.  Here's an example of authentication method for the Bing Translator service using client_credentials flow:
 
    <resource path="OAuth2-13">
      <method name="POST" id="GetToken" siena:isauth="true">
        <request>
          <representation mediaType="application/x-www-form-urlencoded">
            <param name="grant_type" style="query" fixed="client_credentials"/>
            <param name="client_id" style="query" fixed="1YV1vIZIFUlZYgd2LeZTg"/>
            <param name="client_secret" style="query" fixed="xxxxxxxxxxxxxxxxxxx"/>
            <param name="scope" style="query" fixed="http://api.microsofttranslator.com"/>
          </representation>
        </request>
        <response siena:resultform="aggregate">
          <representation mediaType="application/json">
            <param style="plain" name="access_token" path="/access_token"/>
            <param style="plain" name="expires_in" path="/expires_in"/>
          </representation>
        </response>
      </method>
    </resource>
  </resources>

 Attribute   Description  Required/Optional
 siena:isauth  A custom attribute that specifies if this method is required for authentication. When not specified it defaults to false.   Required

Resource Method 
Any method associated with a REST resource that requires authentication references the <siena:auth> element to describe the requirement. Here's an example of how the Speak method in Bing Translator service specifies the authentication requirement: 
 
<resource path="Speak">
  <method name="GET" id="Speak">
    <request>
      <siena:auth href="#dataMarketAuth"/>
      <param name="text" style="query" required="true" siena:sampledefault="welcome"/>
       
    </request>
    <response>
      
    </response>
  </method>
</resource>

 
 Attribute   Description  Required/Optional
 href  URI fragment identifier for the <siena:auth> element to use  Required

End to End Example
 
Following the sections described above we are able to create an end to end example of the Bing Translator service describing the Speak and AllTranslations method below. Save this description with a .xml extension using your favorite text editor and you are ready to import and consume these methods within Siena. 
 
<!--  Application
-->
             xmlns:siena="http://schemas.microsoft.com/MicrosoftProjectSiena/v1/WADL"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"
             xmlns:xh="http://www.w3.org/1999/xhtml"
             >
  
<!--  Siena Header
-->
  
  <siena:header fileversion="1.0"
                formatversion="1.0"
                author="ProjectSiena"
                serviceid="BingTranslator"
                />
  
<!--  Authentication
-->
  
  <siena:auth id="dataMarketAuth"
              type="oauth2"
              granttype="clientcredentials"
              accesstokenstyle="header"
              clientmethodref="#GetToken"/>
  
<!--  Authentication Method
-->
    <resource path="OAuth2-13">
      <method name="POST" id="GetToken" siena:isauth="true">
        <request>
           <representation mediaType="application/x-www-form-urlencoded">
            <param name="grant_type" style="query" fixed="client_credentials"/>
            <param name="client_id" style="query" fixed="1YV1vIZIFUlZYgd2LeZTg"/>
            <param name="client_secret" style="query" fixed="xxxxxxxxxxxxxxxxxxx"/>
            <param name="scope" style="query" fixed="http://api.microsofttranslator.com"/>
          </representation>
        </request>
        <response siena:resultform="aggregate">
          <representation mediaType="application/json">
            <param style="plain" name="access_token" path="/access_token"/>
            <param style="plain" name="expires_in" path="/expires_in"/>
          </representation>
        </response>
      </method>
    </resource>
  </resources>
  
<!--  Translator Resource and Speak Method
-->
  
    <resource path="Speak">
      <method name="GET" id="Speak">
        <request>
          <siena:auth href="#dataMarketAuth"/>
          <param name="text" style="query" required="true" siena:sampledefault="welcome"/>
          <param name="language" style="query" required="true" siena:sampledefault="en"/>
          <param name="format" style="query" required="false"/>
          <param name="options" style="query" required="false"/>
        </request>
        <response>
          <representation mediaType="audio"/>
        </response>
      </method>
    </resource>
  
    <resource path="GetTranslations">
      <method name="POST" id="AllTranslations">
        <request>
          <siena:auth href="#dataMarketAuth"/>
          <param name="text" style="query" required="true" siena:sampledefault="una importante contribución a la rentabilidad de la empresa"/>
          <param name="from" style="query" required="true" siena:sampledefault="es"/>
          <param name="to" style="query" required="true" siena:sampledefault="en"/>
          <param name="maxTranslations" style="query" type="xs:int" required="true" siena:sampledefault="5"/>
        </request>
        <response siena:resultform="single">
          <representation mediaType="application/xml">
            <siena:samplexml>
              <GetTranslationsResponse xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <From>es</From>
                <Translations>
                  <TranslationMatch>
                    <Count>0</Count>
                    <MatchDegree>100</MatchDegree>
                    <MatchedOriginalText/>
                    <Rating>5</Rating>
                    <TranslatedText>an important contribution to the profitability of the company</TranslatedText>
                  </TranslationMatch>
                  <TranslationMatch>
                    <Count>7</Count>
                    <MatchDegree>100</MatchDegree>
                    <MatchedOriginalText>una importante contribución a la rentabilidad de la empresa</MatchedOriginalText>
                    <Rating>1</Rating>
                    <TranslatedText>an important contribution to the company profitability</TranslatedText>
                  </TranslationMatch>
                </Translations>
              </GetTranslationsResponse>
            </siena:samplexml>
          </representation>
        </response>
      </method>
    </resource>
  
  </resources>
</application>