我有一个Web解决方案,里面有一个WCF服务项目。我们需要支持“无cookie”。所以在web.config中,它被设置为
<sessionState
mode="SQLServer"
sqlConnectionString="Data Source=ds;Initial Catalog=db;User Id=uid;Password=pwd"
allowCustomSqlDatabase="true"
cookieless="true"
timeout="720"
regenerateExpiredSessionId="false"/>
WCF服务将支持会话,因此我们还在web.config中将“aspNetCompatibilityEnabled”设置为true。
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true"/>
服务和接口如下,
[ServiceContract(SessionMode=SessionMode.Allowed)]
public interface ICDOCService
{ }
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class CDOCService : ICDOCService
{ }
我们面临的问题是我们无法从任何客户端应用程序访问该服务。 (Web应用程序,WCF测试客户端)
当我们通过WCF测试客户端访问
时,会显示以下错误无法调用该服务。可能的原因:服务离线或无法访问;客户端配置与代理不匹配;现有代理无效。有关更多详细信息,请参阅堆栈跟踪。您可以尝试通过启动新代理,还原到默认配置或刷新服务来恢复。
内容类型
text/html
;响应消息的charset=UTF-8
与绑定的内容类型(multipart / related; type =“application / xop + xml”)不匹配。如果使用自定义编码器,请确保正确实施IsContentTypeSupported
方法。响应的前1024个字节是:
<HTML>
<HEAD>
<link rel="alternate" type="text/xml" href="http://localhost:53721/Services/CDOCService.svc?disco"/>
<STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em;
MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000;
FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM:
12px;
COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid;
PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px;
PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0
1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY:
Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT:
15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM:
3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px;
FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}
</STYLE>
<TITLE>CDOCService Service</TITLE></HEAD><BODY><DIV id="content"><P '.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ICDOCService.GetCDOCCount(String institutionID, String mrnID, String userID, String callingSystemID, String securityToken)
at CDOCServiceClient.GetCDOCCount(String institutionID, String mrnID, String userID, String callingSystemID, String securityToken)
答案 0 :(得分:0)
根据@Jeroen的建议重新发表我的评论,因为它似乎有助于OP。
听起来你有相互排斥的要求。如果你绝对不能使用cookies,还有其他方法可以在不使用Session的情况下访问所需的信息吗?也许是持久性数据存储(如数据库中的表)?