如何在C#中使用Web服务 [英] How to Consume Webservices in C#
本文介绍了如何在C#中使用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hey Guru's,
好的,我将重新解释这个问题,我正试图使用C#来使用Web服务,请给我一些线索.
Hey Guru''s,
Okie i will rephrase the question,i was trying to consume the webservices in C#,can you please give me some lead.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Description;
using System.IO;
using System.Xml;
namespace wsdlreader
{
class Program
{
static void Main(string[] args)
{
ServiceDescription wsdl = ServiceDescription.Read(@"C:\Inetpub\wwwroot\WebService1\t.wsdl");
foreach (PortType pt in wsdl.PortTypes)
{
Console.WriteLine("PortType {0}", pt.Name);
foreach (Operation op in pt.Operations)
{
Console.WriteLine("\tOperation: {0}", op.Name);
foreach (OperationMessage msg in op.Messages)
{
if (msg is OperationInput)
Console.WriteLine("\t\tInput Message: {0}", msg.Message);
else if (msg is OperationOutput)
Console.WriteLine("\t\tOutput Message: {0}", msg.Message);
else
Console.WriteLine("\t\tFault Message: {0}", msg.Message);
}
}
}
}
}
}
推荐答案
如何:调用Web服务
http://msdn.microsoft.com/en-us/library/6h0yh8f9 (v = VS.100).aspx [
How to: Call a Web Service
http://msdn.microsoft.com/en-us/library/6h0yh8f9(v=VS.100).aspx[^]
MSDN可能是 ^ ].
MSDN might be the best link for you[^].
使用Web服务之前,必须首先正确安装它.
所有步骤均列在此处:
http://www.eggheadcafe. com/community/aspnet/7/10043054/using-wsdl-file-to-connect-to-a-webservice.aspx [ http://www.orthodoxphotos.com/history.shtml [
Before you consume a Web service you must first install it correctly.
All the steps are listed here:
http://www.eggheadcafe.com/community/aspnet/7/10043054/using-wsdl-file-to-connect-to-a-webservice.aspx[^]
After that using it is very simple. You access the web service as if you accessed a class.
Class.Method....
--
Signature:
How old is the Orthodox Faith?
http://www.orthodoxphotos.com/history.shtml[^]
这篇关于如何在C#中使用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文