我有一个正在使用WCF服务的Web应用程序。它在TransactionScope中包装了几个方法调用,以防止数据损坏。当使用Web应用程序时,它似乎成功进行了方法调用,因为它返回了适当的数据;数据库似乎没有提交数据。在实现事务支持之前,所有方法都有效并且数据已提交。 web.config文件中的服务配置是:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" transactionFlow="true" />
</wsHttpBinding>
</bindings>
<services>
<service name="SSOAuthenticationService.SSOUserService">
<endpoint address="SSOAuthenticationService"
binding="wsHttpBinding"
contract="SSOAuthenticationService.ISSOUserService"
bindingName="wsHttpBinding"
listenUri="SSOAuthenticationService"
bindingConfiguration="wsHttpBinding" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="wsHttpBinding" scheme="http" bindingConfiguration="wsHttpBinding" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
对于客户:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_SSOUserService" receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionFlow="True" maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://ssoauthservice.com/SSOUserService.svc/SSOAuthenticationService"
binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_SSOUserService"
contract="SSOService.SSOUserService" name="wsHttpBinding_SSOUserService">
<identity>
<userPrincipalName value="SSOAuthServiceDev@local" />
</identity>
</endpoint>
</client>
该服务使用代码首先使用EF数据库方法进行数据库访问。我不确定要包括哪些其他信息,但希望有人知道我做错了什么。
谢谢
我知道这已经很晚了,你有可能设法解决它,但如果没有,在客户端应用程序中,尝试在启动事务范围之前启动服务代理