Response content validation failed - wcf

I'm rewriting app from .NET framework 4.6.1 to .NET Core 3.1.
One library needs to communicate with Soap service. Basically everything works, except response reading.
It looks that the problem is with charset, expected is charset="utf-8" received charset=utf-8.
Does someone have any idea how to adjust it on client side?
Best regards
Fabian
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

Related

access to basicHTTP binding through WCF - results in Forbidden

I am trying to access a web service using WCF client application in CS, when trying to access the web method. I am getting the forbidden error.
Binding configuration:basicHttpBinding
endpoint address=http://xxxxx/yyyy/WebServices/Soap/Query.svc
I noticed 1 more thing - when I try to add the service reference to WCF through VS - it is https://xxxx/yyyy/Webservices/Soap but in app Config it shows http.
Does anyone know how to handle this or what I am missing?
Please do help for the same.
Here is the call stack for the same:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ConsoleApplication1.xxxxxx.Query.Result(String userName, String password, String workflowName, String queryId, QueryData data)
at ConsoleApplication1.UTPQueryService.QueryClient.Result(String userName, String password, String workflowName, String queryId, QueryData data) in

exceptions while calling WCF service from client

When I try to call the WCF on client machine it fails with the following exception. The funny part is sometimes it works perfectly fine. Can anyone assist me on this.
Server stack trace:
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at FixedIncomeReconciliation.ServiceReference1.IFixedIncomeSettlementsService.GetDataService(DateTime date, String isRecon, String tabCaption)
at FixedIncomeReconciliation.ServiceReference1.FixedIncomeSettlementsServiceClient.GetDataService(DateTime date, String isRecon, String tabCaption)
at FixedIncomeReconciliation.ViewModel.MainConfirmsViewModel.ServiceCall(String isRecon, String tabCaption)

Exception when making a call to DB and returning a List<T>

I am making a WCF service that connects to a database and return results. One out of four DataContracts works without a problem (that return an int) but the other three give me an exception (that return a List). Below the error message.
The underlying connection was closed: The connection was closed unexpectedly.
Server stack trace: at
System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException
webException, HttpWebRequest request, HttpAbortReason abortReason)
at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout) 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.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at IReceiverService.SatList() at
ReceiverServiceClient.SatList()
Inner Exception: The underlying connection was closed: The connection
was closed unexpectedly. at System.Net.HttpWebRequest.GetResponse()
at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout)
You probably need to decorate the entities returned or the service with known type attributes

WebHttpBinding authentication ignored

I'm trying to use basic HTTP authentication with a REST service, but debugging proxy shows that no authentication headers are sent at all, they are ignored! Here is my code:
WebChannelFactory<IMyService> factory = new WebChannelFactory<IMyService>(
new WebHttpBinding(),
new Uri("http://10.6.90.45:8081"));
WebHttpBinding http = (WebHttpBinding) factory.Endpoint.Binding;
http.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
http.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
factory.Credentials.UserName.UserName = "username";
factory.Credentials.UserName.Password = "password";
IMyService proxy = factory.CreateChannel();
proxy.SomeMethod();
...
The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was ''.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
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(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
...

WCFTestClient exception on deployed service

I use the WCFTestClient that is provided with visual studio to test my service.
The thing is that the tool is working for the service that is deployed in wisual studio with my aplication. But if I try to connect to a deployed instance on another machine I get the following exception. Has anyone solved this issue?
The service uses WindowsAutentication.
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate oX0we6ADCgEBonQEcmBwBgkqhkiG9xIBAgIDAH5hMF+gAwIBBaEDAgEepBEYDzIwMTAxMDI3MDgzNTIxWqUFAgMCED6mAwIBKakLGwlCQVcuTE9DQUyqJzAloAMCAQOhHjAcGwRob3N0GxRsYmFpdGVzdDAxLmJhdy5sb2NhbA=='.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
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.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IBCMService.GetAllRegions()
at BCMServiceClient.GetAllRegions()
Inner Exception:
The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Inner Exception:
The target principal name is incorrect
at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatus& statusCode)
at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)
at System.Net.NegotiateClient.DoAuthenticate(String challenge, WebRequest webRequest, ICredentials credentials, Boolean preAuthenticate)
at System.Net.NegotiateClient.Authenticate(String challenge, WebRequest webRequest, ICredentials credentials)
at System.Net.AuthenticationManager.Authenticate(String challenge, WebRequest request, ICredentials credentials)
at System.Net.AuthenticationState.AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo)
at System.Net.HttpWebRequest.CheckResubmitForAuth()
at System.Net.HttpWebRequest.CheckResubmit(Exception& e)
You can right click on the config file in wcftestclient, click copy Full path, open the path it in an editor and check that the security settings match the deployed service configuration