如何在C Sharp应用程序中使用WSDL [英] how to consume WSDL in c sharp application

查看:79
本文介绍了如何在C Sharp应用程序中使用WSDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我在远程服务器格式"service?WSDL"上有一个Web服务,并且想在C#应用程序中使用它,请有人可以帮助我如何从我的应用程序访问Web服务.

引用
ASP.NET Web服务 [了解ASP.NET中的Web服务基础 [ ^ ]


如果您使用的是Visual Studio,则可以右键单击该项目,然后选择添加服务引用...".弹出,然后单击高级"框,然后选择添加Web服务引用"

在其中输入服务WSDL的URL,它将允许您在右侧指定名称空间,并在左侧显示所有发现的方法.假设您将名称空间添加为"foobar",并且目标服务称为MyService.

完成添加后,您可以像这样调用服务:

 使用( var  svc =  new  foobar.MySerivce()){

   var  result = svc.SomeMethodOfTheService(withAParameter);

} 



如果您不使用Visual Studio,则必须使用WSDL.exe在命令行上生成代理.

这是使用命令行工具的示例: http://gsraj.tripod.com/dotnet/webservices /webservice_csharp_client.html [ ^ ]


Dear All,

i have a web service on remote server format "service?WSDL" and i want to consume it in C# application, please any one can help me how i can access the web service from my application

解决方案

Refer
ASP.NET Web Service[^]
Understanding the Basics of Web Service in ASP.NET[^]


If you''re using visual studio, you can right click on the project, select "Add a Service Reference..." On the dialog that pops up, then you click the "Advanced" box and choose "Add a Web Service Reference"

In there you enter the url to the service?WSDL and it will allow you to specify a namespace in the right hand side, and display all of the discovered methods on the left. Lets say you added the namespace as "foobar" and your target service is called MyService.

After you complete the add, you can then call the service like this:

using(var svc = new foobar.MySerivce()){

  var result = svc.SomeMethodOfTheService(withAParameter);

}



If you are NOT using visual studio, then you''ll have to generate the proxy on the command line using WSDL.exe.

Here''s an example of using the command line tools: http://gsraj.tripod.com/dotnet/webservices/webservice_csharp_client.html[^]


这篇关于如何在C Sharp应用程序中使用WSDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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