以下是我的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的读/写权限,但问题仍然存在。任何人都可以提出这里有什么问题。
谢谢。
什么是您的客户端配置是什么样子?你为客户使用'wsHttpBinding'吗?并且为客户端绑定指定的安全性与服务相同吗? – Tim