我有带有IIS7的Windows Server 2008 R2。我在其上部署了WCF服务。当我在浏览器(本地或外部机器)http://sbkisourcedev01/VCIndex/Calculator.svc?wsdl中指定WCF服务地址时,我在浏览器中获取服务描述。但是,当我尝试将项目的引用添加到该服务时,我收到以下错误:
The document was understood, but it could not be processed. - The WSDL document contains links that could not be resolved. - There was an error downloading 'http://sbkisourcedev01/VCIndex/Calculator.svc?xsd=xsd0'. - The underlying connection was closed: An unexpected error occurred on a receive. - Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. - An existing connection was forcibly closed by the remote host Metadata contains a reference that cannot be resolved: 'http://sbkisourcedev01/VCIndex/Calculator.svc?wsdl'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://sbkisourcedev01/VCIndex/Calculator.svc?wsdl. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again.
我在Windows 7上运行此服务,没关系。所以我相信我的W2K8 IIS配置设置有一些东西。
这是我的配置文件:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig" />
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="serviceBehavior"
name="WCFVCIndex.Calculator">
<endpoint address=""
binding="basicHttpBinding"
contract="WCFVCIndex.ICalculator"
bindingConfiguration="basicHttpBindingConfig" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
提前致谢。
答案 0 :(得分:7)
问题在于WCF身份权限。用于承载WCF服务的应用程序池的标识必须对%WINDIR%\ temp文件夹具有完全NTFS权限。在C:\ Windows \ Temp上将该权限更改为我的身份(LOCAL SERVICE)后,我能够将服务引用添加到WCF服务。
答案 1 :(得分:1)