Solved

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

Posted on 2008-06-09
8
735 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 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