对于连接到SOAP1.1SAP服务的WCF客户端应用程序,我有一个非常特殊的问题:证书在一段时间后无法工作。使我感到困惑的是,我必须采取步骤,使证书再次发挥作用。在我在两个负载平衡服务器上安装了证书之后,一切看起来都很好。但是几天后,一个应用程序/服务器抛出了这个错误。
请求被中止:无法创建SSL/TLS安全通道.
当我使用MMC登录到服务器并打开证书时(我甚至不需要重新安装它,只要打开就够了),web应用程序就能工作了。我不知道为什么会发生这种事。任何帮助都将不胜感激。
下面是如何设置应用程序/web服务的体系结构/一些代码示例
MVC Web应用--负载均衡器->(服务器1,服务器2)-> SAP SOAP1.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目前正在运行SAO1.1,而我们正在运行的.NET是SOAP1.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();
}
...发布于 2016-08-11 15:57:35
在尝试在应用程序上运行智能程序之后,让我在应用程序池设置中提示我加载用户配置文件被设置为False。这是因为我遇到的问题。当我把它设置为True之后,我的问题就解决了。
https://stackoverflow.com/questions/38403797
复制相似问题