C#: Web Service - ASP.NET Web Application (Framework) Hello World

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome in this video we're going to take a look at how to create a quick hello world soap web service using visual studio let's get right into it okay so live visual studio this is visual studio 2019 click on create new project now we want to create a web application so type web application go ahead and go ahead and click on the net framework so asp.net web application using the net framework click next i'm going to leave everything as default for this demo make sure that you're using the latest dot net framework click create okay let's go ahead and okay let me select an empty web application let's give that a go i mean it's been a while since i created a soap web service typically nowadays people don't tend to use soap as much as they used to nowadays you're more likely to be creating a restful web api type of application but these are still used i certainly come across them an awful lot certainly with legacy systems you'll notice there's lots of soap api as well web services around so it's good to know either way it's good it's good to know these things just in case you happen to come across them okay so let's right click the application i want you to click add and we're going to go ahead and oh look at that it's actually on the list so we can click on it here and if it wasn't there if it's not on your list click on new item and do a search for web service click on it and click add you can give it a name if you want for the purpose of this demo i'm going to leave it as default so click add i mean the great thing about web services to be honest with you is that they are so easy so incredibly easy to use so as you can see in this instance microsoft have been kind enough to provide us with a hello world method already a web method so bearing that in mind let's just dissect what's going on here so it's been tagged as a web method this is called an attribute so if i was to remove that it wouldn't be available for others to call online using soap it's public again if i was to make it private or protected it wouldn't be available for others to call here's the return type so we're going to be returning a string the name of the method is hello world and here's what we're returning i'm going to go ahead actually just just make that a little bit bigger so you can see it because uh sometimes it's a little bit hard to see certainly if you're using a mobile device so how about that hopefully you can see that so as i say we've got an attribute here indicating that it's a method a web method it's public so people can see it outside of this class it's returning a string a data type of string it's called hello world and here's the return statement so for example it's returning a string but if we were to create a string let's call it i don't know my string and we could set that literally equal to hello world and then we could return the string so my string even and that will work in exactly the same way anyway so i'm going to build it ah did anyone spot the error there was a missing semicolon okay so let's control shift b let's build the application the application is built let's go ahead and right click on webservice1.asmx and we're going to click on view in a browser now the other great thing about web soap web services certainly when you're creating them using visual studio is it gives you this really fantastic tool to actually test your your methods so here's the method so you can literally click on it and here you've got a button so you can click on invoke and as you can see the data type is returned it's a string and and it's wrapped around here these this xml so with this soap web service everything that's returned is serialized as xml and xml was pretty pretty big and pretty commonplace uh maybe 10 years ago it's still used heavily but now people tend to favor jason and we we can look at we can look at that in another video for sure um so yeah the great thing about these these tools as well is they actually allow you these like tester tools if you like they uh they actually give you the the soap that you would send and and the data types that come back so um they're really really useful i'm just going to go ahead and i'm going to modify this very slightly just to show you what it looks like if you're inserting parameters so for example if we say we want to insert an input parameter of say for example a string and we're going to just call it my string because i'm lacking inspiration in variable names and what we'll do is we'll literally get rid of this line here we're going to build it alt tab back refresh the page and as you can see now we've got the variable the the uh the input parameters sorry so in here for example you could insert whatever you want let's click on test and then invoke and it comes back with test well of course this is actually a hello world demo so let's insert hello world exclamation mark it's got to have the exclamation mark of ways it's not a proper hello world tutorial click on invoke and there we have it hello world so that about wraps it up for this this video we're going to take a look at some other technologies in another video perhaps we'll look at web api for example that's that's a restful web service and it's used a lot more these days than soap is so we can go into that and we can have a look at how we would go about creating one of those so if you enjoyed the video if you found it useful please go ahead and click the like button if you want to see similar content to this in the future go ahead and subscribe or consider subscribing should i say what's the worst that could happen and if you've got any suggestions for future videos any any questions on this video or comments go ahead and firm in the comment section below and until next time take care
Info
Channel: Saturday Night Coder
Views: 3,515
Rating: 4.8904109 out of 5
Keywords: Visual Studio, Visual Studio 2019, C#, .NET Framework, Hello World, Tutorial, Programming, Development, Coding, Web, Web Service, ASP.NET, .NET, Web Application, SOAP, SOAP Web Service
Id: 5QbrcldRq3c
Channel Id: undefined
Length: 7min 58sec (478 seconds)
Published: Tue Jan 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.