WCF:使用 WCF 服务是否需要元数据?
我创建了由 Silverlight 应用程序使用的 WCF 服务(去年),它没有元数据(没有 IMetadataExchange 端点)。
现在我需要 Windows 控制台应用程序使用 WCF 服务,但无法添加对服务的引用。我单击“添加服务”发现解决方案的服务,选择“所需”服务并单击“确定”按钮。
我没有创建服务引用,而是收到以下错误:
HTML文档不包含Web 服务发现信息。 元数据包含一个参考 无法解决: 'http://localhost/EnrollmentService.svc'。 没有端点在监听 http://localhost/EnrollmentService.svc 可以接受该消息。这是 通常是由于地址不正确引起的 或 SOAP 操作。请参阅 InnerException,如果 目前,了解更多详情。遥控器 服务器返回错误:(404) 不 成立。如果服务定义在 当前的解决方案,尝试构建 解决方案并添加服务 再次参考。
我应该努力为 WCF 服务添加元数据支持还是应该采用其他解决方案?
请指教。
I created WCF service (last year) that is consumed by Silverlight application and it doesn't have metadata (doesn't have IMetadataExchange endpoint).
Now I need WCF service to be consumed by windows console application and I can't add reference to service. I click 'Add Service' discover solution's services, selected 'required' service and clicked 'Ok' button.
Instead of service reference created I got the following error:
The HTML document does not contain Web
service discovery information.
Metadata contains a reference that
cannot be resolved:
'http://localhost/EnrollmentService.svc'.
There was no endpoint listening at
http://localhost/EnrollmentService.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.
Should I work on adding metadata support for WCF service or it should be another solution?
Please advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
WCF 服务
,而无需公开元数据。元数据用于通过 Visual Studio 或任何其他工具生成代理。因此,如果您不公开元数据,您将必须自己创建/编写这些代理类。
只要您使用正确的服务地址和正确的数据合同,就可以开始。
不创建代理访问WCF服务
You can use a
WCF Service
without exposing metadata.Metadata is used to generate a proxy by
Visual Studio
or any other tool. So, in case you don't expose metadata, you are going to have to create/write these proxy classes yourself.As long as you use correct service address and right data contracts, you are good to go.
Accessing WCF service without creating Proxy