对于连接到SOAP 1.1 SAP服务的WCF客户端应用程序,一段时间后证书无法正常运行,我遇到了一个特殊的问题。令我难以理解的是我必须采取的措施才能使证书再次发挥作用。我在几个负载均衡的服务器上安装了证书后,似乎一切正常。但几天后,其中一个应用程序/服务器抛出此错误。
请求已中止:无法创建SSL / TLS安全通道。
当我使用MMC登录服务器并打开证书(我甚至不必重新安装它,只需打开就足够了),Web应用程序正常工作。我最终知道为什么会发生这种情况。任何帮助将不胜感激。
以下是有关如何设置应用/网络服务的架构/一些代码示例
[MVC WebApp] - [负载均衡器] - >(服务器1,服务器2) - > SAP SOAP 1.0 Web服务
一些配置和代码示例..
<system.serviceModel>
<client>
<endpoint address="https://somesapwebservice:8104/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_PORTAL&receiverParty=&receiverService=&interface=SI_AppFormData_Out_Sync&interfaceNamespace=urn%3Acominc.com%3AOTC%3AI1053%3AppForm" behaviorConfiguration="secureCert" binding="wsHttpBinding" contract="somecontract_Out_Sync" name="HTTPS_Port" />
</client>
<bindings>
<wsHttpBinding>
<binding>
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="secureCert">
<clientCredentials>
<clientCertificate storeName="My" storeLocation="CurrentUser" x509FindType="FindBySubjectDistinguishedName" findValue="CN=CNN, OU=Windows, OU=SAP, OU=Service Accounts, OU=Admin, OU=CORP, DC=myinc, DC=ds" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
..
<appSettings>
<add key="ProtocolExceptionMessage" value="The content type text/xml; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)" />
C#代码
public ActionResult FormSubmit(SubmitViewModel model)
try
{
this.SubmitToSAPService(model);
return this.RedirectToAction("Index", "Complete");
}
catch (ProtocolException pe)
{
// Current SAP only support SOAP 1.1 and WCF with .NET 4.6 runs on SOAP 1.2 - Catching the known exception
// Creating custom WCF binding to handle this is another possibility but that config could get convoluted
var messageSnippet = ConfigurationManager.AppSettings["ProtocolExceptionMessage"];
if (pe.Message.Contains(messageSnippet))
{
return this.RedirectToAction("Index", "Complete");
}
throw pe;
}
我在这里做的一件事就是我被告知SAP目前正在运行SAOP 1.1,而我们运行的.NET是SOAP 1.2。所以我总是得到协议异常。为了解决这个问题,我检查了文本,如果异常消息与预期完全匹配,我会绕过它。
public string SubmitToSAPService(SubmitViewModel model)
{
var dtFormDataRecords = new DT_FormData();
dtFormDataRecords.Records = new DT_FormDataRecords();
dtFormDataRecords.Records.Name = model.name
....
var client = new SI_AppFormData_Out_SyncClient();
try
{
client.SI_AppFormData_Out_Sync(dtFormDataRecords);
}
finally
{
client.Close();
}
...
答案 0 :(得分:0)
尝试在应用程序上运行intellitrace后,让我在应用程序池设置中提示我加载用户配置文件设置为False。这导致了我遇到的问题。在我将其设置为True后,我的问题得到了解决。