Get data from web services

Hi Guys

What is best way to get data from web services.I have created a web services in asp.net and i want invoke method of web services and get return data.What is best way. Please share your idea .

Thanks [import]uid: 209400 topic_id: 34978 reply_id: 334978[/import]

I recommend you start here:

http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/
[import]uid: 199310 topic_id: 34978 reply_id: 139102[/import]

Hi Rob

This link shows that you are calling particular page and passing query string from Lua and get return output from that page.But my question is how to invoke method directly from Lua.

[import]uid: 209400 topic_id: 34978 reply_id: 139178[/import]

That is how you do it. You use the network.request() API call to hit the URL for your web service and it returns to you the output from that request.

[import]uid: 199310 topic_id: 34978 reply_id: 139231[/import]

Hi Rob

Then it should work after compile.But its not working after compile.May i know the reason?.Even after
compile its not invoking method. [import]uid: 209400 topic_id: 34978 reply_id: 139233[/import]

You probably should put some print statements in to check to see if the listener is getting called, if you’re getting an error, and what response you’re getting. Without seeing your code, all I can do is guess. Make sure you have network connectivity from your device.

And the two most common reasons for “It works in the simulator but not on the device” is either a case sensitivity problem with a file name or an error in your build.settings file. While this has nothing to do with your network.request(), it could stop the app from running and look like this kind of problem.

Do you know how to view the device’s console log using “adb logcat”?
[import]uid: 199310 topic_id: 34978 reply_id: 139239[/import]

I recommend you start here:

http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/
[import]uid: 199310 topic_id: 34978 reply_id: 139102[/import]

Hi Rob

This link shows that you are calling particular page and passing query string from Lua and get return output from that page.But my question is how to invoke method directly from Lua.

[import]uid: 209400 topic_id: 34978 reply_id: 139178[/import]

That is how you do it. You use the network.request() API call to hit the URL for your web service and it returns to you the output from that request.

[import]uid: 199310 topic_id: 34978 reply_id: 139231[/import]

Hi Rob

Then it should work after compile.But its not working after compile.May i know the reason?.Even after
compile its not invoking method. [import]uid: 209400 topic_id: 34978 reply_id: 139233[/import]

You probably should put some print statements in to check to see if the listener is getting called, if you’re getting an error, and what response you’re getting. Without seeing your code, all I can do is guess. Make sure you have network connectivity from your device.

And the two most common reasons for “It works in the simulator but not on the device” is either a case sensitivity problem with a file name or an error in your build.settings file. While this has nothing to do with your network.request(), it could stop the app from running and look like this kind of problem.

Do you know how to view the device’s console log using “adb logcat”?
[import]uid: 199310 topic_id: 34978 reply_id: 139239[/import]

Hi Guys

What is best way to get data from web services.I have created a web services in asp.net and i want invoke method of web services and get return data.What is best way. Please share your idea .

Thanks [import]uid: 209400 topic_id: 34978 reply_id: 334978[/import]

Change your WebService (I am assuming you are using SOAP) to a WCF service and use JSON.  I did it this way and with a few lines of code you have your data coming in easily.  I can supply a sample if you like.

Chuck Giddens

Hi Guys

What is best way to get data from web services.I have created a web services in asp.net and i want invoke method of web services and get return data.What is best way. Please share your idea .

Thanks [import]uid: 209400 topic_id: 34978 reply_id: 334978[/import]

Change your WebService (I am assuming you are using SOAP) to a WCF service and use JSON.  I did it this way and with a few lines of code you have your data coming in easily.  I can supply a sample if you like.

Chuck Giddens

A sample??   Yes please!  :)

My WCF service works fine but i need help connecting my Corona App

A sample??   Yes please!  :)

My WCF service works fine but i need help connecting my Corona App

Dear sir,

I have problems with my WCF Service method POST.

It is working fine when calling from other clients, but it is not work when calling from Corona.

When calling from Corona, the service is fired, but its parameter is always NULL.

This is the Corona code:

    local dados = {}

    dados.esc_codigo = codigo

    local body = json.encode(dados)

    local url = “http://192.168.0.28:81/wcfEscola.svc/consultaCodigo

    

    local headers = {}

    headers[“Content-Type”] = “application/json”

    headers[“Accept-Language”] = “en-US”

    local params = {}

    params.headers = headers

    params.body = body

    network.request(url, “POST”, onRequestComplete, params)

What do you mean “Its parameter is always NULL”?

Can you post your onRequestComplete function?

Make sure to read today’s blog post on Facebook:

http://coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

I mean that the WCF Web Service receives null as parameter.

The data I would like to pass to WCF Service “params.body = body” does not reach the WCF WebService.

The problem is not in my OnRequestComplete. The problem is in communication between Corona and .NET.

Do you understand ?

Thank you !!!

I forgot to say that if I call the same WCF Web Service from another client, like a Java program, everything work well.

In other words, the data I pass via POST is received by the WCF Web Service.

But if I call from Corona, do not.

Thank You.