generateODataHttpClient method

Generate an OData HttpClient object over https proxy of native platform. This object will re-direct all odata request to the http proxy because even with HTTP connection, there are are some known issue by default setting since the application in device is cross server accessing the odata service. See: http://datajs.codeplex.com/discussions/396112 for details of the issue. Call this method normally on HTML page load event to replace the default odata HTTP client.

Syntax

<static> generateODataHttpClient()

Example

 // Call datajs api without certificate, users could call just as normal by passing 
 // URL as first argument
 var length = 0;
 var updateUri = server + "/example.svc/Categories(1)";
 
 OData.read(server + "/example.svc/Categories",
 function (data, response) {
     alert("length " + data.results.length);
     length = data.results.length;
     if ( length > 0 ) 
{
         var updateRequest = {
             requestUri: updateUri,
             method: "PUT",
             data: 
{ 
                 Picture: new Date().getTime(),
                 Description: "Update Record",
                 CategoryName: "Updated Category",
                 CategoryID: 1
             }
         };
 
         OData.request(updateRequest, 
             function (data, response) {
                 alert("Response " + JSON.stringify(response));
             },
             function (err) {
                 alert("Error occurred " + err.message);
             }
         );
     };     
 },
 function (err) {
     alert("Error occurred " + err.message);
 });

 // However, to specify certificate source in the method call, users need to pass in 
 // the request object instead of URL,
 // and add the field "certificateSource" to the request object.
 var length = 0;
 var updateUri = server + "/example.svc/Categories(1)";
 
 OData.read({ requestUri: server + "/example.svc/Categories", certificateSource : cert},
 function (data, response) {
     alert("length " + data.results.length);
     length = data.results.length;
     if ( length > 0 ) 
{
         var updateRequest = {
             requestUri: updateUri,
             certificateSource : cert,
             method: "PUT",
             data: 
{ 
                 Picture: new Date().getTime(),
                 Description: "Update Record",
                 CategoryName: "Updated Category",
                 CategoryID: 1
             }
         };
 
         OData.request(updateRequest, 
             function (data, response) {
                 alert("Response " + JSON.stringify(response));
             },
             function (err) {
                 alert("Error occurred " + err.message);
             }
         );
     };     
 },
 function (err) {
     alert("Error occurred " + err.message);
 });

Source

Plugins/HttpsProxy/datajs-https-proxy.js, line 108.