.net core 2.2.0 SOAP踩坑

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




 

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踩坑)