Solved

How do I consume a Web Service from a C# Library Project ?

Posted on 2008-06-09
8
730 Views
Last Modified: 2013-12-17
Hello,

I have no problem consuming a web service from an ASP.NET Web Application project. I add a Web Reference and after that  I can easily consume the web service and its methods.

Now if I want to create a C# Class Library Project to test my Web Service, how do I create a Web Reference to the service in order to consume it?

Thank you.

Didier
0
Comment
Question by:DidierSanDiego
  • 5
  • 3
8 Comments
 
LVL 1

Expert Comment

by:picsnet
ID: 21745328
You do it the same way.  I had a hell of a time with it though when I tried to do it the first time.  I can't remember what I did though to fix it.  I'll look for my old question and see if I told what I did...

ServiceEmailer.Emailer objEmailer = new ServiceEmailer.Emailer();     from class library... I  had added the web reference to the class library.  
0
 
LVL 1

Expert Comment

by:picsnet
ID: 21745341
Here was what I did to fix my problems...

Apparently it was something dumb and easy... i deleted the app.config, settings, and those kinda files.  Added the webservice and it worked.  
0
 

Author Comment

by:DidierSanDiego
ID: 21745401
Hello,

Thank you for your prompt reply.

I am unable to find a way to add a Web Reference from my project. How did you do this?

The only option I have is to add a Service Reference.

Didier
0
 
LVL 1

Expert Comment

by:picsnet
ID: 21745483
Add System.Web.WebServices to your project as a reference, maybe System.EnterpriseServices also... I got that as a reference, but I don't remember why... It could be anything.  

Then you might want to make sure that show all files icon is selected in the solution explorer
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Accepted Solution

by:
DidierSanDiego earned 0 total points
ID: 21745693
I was able to add the Web Reference following these steps:

- Right Click "References" in the Solution Explorer
- Click "Add Service Reference"
- Click Advanced...
- Click "Add Web Reference..." (Notice the warning saying: "Add a Web Reference instead of a Service Reference. This will generate code based on .NET Framework 2.0 Web Services technology.")

I am guessing that there is a new way of creating and accessing Web Services on the .NET Framework 3.5.
0
 
LVL 1

Expert Comment

by:picsnet
ID: 21745717
don't know... I use 2008, but I have to use 2.0 framework still for older computers.  
i just add system.web.servservices to my project, and then i add a web reference.  

Or I might have just added the web reference, and then it brought in all those other references.... Hard to remember, I do web services so little.  
0
 

Author Comment

by:DidierSanDiego
ID: 21745738
Thank you very much for the help.

Didier
0
 
LVL 1

Assisted Solution

by:picsnet
picsnet earned 500 total points
ID: 21745801
no prob... i've gotten help here about 250 times... i my as well answer one...  I never go look for questions... They just added a new feature apparently that sends questions related to ones you've asked before to you...

Obviously its a good feature cause i sorta knew the answer, and it wasn't much effort to help.  

Tony
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now