Consuming HTTP Services in Python Transcripts
Chapter: Calling SOAP services from Python
Lecture: Concept: Using Suds
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
All of the operations that we worked with in our soap service, took fundamental types, strings, integers, that sort of thing,
0:09
what if the operation, not only returned its own internal complex types, but actually took them as parameters, it's easy to work with them
0:17
when they come back from functions, they are already allocated you just start treating them as objects in memory,
0:23
but if you have to allocate one to input it into this method for example, how do you do that?
0:27
You can't just call some kind of initializer on it because well, it's created a runtime,
0:32
what are you going to do, okay, so if we want to use this post object back in this operation, now remember, this is not how ours works
0:41
but if this were the case, suds has an answer for this as well. Okay, so what do we do, again, we create the client just like before,
0:48
but now instead of going to client.service we go to client.factory, and it can create these objects so we say client.factory.CreatePost
0:56
and that does all the internal runtime stuff to allocate one of those with basically none values for all of the properties,
1:02
and then we can just set the properties, creating posts from suds is fun, it works in Python 2 or Python 3, and of course, it hasn't been seen yet,
1:09
it's brand new so ViewCount=0. Now once we have this rich type, we can use it as parts of our parameters,
1:16
and our operation so client.service.CreatePost and we are going to pass this rich object which will be serialized
1:23
into the Soap message just like the contract in this example.