简体   繁体   English

SOAP Web服务/ VS2010添加服务引用

[英]SOAP Web Service / VS2010 Add Service Reference

I am having problems gaining access to a clients web service online. 我在获取在线访问客户端Web服务时遇到问题。

If I have the wsdl file, can I do "something" in VS2010 with it so I can add it as a reference and start my C# coding? 如果我有wsdl文件,可以在VS2010中使用它做“东西”,这样我就可以添加它作为参考并开始我的C#编码了吗?

Thanks Paul 谢谢保罗

When you go to "Add Service Reference", the textbox that allows you to enter a URL, can also take a path on your local filesystem to a wsdl. 当您转到“添加服务引用”时,允许您输入URL的文本框也可以将本地文件系统上的路径转换为wsdl。

Additionally, while not the optimal route, you can also use the wsdl.exe/svcutil.exe utility (bundled with VS) to generate a proxy class. 此外,虽然不是最佳路由,但您还可以使用wsdl.exe / svcutil.exe实用程序(与VS捆绑)生成代理类。 Adding a reference is the better way to go, but this is an additional option. 添加引用是更好的方法,但这是一个额外的选项。

Adding the Service Reference as a local path worked for me like a charm. 将服务引用添加为本地路径对我来说就像魅力一样。 I would have voted +1 for xelco52, but my rep is too low... 我会为xelco52投票+1,但我的代表太低了......

Only 1 issue; 只有1个问题; one of my members of the class I've added does not work. 我添加的班级中的一名成员不起作用。 I wonder if I need to use the sledgehammer ...? 我想知道我是否需要使用大锤 ......?

If you have the WSDL file, under one of your projects in VS, right-click the References project folder and choose Add Service Reference. 如果您有WSDL文件,请在VS中的某个项目下,右键单击References项目文件夹,然后选择Add Service Reference。 Click the Advanced button, and in the new dialog click Add Web Reference. 单击“高级”按钮,然后在新对话框中单击“添加Web引用”。 Now, go find the WSDL file, either where you saved it or where you downloaded it, enter its location in the textbox, and click Go. 现在,找到WSDL文件,无论是保存位置还是下载位置,在文本框中输入其位置,然后单击Go。 VS will digest the WSDL and produce a class that is the service client, and others as necessary to implement custom types accepted by the service. VS将消化WSDL并生成一个作为服务客户端的类,并根据需要生成其他类,以实现服务接受的自定义类型。

It's usually a good idea, if you have downloaded the WSDL, to include it as an item in the project that has the web reference; 如果您已经下载了WSDL,那么将它作为项目包含在具有Web引用的项目中通常是个好主意; that allows it to be easily traversed as a reference source, and to be located should you need to recreate the web service classes. 这使得它可以很容易地作为参考源遍历,如果需要重新创建Web服务类,则可以找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM