【发布时间】:2014-09-07 19:57:36
【问题描述】:
我对 WCF 有点陌生。我创建了一个服务并且它有效。该服务在 XML 字符串中接收一些请求的键,并返回一个 XML 结果集。
这是我的一般性问题,然后我会给出一些细节。如果有人使用wsHttpBinding 在 WCF 中创建 RESTful 服务,是否有人从外部使用该服务需要提供用户名/PW 凭据?
好的,详细信息。在服务器端,这是核心配置:
<services>
<service behaviorConfiguration="MyService1Behavior" name="MyRestService">
<endpoint
address="http://(address)/myweb/myrestservice.svc"
binding="wsHttpBinding"
contract="IMyRestService">
<identity> <dns value="numeric address" /> </identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
和服务应用接口:
[ServiceContract]
public interface IMyRestService
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "OrderLookup/{LookupData}")]
string OrderLookup(string LookupData);
}
就像我说的,当我从完全在域外的系统中使用它时,这一切都有效。
但我必须提供凭据,如下所示:
MyClientService.ClientCredentials.Windows.ClientCredential.Domain = "remoteserver";
MyClientService.ClientCredentials.Windows.ClientCredential.UserName = "UserID";
MyClientService.ClientCredentials.Windows.ClientCredential.Password = "Password";
我有点担心尝试使用非 .NET 客户端使用服务的人不想提供凭据。所以 - 如果我使用 WCF 创建了一个 RESTful 服务并将其托管在 IIS 上......是否有人从外部访问该服务需要提供凭据,或者有没有办法可以安全地提出不同的解决方案?
再次,我意识到我的知识存在差距 - 只是想填补它们。
提前感谢您的任何建议......
【问题讨论】:
-
wsHttpBinding不是 RESTful 绑定——它是SOAP。使该服务成为 REST 服务的唯一绑定是webHttpBinding
标签: .net wcf rest authorization credentials