Page 1 of 1

No response receipt Web Service

Posted: Thu Feb 11, 2016 11:50 am
by dcorbaton
Good morning,

I've created a web service in gpsgate called "pruebas12". The response from the web service are the coordinates of a user in JSON:
Response body: {"lat":41.6427946666667,"lon":-0.876757333333334}

If I write the address (http://********.gpsgate.com/webservicescript/4/pruebas12) in a browser displays:
{"lat":41.6427946666667,"lon":-0.876757333333334}

I do not know how to receive this response from a html.

My code is as follows:

Code: Select all

<html>
<head>
</head>

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>

	function funcion_coordenadas()
	{
	   jQuery.ajax({
		type: 'GET',
		url:"http://*********.gpsgate.com/webservicescript/4/pruebas12" +"?callback=?",
	        dataType: 'json',
	        async : true,
	        success:  function (result) {
	                  console.log("bien");
	                   },
		error: function(result) {
			console.log("mal");
			}
		});
		}

</script>
<body onload="funcion_coordenadas();">
</body>
</html>
The code in a browser shows:
"Mal" because it that enters by error and
SyntaxError: missing ; before statement
{"lat":41.6427946666667,"lon":-0.876757333333334}

Json validator is correct.

How I can resolve this error? Why not connect to the web service?

Thanks in advance,

David

RE: No response receipt Web Service

Posted: Thu Feb 11, 2016 12:52 pm
by johan
If you have a hosted server it could be that Web Service Scripts is disabled on your server. Please contact support @ gpsgate.com

Regards,
Johan

GpsGate Support

RE: No response receipt Web Service

Posted: Wed Feb 17, 2016 10:46 am
by dcorbaton
No, I don't have a hosted server.

I remained unable to connect to the web service. With the callback it shows:

SyntaxError: missing ; before statement
{"lat":41.6428933333333,"lon":-0.876957833333333}

Without callback it shows:

"falta la cabecera CORS 'Access-Control-Allow-Origin')"

Where is the problem? Need I change the JSON? Is the callback function required ?

Thanks in advance,

David

RE: No response receipt Web Service

Posted: Wed Feb 17, 2016 10:55 am
by johan
In that case why do you use a URL that points to GpsGate?

http://*********.gpsgate.com/webservicescript/4/pruebas12

Please make sure you use a URL that points to your server.

Regards,
Johan

GpsGate Support

RE: No response receipt Web Service

Posted: Wed Feb 17, 2016 11:08 am
by johan
OK, I see you have a hosted server, but your the client page calling the script is your own server.

Regards,
Johan

GpsGate Support

RE: No response receipt Web Service

Posted: Wed Feb 17, 2016 11:23 am
by dcorbaton
I have a php file on my server that should communicate with the web service script that I've created in gpsgate using json .

RE: No response receipt Web Service

Posted: Fri Feb 19, 2016 7:02 pm
by Gabor
You get this error because your javascript file and the webservice is not hosted on the same domain.
Setting Access-Control-Allow-Origin response header would let you do cross-origin resource sharing.
That is not possible right now, but we will add capability of setting response headers from webservicescript.
I will reply in this thread when it is ready.


Regards,
Gabor
GpsGate Support

RE: No response receipt Web Service

Posted: Tue Feb 23, 2016 6:23 pm
by Gabor
We have released Patch.V4 4.0.0.3809 that allows you to set response headers in webservicescript. The update is available from the beta.gpsgate.com repository. In your webservicescript you can use it like this:
response.setHeader("Access-Control-Allow-Origin", "YourDomain");


Regards,
Gabor
GpsGate Support

RE: No response receipt Web Service

Posted: Mon Jun 27, 2016 12:48 pm
by Bettina
We seem to be having a similar problem and even with the update installed it doesn't work.

When querying a web service on GpsGate with jquery we are getting the following error message:
XMLHttpRequest cannot load http://10.20.1.23/webservicescript/4/myrniservice. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:52379' is therefore not allowed access. The response had HTTP status code 500.

In order to add the header, we installed the most up-to-date software as per instruction here:
topic.asp?TOPIC_ID=18665

and added the following to the script:
response.setHeader("Access-Control-Allow-Origin", "*");

However, we are still receiving the same error message. We also added the header through IIS but this seems to be overridden by the GpsGate software.

I'd be grateful for any assistance,

Bettina