消费Web服务的C#? [英] Consume a web service C#?

查看:157
本文介绍了消费Web服务的C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Web服务,它使用的外部Web服务(例如的http:/ /www.webservicex.com/stockquote.asmx?WSDL ),我怎么使用的Web服务IM楼内外部Web服务?

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?

推荐答案

正如其他人所指出的,添加Web引用到项目中。

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是我的Web引用的名称。 Web引用本身包含很多类。该R12_WebService类是包含在WSDL中列出的Web服务方法之一。其他类和代表对我们的异步方法所有的EventArgs和事件处理器。

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.

这篇关于消费Web服务的C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆