Dear Tomas and all,

I finally got a simple luasoap server working. I made a mistake in the way I
declared my methods. I didn't know that all methods should have a common
signature like (namespace, args). That's why I always received the namespace
no matter what I put in.

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. What would be good approach to move to an
application which is persistent between calls?

- If I set soapversion to 1.2 I get the error I reported in my last message.
What is required to enable 1.2?

- 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?

- 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.


- 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?

- 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.


Best,
Thijs


*Here is my server script:*

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

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

function helloString(namespace, args)
   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)

*
_______________________________________________
Kepler-Project mailing list
[email protected]
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to