如何在本地驱动器中使用wsdl文件

编程入门 行业动态 更新时间:2024-10-27 18:17:36
本文介绍了如何在本地驱动器中使用wsdl文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好 如何在本地系统中使用wsdl文件来使用webservice,我试过在添加Web引用中指定文件路径,但得到的错误是在文档的顶层无效。 谢谢

Hi all How can i use a wsdl file in my local system to consume webservice, i have tried by specifying file path in 'Add Web Reference' , but getting the error 'Invalid at the top level of the document.' Thanks

推荐答案

打开Visual Studio,创建一个Web项目或控制台应用程序,然后右键单击该项目并从上下文菜单中选择添加服务引用。 输入文件将路径和名称放入框中并导入WSDL - 这将生成一个简单,非常基本的WCF客户端供您使用。您应该在生成的代码中找到YourservicenameClient类,该类应该具有WSDL合同中每个已定义方法的方法。 实例化客户端并调用方法你想打电话 - 这就是全部! open Visual Studio, create a web project or console app, and then right-click on the project and pick "Add Service Reference" from the context menu. Enter the file path and name into the box and import the WSDL - this will generate a simple, very basic WCF client for you to use. You should find a "YourservicenameClient" class in the generated code which should have methods for each of the defined methods on the WSDL contract. Instantiate the client and call the methods you want to call - that's all there is! YourServiceClient client = new YourServiceClient(); client.SayHello("World!");

如果您需要指定远程URL(不使用默认创建的远程URL),您可以在代理客户端的构造函数中轻松完成此操作:

if you need to specify the remote URL (not using the one created by default), you can easily do this in the constructor of the proxy client:

YourServiceClient client = new YourServiceClient("configName", "remoteURL");

其中configName是要使用的端点的名称(您将使用除URL之外的所有设置,并且remoteURL是表示要连接的URL的字符串(而不是配置中包含的URL)。

where "configName" is the name of the endpoint to use (you will use all the settings except the URL), and the "remoteURL" is a string representing the URL to connect to (instead of the one contained in the config).

更多推荐

如何在本地驱动器中使用wsdl文件

本文发布于:2023-11-24 05:48:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:器中   文件   如何在   wsdl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!