Forum

Posted by
Erik Dahl - February 2009
Does anyone have a pike script that does a SOAP request? And is willing to share, of course.
Posted by
Pontus stlund - February 2009
Yes, indeed. It depends on what you want. I have a bunch of SOAP-stuff that works with Java and JAX-WS (Stewa helped me out gracefully to get the Java stuff working) but if you just want a simple SOAP-call in Pike I have that to:

======================

// Does the actual SOAP call through a generic HTTP query
string soap_call(string server, string action, string query) // {{{
{
  Protocols.HTTP.Query q;
  mixed e = catch {
    q = Protocols.HTTP.do_method(
      "POST", server, 0,
      ([ "User-Agent"   : sprintf("Tekniska Verken SOAP Client "
                                  "(Roxen/Pike %f)", __REAL_VERSION__),
         "Content-Type" : "text/xml; charset=utf-8",
         "SOAPAction"   : action
      ]), 0, string_to_utf8(query)
    );
  };

  if (e) {
    werror("SOAP Error: %O", e);
    return 0;
  }

  if (q->status != 200) {
    werror("No status 200: %s", q->data());
    return 0;
  }

  return q->data();
} // }}}

======================

The "query" argument is the full SOAP envelope which I build manually.

I can add that I just started working on a Pike SOAP module. The Pike hacker Bill Welliwer started working on a SOAP module a couple of years ago I think, and I have picked up his code and ported some stuff from the Ruby SOAP module. This is a pretty extensive job so I don't expect to finish it in the absolute future. When I get some stuff working I will post a note on these forums and see if anyone is willing to help out.
Posted by
Erik Dahl - February 2009
Perfect! Thanks.
1
Search this thread: