2014-02-05 42 views
1

以下是我的WCF配置。我在IIS中发布了它,并尝试从Windows窗体客户端连接到它。元数据包含无法解析的参考。

<system.serviceModel> 
<client /> 
<bindings> 
    <wsHttpBinding> 
    <binding name="BindingConfiguration"> 
     <security> 
     <message clientCredentialType="UserName" /> 
     </security> 
    </binding> 
    </wsHttpBinding>  
</bindings> 
<services> 
    <service name="Service" behaviorConfiguration="BehaviorConfiguration">   
    <endpoint address="" binding="wsHttpBinding" name="wsBinding" contract="WCFHttps.IService1" bindingConfiguration="BindingConfiguration"/> 
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name= "BehaviorConfiguration"> 
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     <serviceCredentials>    
     <userNameAuthentication userNamePasswordValidationMode="Windows"/> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />--> 

它试图在测试客户端添加服务引用抛出一个错误。

The HTML document does not contain Web service discovery information. 
Metadata contains a reference that cannot be resolved: '****/Service1.svc?wsdl'. 
Content Type application/soap+xml; charset=utf-8 was not supported by service ****/Service1.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. 

我也通过C:\ Windows \ Temp文件夹授予了对IIS_USRS的读/写权限,但问题仍然存在。任何人都可以提出这里有什么问题。

谢谢。

+0

什么是您的客户端配置是什么样子?你为客户使用'wsHttpBinding'吗?并且为客户端绑定指定的安全性与服务相同吗? – Tim

回答

0

原因: 当您尝试引用WCF服务IIS尝试访问C:\ Windows \ Temp文件夹时,此错误的原因很简单。如果ASP.NET或IIS_IUSER(基于Windows版本)帐户无法访问此文件夹,您将看到此错误。

解决方案: 将ASP.NET或IIS_USER帐户添加到此文件夹或给予您运行应用程序的用户帐户的管理员权限。

配置跟踪 http://msdn.microsoft.com/en-us/library/ms733025.aspx

+0

我将IIS_IUSRS的完整权限授予C:\ Windows \ Temp文件夹,但仍然无效。 – user3007740

+0

'客户端和服务绑定可能不匹配.'这可能是这里的关键,但是没有看到OP的客户端配置,很难确定。 – Tim

0

在我的情况下错误的命名空间是在web.config文件中指定。它必须与您的.svc文件的命名空间:

<service name="NAMESPACE.SvcFileName"> 
    <endpoint contract="NAMESPACE.IContractName" /> 
    </service> 

例子:

<service name="MyNameSpace.FileService"> 
<endpoint contract="MyNameSpace.IFileService" /> 
</service> 

(Unrelevant这些样本中省略标签)

相关问题