消费一个Web服务C#?

001*_*001 4 c# asp.net web-services

我正在构建一个Web服务,它使用外部Web服务(例如http://www.webservicex.com/stockquote.asmx?WSDL),如何在Web服务构建中使用外部Web服务?

rav*_*agw 5

正如其他人所说,为您的项目添加Web引用.

这将为您提供可在项目中使用的命名空间.这是我的一个Utility类的片段.

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();
Run Code Online (Sandbox Code Playgroud)

patweb是我的网络参考的名称.Web引用本身包含许多类.R12_WebService类是包含WSDL中概述的Web服务方法的类.其他类和委托都是异步方法的eventargs和eventhandler.