Python SOAP WebServices with Zeep

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
howdy y'all in this video I'm gonna teach you how to use a soap web service in Python so I was browsing the internet and I came up with a soap service that we could use as a sample this is called calculator and basically what it does is adds divides multiplies and subtract using web services so this is the base of it if you want to see what they do you could just click on here and they'll show you examples of how to use it now you could also click on the wisdom and this will show you the entire wisdom of how to use it but I could click on here and this is these are headers you don't have to worry about these but this here will be the soap body and we'll copy that you can see here that it takes in here's the add method it takes in two parameters int a and int B and those are gonna be integer types and then when you run that through the web services it's going to give you this response right here and this response is going to give you back an integer now let's go ahead and test this to make sure it runs I'm gonna use postman and start a new tab so here's that is not what I want here's the wisdom right here so if you do a get on this guy you're gonna get this whole entire page which is this page so we don't want to do it yet we want to do a post like that okay and our post is going to be this add method so if you grab this out of here and in the body where'd the body go there we go you got to make it a raw add this into the body and then be sure you change this from text to text XML because we're set at an XML request through here and once you send that you're gonna get an error because you have to change this to actual integers so if we I'd like 12 and 13 there we go 25 now we're getting the right result this is what a request should look like this is what our response should look like so we're gonna do this programmatically using Python now for Python I used something called Visual Studio code that's my IDE very powerful good stuff I love it just create a new file we're gonna call this soap test add the dot pi extension to make a Python we're gonna use a framework called zeep and this is how this is how you use it go ahead and save this guy and then run it so test pi when you run it you're gonna have an error you can say no module found name's EEP that means you need to install it so python uses installer called pip pip installs EEP we'll get it for you and this doesn't take very long at all and it looks like it's already installed let's see if it actually is go back and run this and that ran good okay so the first thing we're gonna do with zeep is we are going to create a client actually we're going to import client from XIV so from zip import client like that we're gonna initiate the client here and then we're gonna say the wisdom is equal to and they're gonna grab this wisdom out of here and yes you have to use the actual whistle on this one like that and if you run this I run this every now and then just to make sure things are working so something with zip you can do is you can import the schema definition Python - MZ p-- and then pass it in this URL and it'll actually give you the schema definition command let what the heck is going on alright folks it would helped us know how to spell python python - MZ and then pass in that this gives you the schema definition you can see here we'd have to worry about these prefixes for now here's all the elements we're gonna have we can pass in add and it'll give us the add response same thing for divide multiply subtract your types we don't really have to worry about types it gets complicated when you get some complex types bindings there's there's usually always the 11 and 12 binding here's what we really want though we run these services specifically this add service so if we look at this guy this guy's taking in an integer for int a and an integer for int B and then he's returning in the add result which we saw from right here he's returning another integer so under here we could say we're just gonna go ahead and print it so client dot service dot add because we're accessing this service from the client that we just set up here and using the add function because it builds all this on the fly it's pretty powerful and then we're gonna pass it into two integers so 12 and 13 save it and run it and there you go 25 will be the answer from using these web services right here and it's just that simple using soap in Python it's just that simple take your ladies and gentlemen if you found value in this video please share to hit the like button if you like what I do want to see more please subscribe thank you for watching and I'll see you next time
Info
Channel: JavaKing
Views: 30,171
Rating: 4.9339933 out of 5
Keywords:
Id: JBYEQjg_znI
Channel Id: undefined
Length: 6min 46sec (406 seconds)
Published: Thu Jun 06 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.