Hi Thijs

Below is a basic example of how I use luasoap now. There are a few remaining
questions. I hope someone can answer these:

- My server is now completely stateless. The script is executed, registers
its methods, parses the input, executes the functions and then quits. This
happens on every soap call.
        This is how CGI works.

What would be good approach to move to an
application which is persistent between calls?
        It depends on the case.  What are you looking for with this change?

- If I set soapversion to 1.2 I get the error I reported in my last message.
What is required to enable 1.2?
        It should work.  I'll take a look.

- With 1.1 can set soapaction to an empty string or something random, and it
still seems to work the same way without errors. Is it ignored?
        I think your server ignores it (it's redundant, and I think this is
why version 1.2 obsoletes it).

- If I specify the type of my arguments, like in the code below, I can still
call the function with other types, and it will convert without warning. For
a method expecting a string this assertion always passes even though it was
passed as a number:

assert(type(args[1][1]) == 'string', "First argument to helloString is not a
string")

This is not a big deal, just wondering.
        LuaSOAP does not check conformance :-)  It just let things work.
You can add this kind of check if you want.

- I know the wsdl generator is still experimental, but I'd like to try it
anyway. How would I change my server script so that "my/url?wsdl" generates
a wsdl file?
        Have you tried it?  The handle_request() should produce a response
to a "?wsdl" request.

- If I require "cgilua" then cgilua.serialize is nil. If I require
"cgilua.serialize" then nothing is reported to the log when I call it with
cgilua.errorlog as its second parameter.
        This works for me.  Could you elaborate a bit on that?

*Here is my server script:*

#!/usr/bin/env /usr/local/bin/cgilua.cgi

require "soap.server"
require "cgilua.serialize"

function helloString(namespace, args)
        These arguments might not be necessary...

  assert(type(args[1][1]) == 'string', "First argument to helloString is
not a string")

  cgilua.errorlog("namespace: ".. namespace)
  cgilua.errorlog("arguments:")
  cgilua.serialize(args, cgilua.errorlog) -- doesn't work?

  local someString = args[1][1] or "foo"
  local response = "Hello ".. someString ..", you're late!"
  cgilua.errorlog(response)
  return {tag = "myHelloStringResponse", {tag = "someOtherString",
response}}
end

function hello()
  return {tag = "myHelloResponse"}
end

local helloStringDescription = {
  name = "helloString",
  method = helloString,
  message = { name="helloString", {name="someString", occurrence=1,
type="string"}},
  response = { name="myHelloStringResponse", {name="someOtherString",
occurrence=1, type="string"}},
  --soapaction = "/helloString",
}

soap.server.export(helloStringDescription)

-- should be last line (after export)
soap.server.handle_request(cgilua.POST[1], cgilua.GET)



*And this is my client script:*
*
*
*
*
*
#!/usr/bin/env lua

require 'luarocks.loader'
local soap_client = require 'soap.client'
local LUA_SERVICE_URL = 'http://localhost:8888/lua/mysoapserver.lua'

function callHelloString(strval)

local ns, meth, response = soap_client.call {
 url = LUA_SERVICE_URL,
 --soapaction = '/helloString',
 soapaction = "", -- this works too?
 soapversion = 1.1,
 method = 'helloString',
 entries = {{tag = "someString", strval}}
}
return response[1]
end

local response = callHelloString("thijs")

-- works too, no type check?
response = callHelloString(12345)
        Sure, this would the same as:

response = callHelloString"12345"

        Regards,
                Tomás
_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to