繁体   English   中英

C#-如何向我的项目添加SOAP Web服务引用?

[英]C# - How to add a SOAP web service reference to my project?

我正在尝试将示例项目中的Web服务引用添加到当前的VS 2015 C#项目中。 这是示例项目中的内容:

在此处输入图片说明

要将其移到我的新项目中,我试图通过右键单击我的项目并选择“添加服务引用”将“地址”字段复制并粘贴到我的项目中。 当我这样做时,出现以下错误:

There was an error downloading 'http://myserver.com/MyServiceExample.svc?wsdl/$metadata'.

The remote name could not be resolved: 'myserver.com'
Metadata contains a reference that cannot be resolved: 'http://myserver.com/MyServiceExample.svc?wsdl/$metadata'.
There was no endpoint listening at 'http://myserver.com/MyServiceExample.svc?wsdl/$metadata that could accept the message. 

This is often caused by an incorrect address or SOAP action.     
See InnerException, if present, for more details.

The remote name could not be resolved: 'myserver.com'
If the service is defined in the current solution, try building the solution    and adding the service reference again.

如何将该服务引用添加到我的项目中? 我尝试通过将VS 2015 CMD Prompt与WSDL /verbose命令结合使用来添加它,但这似乎不起作用。 我有该示例的项目文件和wsdl文件,但无法使它们在我的解决方案上工作。

通过启动调试会话在iis express启动您的web-service项目,然后在获得服务的临时URL(例如http:// localhost:8000 / MyServiceExample.svc )时,可以从中检索wsdl

添加服务引用时,只需在新URL上替换myserver.com部分的url。

在这里,您可以了解添加service refence的工作方式,但是通常您需要从已部署的web service (wsdl)中检索合同, vs从中生成新类。

稍后,您应该在部署的web.config更改服务url。

暂无
暂无

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

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