gpt4 book ai didi

c# - 尝试添加服务引用时出错

转载 作者:行者123 更新时间:2023-11-30 15:39:42 25 4
gpt4 key购买 nike

我正在尝试用 C# 创建一个客户端到一个(我想)用 Java 编写的 Web 服务。这是我第一次尝试编写客户端,所以我按照 MSDN 上的说明进行操作,但我遇到了添加引用的问题。当我打开添加服务引用对话框并添加 URL 时,出现错误:

There was an error downloading 'http://geoportal.cuzk.cz/WCTService/WCTService.svc'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://geoportal.cuzk.cz/WCTService/WCTService.svc'.
There was no endpoint listening at http://geoportal.cuzk.cz/WCTService/WCTService.svc 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 server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.

我的下一步应该是什么?我不知道该怎么办!(这是来自捷克共和国的坐标转换服务。)

更多信息:
属性(property)服务 (GetCapabilities) http://geoportal.cuzk.cz/WCTService/WCTService.svc/get

本地化服务: http://geoportal.cuzk.cz/WCTService/WCTService.svc/get?request=GetCapabilities&service=WCTS

最佳答案

我遇到了类似的情况,我创建了一个 WCF 服务 (Employee.svc),后来将名称更改为 EmployeeService.svc。 WCF 项目编译得很好,但是当我尝试通过 UI 客户端添加服务引用时,出现以下错误:

Metadata contains a reference that cannot be resolved: 'http://localhost:2278/EmployeeService.svc?wsdl'.
The document format is not recognized (the content type is 'text/html; charset=UTF-8').
Metadata contains a reference that cannot be resolved: 'http://localhost:2278/EmployeeService.svc'.
There was no endpoint listening at 'http://localhost:2278/EmployeeService.svc' 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 server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.

我通过在各处替换正确的服务类名称来解决它。在我的例子中,它应该是 EmployeeService 而不是 employee。遗漏的地方是在 svc 文件的标记代码中:

<%@ ServiceHost Language="C#" Debug="true" Service="WCFServiceHost.**Employee**" CodeBehind="EmployeeService.svc.cs" %>

改成

<%@ ServiceHost Language="C#" Debug="true" Service="WCFServiceHost.**EmployeeService**" CodeBehind="EmployeeService.svc.cs" %>

它又开始工作了!!!不要忘记在更改服务名称后构建您的 WCF 项目。

关于c# - 尝试添加服务引用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10085048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com