Web services 如何使用外部(免费或付费)web服务
如何在应用程序中使用外部web服务(付费或免费)。 例如: 下面是一个网站的代码片段(http://debugmode.net/2010/09/10/consuming-wcf-rest-service-in-asp-net-web-site/)它正在使用自创服务。但是,如果必须使用外部服务,应该如何进行Web services 如何使用外部(免费或付费)web服务,web-services,Web Services,如何在应用程序中使用外部web服务(付费或免费)。 例如: 下面是一个网站的代码片段(http://debugmode.net/2010/09/10/consuming-wcf-rest-service-in-asp-net-web-site/)它正在使用自创服务。但是,如果必须使用外部服务,应该如何进行 public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sende
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
WebClient proxy = new WebClient();
byte[] abc = proxy.DownloadData((new Uri("http://localhost:4567/Service1.svc/GetData")));
Stream strm = new MemoryStream(abc);
DataContractSerializer obj = new DataContractSerializer(typeof(string));
string result = obj.ReadObject(strm).ToString();
TextBox1.Text = result;
}
您应该将WebClient和流包含在using语句中,因为它们实现IDisposable,并且您希望调用它们的实现Dispose()方法。欢迎来到堆栈溢出!请阅读常见问题解答,以便获得更高质量的问题答案。您并不是指希望使用哪种语言访问Web服务(我猜是C#?)。请用语言重新标记你的问题。谢谢