Make SOAP requests from Postman + Web Service Testing

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi there this is Valentine and welcome to another postman tutorial this time we're gonna take a look at how you can make soap request from postman and I'm gonna show you how you can create requests how you can create assertions and basically API tests for the requests that you are working with so let's get started with a very simple soap service and this one is called calculator and it offers multiple operations and I'm going to simply use add to add two integers and from the documentation you can see that it's pretty simple what we should send and what we should receive so I'm going to start by copy pasting information from this page into postman the first thing that can occur copy is the address where I should send a request and it will see from the documentation this is a post request that goes to slash calculator dot a SMX I'm going to paste this address here I'm gonna select post and then in order to submit the soap body I'm gonna go to the body part of the request I'm gonna select raw and from this drop-down I will select XML and this will allow us to insert XML in our request so the next step would be to simply copy and paste the XML that we need to send based it here and what you'll notice additionally is that postman automatically adds specific headers for your request now usually application XML it's something that would work but in this case it needs to be text XML so for that reason I'm gonna replace that to it text 6 ml and we still get an error because we haven't really updated our body so we still need to add our integers let's say that we are adding 3 & 4 and the result that we're getting is then seven now one of the common use cases when dealing with request bodies that send information is to have something dynamic in it and as you can see currently we have hard-coded three and four and this is something that you generally may want to manipulate by using scripts or using using other possibilities and I'm just gonna enough going to do scripting when it comes to creating this request because there are other tutorials explain that much better but I just going to show you how we can replace three and four with a postman variable and I'm gonna go quick and dirty and create two global variables here I'm gonna call them a and B and let's give here two specific values five and six so now I have this global variables here available so all I have to do is replace the numbers now with a variable and I'm using these special syntax with double curly braces and this will be replaced by postman when we are sending the request and now will you see that the result has changed so obviously the information that we inserted here has been then replaced by postman and real actual values that we wanted to send have been submitted so this is when it comes to request creation now as you have noticed we have done everything manually when it comes to creating the request and if you're familiar with other tools like soap UI you must notice that there is no support for soap requests and XML generally in postman and this is because postman is more into REST API s and now most recently into graphic you are creating soap request requires a bit of extra work but if you want to take advantage of other functionality that postman has really need to do this manually in order to create it so you don't have the possibility of linking or importing a WSDL schema so that you can automatically generate requests and to do stuff like that if you already have this request created in a tool like soap UI then you can import those information from there to here but otherwise this is this is the manual process you need to go through in order to make everything work the second part is after the request is working and everything is ok I'm going to simply save this to a collection going to call the collection calculator and the request name will be add now we can easily have it here in a collection and share it with others and so this is the way we save things in postman now the second interesting part of postman is actually the possibility of writing tests for what we have received so in this case it's pretty clear that we have added two numbers and we want to make sure that the web service that way I'm calling here is providing us with the correct result so for that I'm going to go here to the tests tab and this allows us to basically write JavaScript in order to work with this and on the right side here you can open up a few JavaScript snippets and one of the snippets that are interesting in our case is this one with response body convert XML body to a JSON object so what this will do is we'll take the raw response and we'll parse it understanding that this is an XML and we'll map it with JSON objects actually a JavaScript object that will contain all the nested objects that this response had and I'm going to show you in a bit how exactly we can write a very simple assertion so we're going to assert that add result from this value 11 is actually what we expected this to be so we're gonna quickly generate the test by using the following snippet when I do use it this response body JSON value check I'm gonna move JSON object right here inside this would be pretty easy and we what we need to do is to navigate property by property and to figure out how to get to this edge result now this depending on the response this in this isn't even a very complex response this may get complicated and I will show you an alternative to this but if you this is something what you want to do you will find here in the notification that I've created an odd tutorial explaining how you can go step by step so I'm going to do this a bit quicker now to avoid the pain of having you watch me do this basically I'm going property by property so I'm starting with soap envelope and I'm going to soap body and response ad result and this will give us the value that's inside ad result and we're going to check if this matches eleven and I will notice that in our test results you will see here the test name this is the name of test we haven't really properly given something there but you will see this this has passed and if I change the value to something else for whatever reason you will see that you get this assertion error and this is not working anymore and of course 11 is now hard-coded you can use scripts in order to access this variable that I have mentioned here and you will find more resources in this video description on how to work with scripts and so on so on not get into that what I wanted to do is to show you an alternative to using XML to JSON so I'm gonna name this test using XML to JSON and I'm going to copy this exact same test structure that you've seen here and actually what I'm going to use is serial serial is JavaScript library it's actually quite powerful but it's a bit more complex to use or depending on the scenario you might find it a bit weird in the beginning but I you it's relatively easy to use and very powerful and avoid you having this long nested objects here that are actually not so nice so the first thing that we'll do is to initialize serial and we're going to define a constant and the constant will be a dollar sign and this is the usage of dollar sign is simply a convention and what we need to do is to use serial and we are going to load to response body so certian will look something like this we still can use the dollar sign and this will be a function and we're going to give a parameter to this function and that will be from the response the note that we are looking for and this one is ad result and with calling the function text we'll get the value of AD result now you will see we have to separate the sessions when using serial and the other one using XML to Jason and Jason javascript objects so this one is much shorter and much powerful we again need to make sure that this one fails as well so that we don't get anything that's totally weird here it's working perfectly and just to give you a bit more practice with this let me show you how exactly you can get for example add response as a node so let's create another expectation every dolt I'm gonna use at response as a string and we're not longer getting the value of it but we're actually trying to read this attribute so I'm gonna use the attribute function this will give us the attribute of course a test will fail but as you can see from the assertion I've managed to extract the right attribute and now this test is passing as well so here we go this is how you can create soap requesting postman if you're having any issues parsing your request body in postman then head to mock it up iö select here the content type that's necessary in this case you probably application slash XML or text XML paste here the response that you have click on generate my HTTP response and in the section below paste this link that has been generated and I'll do my best to give you a response on how you can parse a specific property from that response to extract a specific value now when you're using this this is totally public so make sure that you remove any sensitive information from the response so don't share anything that you're not comfortable sharing with others but I'll be more than happy to help you use Syria or use the XML to JSON way of extracting values from their XML now XML compared to JSON is a bit more complex but still a lot of people prefer to use postman in order to have like one tool to work with REST API is to work with soap requests or to work with graph girl so for that reason I think it's a good way if you manage to gain more information on how you can use postman for your soap requests okay guys that's about it thank you very much for watching hopefully you have learned something new and this has helped you create soap request from postman and with that test as well if this video was helpful give it a thumbs up subscribe to this channel for more tutorials like this and if you have any questions or if you run into any problems just check the video description for some resources or leave a comment in the section below see you at the next tutorial bye bye [Music]
Info
Channel: Valentin Despa
Views: 70,952
Rating: undefined out of 5
Keywords: Make SOAP requests from Postman, postman how to run soap requests, postman soap api testing, postman soap testing, postman-soap-request, postman-soap-body
Id: xC4QQCQDDDk
Channel Id: undefined
Length: 13min 0sec (780 seconds)
Published: Thu Nov 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.