How do I test a web service?

I was asked to write a web service and now I need to test it.
The web service has one function like this:
<WebMethod()> _
    Public Function GetInfo(userid AS String, code As String, sysid As Integer) As Integer
    End Function

**** I need to write a webpage, register the web service, "consume" it by calling that function??
Who is Participating?
StashioConnect With a Mentor Commented:
Either install the MS IIS service or download Apache - both will then turn your PC into a local host for webpages, etc, allowing you to test your script.
CamilliaAuthor Commented:
hmm...I do have MS IIS. But my question is...I have the web service. It compiles... I have that function in there...I created a Virtual Directory for the web services in IIS... do I call that function to make sure that web service is working?? write an aspx page, register that web service using "Add Web Reference", call that function in the web services and display the values in the aspx page??

Basically..."consume" that web service...sorry...i'm new to web services and have read only couple of articles about it...
Hi ,

Did you get accurate answer for this question?

I have a similiar question too
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

CamilliaAuthor Commented:
complete answer is this:

I wrote a web service and had a function. To test it , I wrote an aspx page, "added a web reference" to my web service. On my aspx page, i have a textbox to display the web service's output to make sure my web service's function calculation is correct.

For example, in my aspx page, after i added a web service reference: "callConnected" is a method/funcion in my web services

localhost.Service1 UniTest = new localhost.Service1();
            //test the web service            
 TextBox1.text = UniTest.callConnected("John","", "141636                001", "", "", "", "", "", "", "MED03", "K000044199 026  ", "");

Open in new window

I created a Windows application on Visual Studio 2005 with a class.

If I click on Add Web reference , it shows me the option :-
Use this page as a starting point to find Web services. You can click the links below, or type a known URL into the address bar.
Browse to:
Web services in this solution
Web services on the local machine
Browse UDDI Servers on the local network
Query your local network for UDDI servers.  

Which one should I choose? Should I first create a Web service ?

I also have localhost:8080 installed on my machine.

really confused here?
What did you ASPX page contained?

Maybe I can try the same? I just need to understand how it works in reality?
CamilliaAuthor Commented:
so you've created a class to in a winform to test it...right?
When you "add a web reference", type the URL of your web services in there. Click "add" and it should add it.

Then you can reference the method in your web service like my code.
1. you created a web services. You have IIS and you need to create a virtual directory for it. Just like a regular website. Your UR would be : http://localhost/whateveryounamedyoursite/service1.asmx 

That Service1.asmx is whatever you named your file in your webservices

2. To test your web services website, you have a winform class. You need to "add a reference" to that url. Then reference the web services like my code and call your method.
CamilliaAuthor Commented:
So "or type a known URL into the address bar."...type the URL of your web services in there.

Part 1, 2 and 3 of this article got me going:

CamilliaAuthor Commented:
>> Which one should I choose? Should I first create a Web service ?

Of course you need to create a web service. Otherwise, what are you trying to test??
Here are the steps I have followed;-

1.> In VS 2005, I created a Windows application called Example2 which has a form and a class called Line.vb. Very basic , very simple. It runs great!

2.> Now, I also have IIS installed which I access as

I have list of files sitting here. So thats good.

3.> Next, I quickly copied and pasted your code (above) and named as Service1.asmx
I saved this on the same location - http://localhost:8080/suma/

4.> so my URL address would be

IT DOES NOT WORK. The service1.asmx has the same code as you have above.

What should I change
CamilliaAuthor Commented:
>>  I quickly copied and pasted your code (above) and named as Service1.asmx

no, that's not correct. That code is for TESTING the webservice. It's not the code FOR web service.

Read the first 3 articles of that 4guysfromrolla. It will guide you thru writing a web service and tesing it.

You need to write the code for web service. Code for web service must have "webmethod" in it. But that article really does walk you thru it.
ok got it..thanks again
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.