Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in response processing #4

Closed
fpaquet opened this issue Jun 5, 2012 · 3 comments
Closed

Bugs in response processing #4

fpaquet opened this issue Jun 5, 2012 · 3 comments

Comments

@fpaquet
Copy link

fpaquet commented Jun 5, 2012

We found 3 issues with luasoap 3.0 (latest)

  1. list_children() fails to access the second and any further elements
    error: soap.lua:215: attempt to index global 'self' (a nil value)
  2. some webservices omit the SOAP-ENV:Header
    if SOAP-ENV:Header is missing, decode() will fail to locate the SOAP-ENV:Body
  3. decode() fails to return any response entries
    error: soap.lua:~251: attempt to index local 'obj' (a function value)
  4. because a response contains lots of whitespace entries, we suggest
    that you add something like list_children() to the public interface of soap
@fpaquet
Copy link
Author

fpaquet commented Jun 5, 2012

Patch for issue 1-3

diff --git a/src/soap.lua b/src/soap.lua
index 79c577b..7f5da83 100755
--- a/src/soap.lua
+++ b/src/soap.lua
@@ -212,7 +212,7 @@ local function list_children (obj, tag)
                                return v
                        end
                        i = i+1
-                       v = self[i]
+                       v = obj[i]
                end
                return nil
        end
@@ -232,12 +232,18 @@ local function decode (doc)
        local namespace = find_xmlns (obj.attr)
        local lc = list_children (obj)
        local o = lc ()
-       -- Skip SOAP:Header
-       while o and o.tag ~= ns..":Header" and o.tag ~= "SOAP-ENV:Header" do
+
+       -- Skip (optional) SOAP:Header
+       while o 
+       and o.tag ~= ns..":Header" and o.tag ~= "SOAP-ENV:Header" 
+       and o.tag ~= ns..":Body" and o.tag ~= "SOAP-ENV:Body" 
+       do
                o = lc ()
        end
-       if o.tag == ns..":Body" or o.tag == "SOAP-ENV:Body" then
-               obj = list_children (o)
+
+       if o and (o.tag == ns..":Body" or o.tag == "SOAP-ENV:Body") then
+               local lo = list_children(o)
+               obj = lo()  -- get first child
        else
                error ("Couldn't find SOAP Body!")
        end

@denisdemais
Copy link

@fpaquet do you can attach the soap reply (raw) with optional header ?

@fpaquet
Copy link
Author

fpaquet commented Feb 13, 2016

Hello Denis

I'm not sure wether i can reproduce today the SOAP reply that we got in 2012.
(the SOAP services have changed in the meantime)

LuaSOAP is running absolutely fine with the patch since several years now.

The patch fixes 3 errors while retaining 100% compatibility with previous behaviour.
Why not merge it into master and check LuaSOAP ist still working today?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants