.net core 2.2.0 SOAP踩坑
2024-09-05 15:12:52
首先确认下面几个程序集是最新版本:
<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}");
}
}
最新文章
- ElasticSearch返回不同的type的序列化
- C#基础知识汇总
- DevWebForm控件,触发用客户端事件
- Sort 整理
- 无线客户端框架设计(3):基类的设计(iOS篇)
- grub条目示例
- 用cmd命令合并N个文件
- Discuz!图片查看插件(支持鼠标缩放、实际大小、旋转、下载)
- 转:MVC3系列:~Html.BeginForm与Ajax.BeginForm
- JS 数据类型转换-转换函数、强制类型转换、利用js变量弱类型转换
- windows phone (14) 简单了解Ellipse元素和Rectangle元素
- plsql找外键约束关联的表的方法
- Jmeter+badboy环境搭建
- PHP常用字符串处理函数
- HDU 5791 Two(训练题002 F)
- emWin监护仪界面设计,含uCOS-III和FreeRTOS两个版本
- Compile groovy mixed with java in Maven
- 第一个Eureka程序,Eureka Client的自启动原理和简要过程
- 开源网站流量统计系统Piwik源码分析——后台处理(二)
- java 之UDP编程