我有两个问题,但我认为在某种程度上存在联系。
我使用 .NET4 并且仅在 https 上创建了 WCF Rest 服务。在我的本地电脑上,一切正常。
现在我将它部署到托管服务提供商。据我所知,所有请求都通过 ISA 服务器。
起初,它没有用。我尝试了很多,但我总是得到错误 404,找不到资源。具体错误是:
[EndpointNotFoundException]: There was no channel actively listening at
'http://mydomainname/items/help'.
This is often caused by an incorrect address URI.
Ensure that the address to which the message is sent matches
an address on which a service is listening.
我看到的第一件事是异常中的 URL 不是 https。好的,奇怪,因为我的 web.config 是:
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceAuthorization serviceAuthorizationManagerType="myNamespace.APIKeyAuthorization, myNamespace" />
</behavior>
</serviceBehaviors>
...
<webHttpBinding>
<binding name="">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</webHttpBinding>
...
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</standardEndpoint>
</webHttpEndpoint>
所以我尝试了很多东西,但最后我成功了。我只是在任何地方都放了一个名字。在行为标签中,绑定和标准端点标签。有用 !!好吧,差不多。现在我所有的结果都是 XML 格式的。我没有json。即使使用带有“Accept: application/json”或“Accept: text/json”行的提琴手,它也总是在 XML 中。即使我将 automaticFormatSelectionEnabled 设置为 false。并将“帮助”添加到 URL,例如“https://mydomainname/items/help”,我得到了“找不到端点”
所以,现在我迷路了,因为我不了解 WCF 中的所有微小配置以使一切正常。希望您能够帮助我。
提前致谢。
M。