WCF REST 服务在 WCFTestClient 中不可见
我已成功为我的原型服务配置了 3 个端点。端点是 basicHttpBinding、wsHttpBinding 和 webHttpBinding。目前我遇到的唯一问题是 WCFTestClient。当我将其指向我的服务时,它会列出前两个,但不会列出 webHttpBinding。我可以通过浏览器测试 REST 端点,它工作得很好。这是我的配置:
<system.serviceModel>
<services>
<service behaviorConfiguration="serviceBehaviour" name="VMDServices.VMDService">
<endpoint binding="webHttpBinding"
address="rest" behaviorConfiguration="webBehaviour" contract="VMDServices.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint binding="basicHttpBinding"
address="basic" bindingConfiguration="basicBinding" contract="VMDServices.IService1">
</endpoint>
<endpoint binding="wsHttpBinding"
address="ws" bindingConfiguration="wsBinding" contract="VMDServices.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None"></security>
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsBinding" transactionFlow="true">
<security mode="None"></security>
<reliableSession enabled="true" ordered="true" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>
有什么原因导致我在 WCFTestClient 工具中看不到 webHttpEndpoint 吗?
干杯, 丹妮.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是因为 Web 端点(与 SOAP 端点不同)不公开元数据,因此测试客户端在下载服务的 WSDL 时并不知道元数据。与 SOAP 不同的是,SOAP 具有用于公开元数据(WSDL、MEX)的明确定义的格式,而 Web(又名 REST)端点却没有。
这就是短篇故事。如果您想了解更多详细信息,我在 http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-aka-rest-endpoint-不工作.aspx
It's because web endpoints (unlike SOAP ones) do not expose metadata, so the test client doesn't know about it when it downloads the WSDL for the service. Unlike SOAP, which has well-defined formats for exposing metadata (WSDL, MEX), web (a.k.a. REST) endpoints do not.
That's the short story. If you want to know more details, I wrote a blog post about it at http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx
以下是 WCF 测试客户端不支持的功能列表:
• 类型:Stream、Message、XmlElement、XmlAttribute、XmlNode、实现
IXmlSerialized 接口,包括相关的 XmlSchemaProviderAttribute 属性、XDocument 和 XElement 类型以及 ADO.NET DataTable 类型。
• 复式合同。
• 交易。
• 安全性:CardSpace、证书和用户名/密码。
• 绑定:WSFederation 绑定、任何上下文绑定和Https 绑定、WebHttp 绑定(Json 响应消息支持)。
来源:http://msdn.microsoft.com/en-us/library/bb552364 .aspx
The following is a list of features not supported by WCF Test Client:
• Types: Stream, Message, XmlElement, XmlAttribute, XmlNode, types that implement the
IXmlSerializableinterface, including the related XmlSchemaProviderAttribute attribute, and the XDocument and XElement types and the ADO.NET DataTable type.
• Duplex contract.
• Transaction.
• Security: CardSpace , Certificate, and Username/Password.
• Bindings: WSFederationbinding, any Context bindings and Https binding, WebHttpbinding (Json response message support).
Source: http://msdn.microsoft.com/en-us/library/bb552364.aspx
尝试添加公开元数据的“mexHttpBinding”端点
try adding the "mexHttpBinding" endpoint that exposes the metadata