https and SOAP

Questions and information about using Lua scripting with Storyboard

Moderator: jamiev

https and SOAP

Postby ScotSutherland » Thu Jul 16, 2015 3:16 pm

New to SB.

Connecting to a back end SOAP service via https. Data will be encoded in JSON with a SOAP wrapper. Looking for examples of client for connecting and communication with the service.
ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm

Re: https and SOAP

Postby ChrisK » Fri Jul 17, 2015 10:39 am

HI Scot, i'd have to look into the SOAP aspect of things, but using LUA scripts you could create JSON strings or https urls and pass them to/from a client app using gre.send_event_data/gre.recieve data, along with a LUA module for parsing JSON (dkjson: http://dkolf.de/src/dkjson-lua.fsl/home)
ChrisK
 
Posts: 38
Joined: Wed Nov 04, 2009 3:34 pm

Re: https and SOAP

Postby jason » Fri Jul 17, 2015 12:45 pm

Hi Scott,

There is a Lua SOAP project
http://tomasguisasola.github.io/luasoap/
However I have no experience with it.

Here is a pretty simple example of Lua doing an http get and decoding the json response using luasocket and the json modules.

Code: Select all
http = require("socket.http")
require('json')

function get_weather(city_id)
  local v, b, c, h
  local url_current = string.format("http://api.openweathermap.org/data/2.5/weather?q=%s&units=metric",city_id)
  local data = {}
 
   b, c, h = http.request(url_current)
   v = json.decode(b)
   
   data["Layer.temp.text"] = math.floor(v.main.temp)
   gre.set_data(data)
end


If you download and compile Lua module from the web just make sure you use the headers and libsblua.so for your target when you compile and link.

Regards,
Jason
User avatar
jason
 
Posts: 188
Joined: Mon Nov 02, 2009 4:53 pm

Re: https and SOAP

Postby MikeMarchand » Fri Jul 17, 2015 1:01 pm

Hi Scot,

I would have a look at this forum post about creating a custom Lua module. The trick to this is to compile the source code for your module against libsblua.

http://www.cranksoftware.com/forums/viewtopic.php?f=6&t=449&p=1219&hilit=lua+module#p1219

As Jason mentioned, you will want to check out LuaSockets and build a Lua module for your target platform. LuaSockets is licensed under MIT so it is a good resource to use.

http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz

Like Chris said, it would be a good idea to use dkjson, it is a robust json library that is pure Lua, fast and easy to use. As with the LuaSockets library, the dkjson library is licensed under MIT so it may be used commercially without a problem.


It would also be a good idea when beginning a forum post to mention which version of Storyboard you are using, which platform you will be using to develop you application and the target platform(OS and Hardware) on which you plan to deploy your application.
MikeMarchand
 
Posts: 17
Joined: Wed Jan 21, 2015 3:33 pm

Re: https and SOAP

Postby ScotSutherland » Fri Jul 17, 2015 2:17 pm

Wow. Thanks for your all your replies. I am in the process of setting up a web service on the back end. Then I will dig in.

Currently:

Version: SB v4.1
Platform: IOS (iPad Mini 2)
Backend: Microsoft SQL Server, .NET SOAP service.

I am quite familiar with dkjson and Luasockets having worked extensively with Corona SDK. Not familiar with SOAP and https SSL.

My implementation will use a listener that executes functions whenever the service sends data. I have always used a timer in the event loop to do this on other platforms.
ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm

Re: https and SOAP

Postby ScotSutherland » Fri Jul 17, 2015 2:39 pm

ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm

Re: https and SOAP

Postby ScotSutherland » Tue Aug 18, 2015 12:39 pm

Ok. I have examined LuaSockets and LuaSec. It appears that a binary must be compiled from the c libraries for these two modules to work.

I am confused about the target for the compiler.

Am I compiling a new extended version of libslua.so?

Or am I compiling separate LuaSocket.a and LuaSec.a static libraries that will be loaded and when the IOS executable is compiled?

It appears that I can simply add dkjson as a module to my Lua code without compiling an IOS binary.

Will these libraries be available for the simulator, or will they only work with the device?
ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm

Re: https and SOAP

Postby ScotSutherland » Tue Aug 18, 2015 12:49 pm

I also ran across n-wax which exposes native IOS functions to Lua. I would rather use LuaSockets but it appears that n-wax might be useful for other connections to native functions.

https://github.com/felipejfc/n-wax

Would n-wax be simply a plugin of its own, or would I use it to make separate plugins for each native function I want to use?
ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm

Re: https and SOAP

Postby ScotSutherland » Thu Oct 01, 2015 12:32 pm

To complete this thread. We compiled the Lua Socket, Luasec and LuaXML c libraries for use with Storyboard on IOS. We did not take the extra step of compiling Lua SOAP. We found it to be trivial to use LuaXML to parse the SOAP encoded xml and implement Lua functions. We paid Crank Software to sort out some complexities of integrating the libraries with Storyboard for IOS. Apple code signing and the structure of the Luasec distro made this more complicated than it should be for other platforms.
ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron