Wcf 响应内容验证失败

Wcf 响应内容验证失败,wcf,.net-core,soap,wsdl,.net-standard,Wcf,.net Core,Soap,Wsdl,.net Standard,我正在将应用程序从.NET framework 4.6.1改写为.NET Core 3.1。 一个库需要与Soap服务通信。基本上,除了回应阅读,所有的东西都能工作 看起来问题出在字符集上,预期是charset=“utf-8”收到charset=utf-8 有人知道如何在客户端进行调整吗 致意 费边 System.ServiceModel.ProtocolException:内容类型text/xml;响应消息的charset=“utf-8”与绑定的内容类型不匹配(text/xml;charset

我正在将应用程序从.NET framework 4.6.1改写为.NET Core 3.1。 一个库需要与Soap服务通信。基本上,除了回应阅读,所有的东西都能工作

看起来问题出在字符集上,预期是charset=“utf-8”收到charset=utf-8

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

致意 费边

System.ServiceModel.ProtocolException:内容类型text/xml;响应消息的charset=“utf-8”与绑定的内容类型不匹配(text/xml;charset=utf-8)。如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前518个字节是:“OK2722911OK1264106OK1758645000000831731Q”。
位于System.ServiceModel.Channels.HttpResponseMessageHelper.ValidateContentTypeAsync()处
位于System.ServiceModel.Channels.HttpResponseMessageHelper.ParseIncomingResponse(TimeoutHelper TimeoutHelper)
位于System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.ReceiveReplySync(TimeoutHelper TimeoutHelper)
位于System.ServiceModel.Channels.RequestChannel.RequestAsync(消息消息,TimeSpan超时)
位于System.ServiceModel.Channels.RequestChannel.RequestAsyncInternal(消息消息,TimeSpan超时)
在System.Runtime.TaskHelpers.WaitForCompletionNoSpin[TResult](任务'1任务)中
位于System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)
位于System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超时)
在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作、布尔单向、ProxyOperationRuntime操作、对象[]输入、对象[]输出、时间跨度超时)
在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作、布尔单向、ProxyOperationRuntime操作、对象[]输入、对象[]输出)
位于System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(MethodCall MethodCall,ProxyOperationRuntime操作)
在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(MethodInfo targetMethod,对象[]args)处
---来自引发异常的上一个位置的堆栈结束跟踪---
位于System.Reflection.DispatchProxyGenerator.Invoke(对象[]args)
在generatedProxy_1.GeneratePackagesUnbersv2(GeneratePackagesUnbersv2Request)
在C:\Users\fabia\Repos\DocFlowPlatformCore.Server\ClassLibrary1\Connected Services\ServiceReference2\Reference.cs中的ServiceReference2.dpdpdpackageObjServicesClient.generatePackagesNumbersV2(generatePackagesNumbersV2Request请求)中
在C:\Users\fabia\Repos\DocFlowPlatformCore.Server\ClassLibrary1\Class1.cs中的Scodes.ShippingProvider.Dpd.dpdpdpdpdprovider2.Create(装运装运)中

您使用了哪些绑定?core支持的绑定是有限的。嗨,我使用的是基本http绑定。最后我发现了类似的问题,但在应用它之后,服务器在读取我的请求时遇到了问题,所以基本上我决定实现我自己的客户端,并使用HttpWebRequestsId HttpWebRequests帮助您解决问题?基本上是的,但还需要很多额外的工作来实现通信。
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, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, 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