User avatar
Gabor
GpsGate
Posts: 86
Joined: Thu May 16, 2013 3:43 pm

RE: GUIDE: Web Service Scripting

Wed Oct 21, 2015 5:46 pm

The WebServiceScript does not work that way, it does not push the data anywhere, the other system has to request the data from gpsgate server.


Regards,
Gabor
GpsGate Support

mikelord
Posts: 40
Joined: Wed Apr 02, 2014 6:59 pm
Location: Chile

RE: GUIDE: Web Service Scripting

Wed Oct 21, 2015 10:40 pm

Peron might not explain well what I need, the idea is to get the atravez data webservice and to forward them to other recipients, obviously that gps gate does not do that and would have to do some kind of development on our part to take the position data of the vehicles

Desde Chile

piter197
Posts: 832
Joined: Sun Jan 09, 2011 3:32 am

RE: GUIDE: Web Service Scripting

Fri Oct 23, 2015 5:45 am

Hi,

My GGS Patch.v4 ver 4.0.0.3405.

My script:

Code: Select all

var users = directory.getUsers();
var vehFound = "";
	  
vehFound = users[i];

if(vehFound != "") {
  response.body =
  '{\"response\":{' +
  '\"vehicleID\":' + vehFound.id + ',' +
  '\"username\":' + '\"' + vehFound.username + '\"' + ',' +
  '\"name\":' + '\"' + vehFound.name + '\"' + ',' +
  '}}';
}
This work before without any problem. Now it always return error: Response body: {"response":{"error":"Object reference not set to an instance of an object."}}

I have change

Code: Select all

vehFound = users[i];
into

Code: Select all

vehFound = directory.getUserByID(users[i].id);
but no luck, please help.


Best Regards,
piter197

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Web Service Scripting

Fri Oct 23, 2015 8:49 am

Where is the variable "i" defined?

Regards,
Johan

GpsGate Support

piter197
Posts: 832
Joined: Sun Jan 09, 2011 3:32 am

RE: GUIDE: Web Service Scripting

Fri Oct 23, 2015 12:38 pm

Hi Johan,

that was incomplete script, i is some positive integer.


Another script that also return error: Response body: {"response":{"error":"Null object cannot be converted to a value type."}}

Code: Select all

var loc = geo.reverseGeocode(lat, lng);
response.body =
              '{\"response\":{' +
              '\"location\":' + '\"' + loc.address + '\"' + ',' +
              '}}';
If I change into:

Code: Select all

// var loc = geo.reverseGeocode(lat, lng);
response.body =
              '{\"response\":{' +
              '\"location\":' + '\"' + geo.reverseGeocode(lat, lng).address + '\"' + ',' +
              '}}';
then every thing just fine, this will return location address with out any error. Hope this can be use as clue.

Best Regards,
piter197

piter197
Posts: 832
Joined: Sun Jan 09, 2011 3:32 am

RE: GUIDE: Web Service Scripting

Thu Oct 29, 2015 3:01 am

Hi Support,

After updating to recent beta Patch.v4, the problem "Object reference not set to an instance of an object." and the problem "Null object cannot be converted to a value type." all have been rectified.

Thank you.


Best Regards,
piter197

ramonoakz
Posts: 2
Joined: Mon Nov 09, 2015 1:59 pm
Location: Brazil

RE: GUIDE: Web Service Scripting

Tue Nov 10, 2015 3:53 pm

Hi people,

I want to get the latitude and longitude and expose on the webservice to get this information on a Android app.

But I don't know how to make a script that get this information.

Can someone help me?

mapaws
Posts: 3
Joined: Mon Dec 28, 2015 10:45 am

RE: GUIDE: Web Service Scripting

Wed Feb 03, 2016 2:05 pm

Is it possible to bind the WebServiceScriptProvider to use https instead of http only?

User avatar
Gabor
GpsGate
Posts: 86
Joined: Thu May 16, 2013 3:43 pm

RE: GUIDE: Web Service Scripting

Wed Feb 03, 2016 4:28 pm

Only http is supported currently.


Regards,
Gabor
GpsGate Support

dannalejandro
Posts: 15
Joined: Fri Feb 08, 2013 8:57 pm
Location: Ecuador
Contact: Website Facebook Twitter

RE: GUIDE: Web Service Scripting

Wed Jul 13, 2016 2:17 am

Dear GPSGate:

I have the next Web Script that I found here in the forum with a little modifications:

var xmlReq = xml.parseFromString(request.body);

var user = xmlReq.selectSingleNode('/request/login/user').innerText;
var pass = xmlReq.selectSingleNode('/request/login/pass').innerText;
auth.login(user, pass); // the user needs _WebServiceScriptLogin privilege

var vehicleID = xmlReq.selectSingleNode('/request/vehicleid').innerText;
var user = directory.getUserByID(vehicleID);

if(user != null) {
var lat = user.trackPoint.position.latitude;
var lon = user.trackPoint.position.longitude;
var speed = user.trackPoint.velocity.groundSpeed;
var utc = user.trackPoint.utcTimestamp;

response.body =
'<response>' +
'<lat>' + lat + '</lat>' +
'<long>' + lon + '</long>' +
'<speed>' + speed + '</speed>' +
'<utc>' + utc + '</utc>' +
'</reponse>';
} else {
response.body = '<response><error>Not found</error></response>';
}

The Request Body Is:

<request>
<login>
<user>username</user>
<pass>password</pass></login>
<vehicleid>vehicleid</vehicleid>
</request>

I dont know which is the vehicleid of each unit, where can I find it?
Thanks

Return to “GpsGate for Developers”