问题描述
请帮忙!
我有一个带有 .Net Core 的 SOAP WCF 客户端,它正在将请求序列化到 htmlEntity,我有接收器,这就是它向我显示的方式!
<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">urn:call3</a:Action>
<a:MessageID>urn:uuid:9fb7fe14-ace1-4b5f-b055-9f389606f527</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<call3 xmlns="http://ws.allianz.com">
<xml><![CDATA[<?xml version="1.0" encoding="UTF-8"?><chargerequest><transactionnumber>12345</transactionnumber><authentication><company>COL</company><partnerid>CP239516</partnerid><agentid>CA626290</agentid><partnercode>CP239516</partnercode><agentcode>1703229</agentcode></authentication><operationheaders><operationtypecode>TA</operationtypecode><productcode>1251</productcode><policynumber>22310792</policynumber></operationheaders><effectivedate>20190312</effectivedate><TermDate>20200311</TermDate><firstbill>0</firstbill><successive>0</successive><holderdoctype>C</holderdoctype><holderdocnumber>17326334</holderdocnumber><ownerdoctype>C</ownerdoctype><ownerdocnumber>17326334</ownerdocnumber><isholderdriver>S</isholderdriver><isholderowner>S</isholderowner><isnewowner>S</isnewowner><risktype>L0001</risktype><vehicleplate>BIR039</vehicleplate><vehicleorigin>11001</vehicleorigin><vehiclefasecoldacode>l</vehiclefasecoldacode><vehicleyear>2013</vehicleyear><cap>0</cap><riskdata><ownerborndate>19691010</ownerborndate><ownersex>M</ownersex><repowered>N</repowered><protectiondevicecode>1</protectiondevicecode><accessoriesvalue>0.0</accessoriesvalue><shieldingvalue>0.0</shieldingvalue><gassystemvalue>0.0</gassystemvalue><insuredvalue>0.0</insuredvalue><isnewvehicle>N</isnewvehicle><continuity>N</continuity><circulationareadanecode>11001</circulationareadanecode></riskdata></chargerequest>]]></xml>
</call3>
</s:Body>
</s:Envelope>
c#中的代码如下
var b = new NetHttpBinding();
b.Security.Mode = BasicHttpSecurityMode.Transport;
b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
b.TransferMode = TransferMode.StreamedRequest;
b.MessageEncoding = NetHttpMessageEncoding.Text;
Encoding utf8 = new UTF8Encoding();
b.TextEncoding = utf8;
EndpointAddress ea = new EndpointAddress("https://endpointtest/WSHttpsSoap12Endpoint/");
AutosClonicoWSPortTypeClient clientService = new AutosClonicoWSPortTypeClient(b,ea);
var requestInterceptor = new InspectorBehavior();
clientService.Endpoint.EndpointBehaviors.Add(requestInterceptor);
clientService.ClientCredentials.ClientCertificate.SetCertificate(
StoreLocation.CurrentUser,StoreName.Root,X509FindType.FindBySerialNumber,"NumberSerial");
await clientService.OpenAsync();
var res = await clientService.call3Async("<![CDATA[" + "<test><element>exampletest</element></test>" + "]]>");
客户端层面的合约如下
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil","2.0.2")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://example.com",ConfigurationName="ServiceReference2.Example")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document,Use = OperationFormatUse.Literal)]
public interface ClonicoWSPortType
{
[System.ServiceModel.OperationContractAttribute(Action="urn:call3",ReplyAction="urn:call3Response")]
[System.ServiceModel.FaultContractAttribute(typeof(ServiceReference2.ClonicoWSException),Action="urn:call3AutosClonicoWSException",Name="AutosClonicoWSException")]
[return: System.ServiceModel.MessageParameterattribute(Name="return")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document,Use = OperationFormatUse.Literal)]
System.Threading.Tasks.Task<string> call3Async(string xml);
}
如果发生在其他人身上,我感谢您的帮助,我已尝试应用我发现的所有内容,但未能解决,非常感谢您!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)