cancel
Showing results for 
Search instead for 
Did you mean: 

Sybase SA 12.0.1: How to transfer the web-services json parameter type ?

0 Kudos
3,581

Hi All,

Is google-form, the user fills in the fields on it and presses the button, which is formed by the json object, and call my web service in SA 12.0.1 which that the json-object should be transferred.

This JS-method code that calls the service at Sybase SA 12.0.1

function postToURL_1(formObject, URL) {
  var result = {};
  try {
    var options =
        { "method": "post",
         "contentType": "application/json",
         "muteHttpExceptions": true,
         "payload": JSON.stringify([ formObject.text, +formObject.number,
formObject.string, formObject.inputDate, formObject.myFile ])
        };
    result.status = true;
    result.message = 'Запрос выполнился';
    var response = UrlFetchApp.fetch(URL, options);
    result.itog = JSON.parse(response);
  }
  catch (err) {
    result.status = false;
    result.message = 'Запрос не выполнился';
    result.err = err;
  }
  return result;
}

The URL parameter is passed a reference to the web-service http://xxx.xxx.xxx.xxx:yyyy/TestBase/wsTest1 formObject is google-form.

This is the code from the database:

CREATE SERVICE "wsTest1" TYPE 'JSON' AUTHORIZATION OFF USER "MyUser" AS call dba.WebTest1(:cXML);

CREATE PROCEDURE "DBA"."WebTest1"(in cXML long varchar)
RESULT( cReturn long varchar ) 
BEGIN       
 select cXML;
END
go

The parameter should come cXML json-object, but why it does not come. That is, the web-service call and subsequent call dba.WebTest1 happening, but why it cXML null value (NULL) comes.

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_duemesnil
Participant

In the Help you can read that the Parameters to a service can be Host Variables.

Create Service -> statement

Specifies a command, such as a stored procedure call, to invoke when the service is accessed.
In a typical web service application, you use statement to call a function or procedure. You can pass host variables as parameters to access client-supplied HTTP variables.

You should use the HTTP_BODY function to get the POST Data.

HTH

0 Kudos

Many thanks for the tip, HTTP_BODY() returns the value of transmitted json-object. But still not clear why the cXML comes NULL ?