从 WSDL 文件在 Visual Studio 中创建 Web 服务代理 [英] Create web service proxy in Visual Studio from a WSDL file

查看:39
本文介绍了从 WSDL 文件在 Visual Studio 中创建 Web 服务代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要与没有在线 WSDL 定义的 Web 服务通信.然而,开发人员为我提供了一个 WSDL 文件.

My application needs to talk to a web service that hasn't got an online WSDL definition. The developers however supplied me with a WSDL file.

使用公共 WSDL,Visual Studio 可以使用服务引用向导为我生成此代码.但如果没有公共 WSDL,它似乎无法工作.

With a public WSDL Visual Studio can generate this code for me using the Service Reference wizard. But it doesn't seem to work without a public WSDL.

如何使用此 WSDL 文件生成与此 Web 服务对话的代码?

How do I generate the code for talking to this web service using this WSDL file?

推荐答案

尝试使用 WSDL.exe,然后将生成的文件 (.cs) 包含到您的项目中.

Try using WSDL.exe and then including the generated file (.cs) into your project.

启动 Visual Studio 命令提示符(在开始菜单中的 Visual Studio/tools 下)然后输入

Fire up the Visual Studio Command prompt (under visual studio/tools in the start menu) then type

>wsdl.exe [path To Your WSDL File]

这会生成一个文件,您可以复制/移动该文件并将其包含在您的项目中.该文件包含一个类,它是您的服务的代理,启动该类的一个实例,它将具有您可以即时设置的 URL 属性,以及您可以调用的一堆方法.它还将为通过服务接口传递的所有/任何复杂对象生成类.

That'll spit out a file, which you copy/move and include in your project. That file contains a class which is a proxy to your sevice, Fire up an instance of that class, and it'll have a URL property you can set on the fly, and a bunch of methods that you can call. It'll also generate classes for all/any complex objects passed across the service interface.

这篇关于从 WSDL 文件在 Visual Studio 中创建 Web 服务代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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