001
001

Reputation: 65077

Consume a web service C#?

I'm building a web service, and it uses an external web services (example http://www.webservicex.com/stockquote.asmx?WSDL) , how do I consume the external web service inside the web service im building?

Upvotes: 4

Views: 5887

Answers (6)

ravibhagw
ravibhagw

Reputation: 1740

As others have stated, add a web reference to your project.

This will give you a namespace that you can use in your project. Here is a snippet from one of my Utility classes.

using System;
//...there's more
using System.Text;
using WSDebug.patweb; //web reference to WSDL

namespace WSDebug
{
    class Utils
    {
        private static R12_WebService ws = new R12_WebService();

patweb is the name of my web reference. The web reference itself contains many classes. The R12_WebService class is the one that contains the web service methods outlined in the WSDL. The other classes and delegates are all eventargs and eventhandlers for our asynchronous methods.

Upvotes: 5

Mechamonkey
Mechamonkey

Reputation: 378

Just add a web reference in your calling service by right clicking the project and adding a web reference to the service you wish to consume.

You can keep chaining services like this for instance Service A -> B -> C

Upvotes: 1

Yves M.
Yves M.

Reputation: 3318

Right-Click on the project and "Add Web Reference". Point to the location (url) the service is hosted.

Upvotes: 0

Amokrane Chentir
Amokrane Chentir

Reputation: 30385

By adding a Web Reference to your project.

Upvotes: 0

user414661
user414661

Reputation: 1042

Add it as a Web Reference to the project?

Upvotes: 0

Justin Niessner
Justin Niessner

Reputation: 245389

Add a Service Reference to the external Web Service inside your Web Service Project.

Upvotes: 2

Related Questions