首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF客户端Certs在一段时间后停止工作

WCF客户端Certs在一段时间后停止工作
EN

Stack Overflow用户
提问于 2016-07-15 19:30:02
回答 1查看 66关注 0票数 0

对于连接到SOAP1.1SAP服务的WCF客户端应用程序,我有一个非常特殊的问题:证书在一段时间后无法工作。使我感到困惑的是,我必须采取步骤,使证书再次发挥作用。在我在两个负载平衡服务器上安装了证书之后,一切看起来都很好。但是几天后,一个应用程序/服务器抛出了这个错误。

请求被中止:无法创建SSL/TLS安全通道.

当我使用MMC登录到服务器并打开证书时(我甚至不需要重新安装它,只要打开就够了),web应用程序就能工作了。我不知道为什么会发生这种事。任何帮助都将不胜感激。

下面是如何设置应用程序/web服务的体系结构/一些代码示例

MVC Web应用--负载均衡器->(服务器1,服务器2)-> SAP SOAP1.0 Web服务

一些配置和代码示例。

代码语言:javascript
复制
<system.serviceModel>
    <client>
      <endpoint address="https://somesapwebservice:8104/XISOAPAdapter/MessageServlet?senderParty=&amp;senderService=BC_PORTAL&amp;receiverParty=&amp;receiverService=&amp;interface=SI_AppFormData_Out_Sync&amp;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#码

代码语言:javascript
复制
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。所以我总是得到协议例外。为了避免这种情况,我检查文本,如果异常消息与预期完全匹配,我将绕过它。

代码语言:javascript
复制
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();
}
...
EN

回答 1

Stack Overflow用户

发布于 2016-08-11 15:57:35

在尝试在应用程序上运行智能程序之后,让我在应用程序池设置中提示我加载用户配置文件被设置为False。这是因为我遇到的问题。当我把它设置为True之后,我的问题就解决了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38403797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档