【发布时间】:2016-09-06 15:08:28
【问题描述】:
当我使用 VS 生成客户端代理时,我可以连接到托管在 IIS 上的 WCF 服务,但是当我通过浏览器查看时,我得到一个空白页面,当我附加 ?WSDL 时也是如此。我究竟做错了什么?我需要查看 WSDL
我的服务接口
[ServiceContract]
public interface IObjectService
{
[OperationContract]
[WebInvoke(
Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/GetTrade"
)]
GetTradeResponse GetTrade(GetTradeRequest request);
}
还有我的 web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ObjectServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<!-- This section is optional with the default configuration model introduced in .NET Framework 4 -->
<service name="ObjectServiceApi.ObjectService" behaviorConfiguration="ObjectServiceBehaviour">
<!-- This endpoint is exposed at the base address provided by host:http://localhost/ObjectService.svc -->
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpointBinding"
contract="ObjectServiceApi.Interface.IObjectService" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="0" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
【问题讨论】:
-
您调用的 URL 是什么?也许您在 URL 上有一个结尾
slash? /,如下所示:http://localhost:PORT/ObjectService.svc/ -
10.220.175.59:8085/ObjectService.svc - 我试过带和不带斜线。是否可以打开某种 IIS 跟踪以查看是否抛出任何错误?
-
你可以尝试设置
security mode="None"和transport clientCredentialType="None"。可能是认证有问题。 -
另一个想法是完全删除
<services />部分并将<binding name="BasicHttpEndpointBinding">更改为<binding>因为您不需要这些属性,除非您想修改端点(这可能是问题)。 -
我认为您可能对身份验证有所了解。我只记得我最近删除了对匿名开放的 MEX 端点,但我的标准服务需要 Windows 身份验证。由于删除了我的 MEX 端点,我无法再通过 VS 连接到该服务,它给出了 401 未经授权的异常。如何在锁定我的服务的同时公开 WSDL?