[英]Contract requires Session, but Binding ‘WSHttpBinding’ doesn’t support it or isn’t configured properly to support it
[英]Contract requires Session, but Binding 'WSHttpBinding' doesn't support it; 404 with TransportWithMessageCredential
我正在尝试使WCF服务能够通过HTTPS进行通信。
服务器配置:
<system.serviceModel>
<services>
<service name="PortalServiceLibrary.PortalService" behaviorConfiguration="PortalServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="PortalServiceLibrary.IPortalService">
<identity>
<dns value="vmserver"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/PortalServiceLibrary/PortalService/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PortalServiceBehavior">
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="bindingAction" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
<add scheme="https" binding="wsHttpBinding"/>
</protocolMapping>
</system.serviceModel>
客户端配置:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPortalService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://vmserver/PortalService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPortalService"
contract="PortalService.IPortalService" name="WSHttpBinding_IPortalService">
</endpoint>
</client>
</system.serviceModel>
当我使用时:
<security mode="Transport">
我收到以下错误:
Contract requires Session, but Binding 'WSHttpBinding' doesn't support it or isn't configured properly to support it.
但是当我将其更改为:
<security mode="TransportWithMessageCredential">
我收到以下异常:
[WebException: The remote server returned an error: (404) Not Found.]
System.Net.HttpWebRequest.GetResponse() +6592536
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +55
[EndpointNotFoundException: There was no endpoint listening at https://vmserver/PortalService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10733331
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336
Portal.PortalService.IPortalService.GetToken(TokenRequest request) +0
...
我真的不知道该朝哪个方向前进,因为我看上去很卡住。 任何帮助将不胜感激。
首先,
在客户端配置中指定的<wsHttpBinding>
绑定与在服务配置中指定的绑定不同。
请从客户端配置中复制绑定,然后将其粘贴到服务配置中。
<wsHttpBinding>
<binding name="WSHttpBinding_IPortalService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
</security>
</binding>
</wsHttpBinding>
也,
将服务端点(尚未在此处发布)更新为bindingConfiguration="WSHttpBinding_IPortalService"
以及端点地址。
这应至少解决未找到的问题。
希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.