Solved

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

Posted on 2008-06-09
8
731 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
DevOps Toolchain Recommendations

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

 
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

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.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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