?
Solved

How do I test a web service?

Posted on 2007-10-11
12
Medium Priority
?
505 Views
Last Modified: 2013-11-19
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??
0
Comment
Question by:Camillia
  • 6
  • 5
12 Comments
 
LVL 3

Accepted Solution

by:
Stashio earned 1000 total points
ID: 20056678
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.
0
 
LVL 7

Author Comment

by:Camillia
ID: 20056726
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...

Now...how 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...
0
 

Expert Comment

by:SUMA ANAND
ID: 20459691
Hi ,

Did you get accurate answer for this question?

I have a similiar question too
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Author Comment

by:Camillia
ID: 20459965
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

0
 

Expert Comment

by:SUMA ANAND
ID: 20460634
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?
0
 

Expert Comment

by:SUMA ANAND
ID: 20460646
What did you ASPX page contained?

Maybe I can try the same? I just need to understand how it works in reality?
0
 
LVL 7

Author Comment

by:Camillia
ID: 20460706
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.
So:
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.
0
 
LVL 7

Author Comment

by:Camillia
ID: 20460716
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:
http://aspnet.4guysfromrolla.com/articles/092607-1.aspx

0
 
LVL 7

Author Comment

by:Camillia
ID: 20460724
>> 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??
0
 

Expert Comment

by:SUMA ANAND
ID: 20460788
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
http://localhost:8080/suma/

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
http://localhost:8080/suma/service1.asmx

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

What should I change
0
 
LVL 7

Author Comment

by:Camillia
ID: 20460836
>>  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.
0
 

Expert Comment

by:SUMA ANAND
ID: 20461095
ok got it..thanks again
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question