响应内容验证失败

问题描述

我正在将应用程序从.NET Framework 4.6.1重写为.NET Core 3.1。 一个库需要与Soap服务进行通信。基本上所有的东西都可以,除了阅读响应。

问题似乎出在字符集上,应该是 charset =“ utf-8” 收到了 charset = utf-8

有人知道如何在客户端进行调整吗?

最好的问候 法比安

System.ServiceModel.ProtocolException: The content type text/xml; charset="utf-8" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder,be sure that the IsContentTypeSupported method is implemented properly. The first 518 bytes of the response were: '<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:generatePackagesNumbersV2Response xmlns:ns2="http://dpdservices.dpd.com.pl/"><return xmlns=""><Status>OK</Status><SessionId>2722911</SessionId><Packages><Package><Status>OK</Status><PackageId>1264106</PackageId><Parcels><Parcel><Status>OK</Status><ParcelId>1758645</ParcelId><Waybill>0000000831731Q</Waybill></Parcel></Parcels></Package></Packages></return></ns2:generatePackagesNumbersV2Response></S:Body></S:Envelope>'.
   at System.ServiceModel.Channels.HttpResponseMessageHelper.ValidateContentTypeAsync()
   at System.ServiceModel.Channels.HttpResponseMessageHelper.ParseIncomingResponse(TimeoutHelper timeoutHelper)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.ReceiveReplyAsync(TimeoutHelper timeoutHelper)
   at System.ServiceModel.Channels.RequestChannel.RequestAsync(Message message,TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.RequestAsyncInternal(Message message,TimeSpan timeout)
   at System.Runtime.TaskHelpers.WaitForCompletionNoSpin[TResult](Task`1 task)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message,TimeSpan timeout)
   at System.ServiceModel.dispatcher.RequestChannelBinder.Request(Message message,TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object[] ins,Object[] outs,Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(MethodCall methodCall,ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(MethodInfo targetmethod,Object[] args)
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Reflection.dispatchproxygenerator.Invoke(Object[] args)
   at generatedProxy_1.generatePackagesNumbersV2(generatePackagesNumbersV2Request )
   at ServiceReference2.DPDPackageObjServicesClient.generatePackagesNumbersV2(generatePackagesNumbersV2Request request) in C:\Users\fabia\Repos\DocFlowPlatformCore.Server\ClassLibrary1\Connected Services\ServiceReference2\Reference.cs:line 9646
   at Scodes.ShippingProvider.Dpd.DpdProvider2.Create(Shipment shipment) in C:\Users\fabia\Repos\DocFlowPlatformCore.Server\ClassLibrary1\Class1.cs:line 67

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)