Solved

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

Posted on 2008-06-09
8
734 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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
 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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