我正在尝试将示例项目中的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.
如何将此服务引用添加到我的项目中?我尝试使用带有WSDL /verbose
命令的VS 2015 CMD Prompt添加它,但这似乎不起作用。我有示例的项目文件和wsdl文件,但我无法让他们处理我的解决方案。
答案 0 :(得分:0)
通过启动调试会话在web-service
中启动您的iis express
项目,然后当您获得服务的临时网址时(例如http://localhost:8000/MyServiceExample.svc),您可以从中恢复wsdl
。< / p>
添加服务参考时,只需在新网址上替换myserver.com
部分网址。
Here您可以了解添加service refence
的工作原理,但一般情况下,您需要从部署的web service
(wsdl)中审核合同,vs
生成新类
稍后您应该在已部署的web.config
中更改服务网址。