码迷,mamicode.com
首页 > Web开发 > 详细

.net core 2.2.0 SOAP踩坑

时间:2019-06-11 11:29:50      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:on()   counter   ons   client   als   ui测试   model   count   system   

首先确认下面几个程序集是最新版本:

<PackageReference Include="System.ServiceModel.Http" Version="4.5.3" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.5.3" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.5.3" />
<PackageReference Include="System.ServiceModel.Security" Version="4.5.3" />

 

org.xml.sax.SAXException: SimpleDeserializer encountered a child element

大概率是出在sendbody格式上,通过SoapUI测试可以看到正确的数据格式。

 

如果是HTTPS需要在客户端加上如下代码:

client.ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new System.ServiceModel.Security.X509ServiceCertificateAuthentication()
                {
                    CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.Custom,
                    RevocationMode = X509RevocationMode.NoCheck,
                    CustomCertificateValidator = new MyX509CertificateValidator("anything")
                };


    public class MyX509CertificateValidator : X509CertificateValidator
    {
        string allowedIssuerName;

        public MyX509CertificateValidator(string allowedIssuerName)
        {
            this.allowedIssuerName = allowedIssuerName;
        }

        public override void Validate(X509Certificate2 certificate)
        {
            Console.WriteLine($"X509证书:{certificate?.IssuerName?.Name}");
        }
    }

  

.net core 2.2.0 SOAP踩坑

标签:on()   counter   ons   client   als   ui测试   model   count   system   

原文地址:https://www.cnblogs.com/coolyuwk/p/11002118.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!