On Friday, December 22, 2017 at 12:25:43 AM UTC-8, Yebach wrote:
>
> Hello
>
> I have to create a SOAP client (later also a service will be needed). It 
> is my first time so please bare with me on this one as I do not have a 
> proper understanding of this.
>
> If I understand the whole process it is smth like this. I send a WSDL 
> request where URL contains "?wsdl". This way I can see all the methods 
> provided by the server. This is called GET.
> Now after that i can get a definition of an xml "envelope" with which I 
> filter which results I want. I use POST method to call an URL - without 
> "?wdsl"  send this to some method and it should return xml with data 
> provided?
>


I don't deal with the wsdl myself (on the client side).  I use suds

from suds.client import Client
from suds.transport.http import HttpAuthenticated

and when I instantiate a client, the WSDL is handled for me (aside from my 
choosing a filename to store it in).

def start(self):
   url1 = 'http://' + self.loggerIP + ':' + self.loggerPort \
                + '/MyServer/default/call/soap?WSDL'
   self.client = Client(url=url1, username='logusr', password=
'mypassword1234567890')
   self.client.set_options(cache=None)
   authenticationHeader = {
                 "SOAPAction" : "ActionName",
                  "Authorization" : "Basic %s" % base64string
                 }

(self, because I actually made classes in the code I'm quoting; this is 
part of t)

Then the hook to do stuff (also part of the class)

def getLogStatus(self, targetIP):
    return self.client.service.LastStatus(targetID)

The "main" code looks like:

logClient = LoggerClient("10.3.171.71", "8080",
                            'file:///path/logserver-wsdl.xml')
logClient.start()
result = logClient.getTDStatus(target.IP)
failed = result.rfind(" failed")
    if failed > 0:
       result = result[0:failed - 1]
print "target has reported in at %s" % (result)


(result is a string, either just an ISO-format datetime, or the datetime 
with " failed" appended.)

I use PySimpleSoap on the server ... finding that led to my finding 
web2py.  I think a client using PySimpleSoap would look similar to my 
example, but it appears I didn't get around to that yet.

Also, my technique does require that you know what the calls are, but 
that's either in the server API documentation or you can get the WSDL and 
eyeball it.

/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to