.net 如何仅使用物理 wsdl 文件生成服务引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12710281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:38:48  来源:igfitidea点击:

How to generate service reference with only physical wsdl file

.netweb-servicesservice-reference

提问by kfoster

I have been creating and consuming web services for years and always have been able to use Visual Studio to create a service reference from the client. I have a third party service I need to work with and they refuse to open their security so I can see the wsdl and make the service reference. It's a public facing service so I don't see the need for that level of security but it is what it is.

我多年来一直在创建和使用 Web 服务,并且始终能够使用 Visual Studio 从客户端创建服务引用。我有一个需要使用的第三方服务,他们拒绝打开他们的安全性,所以我可以看到 wsdl 并提供服务参考。这是一项面向公众的服务,所以我认为不需要这种级别的安全性,但它就是这样。

I know this is a n00b question and I'm ashamed to be asking it, but how do I do create the equivalent Service Reference information in my client when all I have available to me is a physical copy of the wsdl the client emailed me? The web.config changes, the object layer over the SOAP data, etc. Just like with an automated Service Reference I just want to open a connection to the service and start using it with the defined objects.

我知道这是一个 n00b 问题,我很惭愧提出这个问题,但是当我可用的只是客户通过电子邮件发送给我的 wsdl 的物理副本时,我该如何在我的客户中创建等效的服务参考信息?web.config 更改、SOAP 数据上的对象层等。就像使用自动化服务引用一样,我只想打开到服务的连接并开始使用它与定义的对象。

The third party service is not WCF as far as I can tell but is SOAP. I'm using VS 2010 btw. Thanks in advance, Ken

据我所知,第三方服务不是 WCF,而是 SOAP。顺便说一句,我正在使用 VS 2010。提前致谢,肯

回答by Ant Radha

This may be the easiest method

这可能是最简单的方法

  • Right click on the project and select "Add Service Reference..."
  • In the Address: box, enter the physical path (C:\test\project....) of the downloaded/Modified wsdl.
  • Hit Go
  • 右键单击项目并选择“添加服务引用...”
  • 在地址:框中,输入下载/修改的 wsdl 的物理路径 (C:\test\project....)。
  • 打去

回答by Lynn Crumbling

There are two ways to go about this. You can either use the IDE to generate a WSDL, or you can do it via the command line.

有两种方法可以解决这个问题。您可以使用 IDE 生成 WSDL,也可以通过命令行来生成。

1. To create it via the IDE:

1. 通过 IDE 创建它:

In the solution explorer pane, right click on the project that you would like to add the Service to:

在解决方案资源管理器窗格中,右键单击要将服务添加到的项目:

enter image description here

在此处输入图片说明

Then, you can enter the path to your service WSDL and hit go:

然后,您可以输入服务 WSDL 的路径并点击执行:

enter image description here

在此处输入图片说明

2. To create it via the command line:

2. 通过命令行创建它:

Open a VS 2010 Command Prompt (Programs -> Visual Studio 2010 -> Visual Studio Tools)
Then execute:

打开 VS 2010 命令提示符(程序 -> Visual Studio 2010 -> Visual Studio 工具)
然后执行:

WSDL /verbose C:\path\to\wsdl

WSDL.exe will then output a .cs file for your consumption.

然后 WSDL.exe 将输出一个 .cs 文件供您使用。

If you have other dependencies that you received with the file, such as xsd's, add those to the argument list:

如果您有随文件收到的其他依赖项,例如 xsd,请将它们添加到参数列表中:

WSDL /verbose C:\path\to\wsdl C:\path\to\some\xsd C:\path\to\some\xsd

If you need VB output, use /language:VBin addition to the /verbose.

如果您需要 VB 输出,/language:VB除了/verbose.