响应消息的内容类型text / html与绑定的内容类型不匹配(text / xml; charset = utf-8)

时间:2018-10-09 10:06:17

标签: wpf wcf windows-authentication

我有一个WPF应用程序,正在使用WCF终结点 但是,当我尝试调用该服务时,出现以下错误,有趣的是,有时它正在工作,但是大多数情况下,我收到以下错误

An unhandled exception of type 'System.ServiceModel.ProtocolException' 
occurred in mscorlib.dll

Additional information: The content type text/html 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 75 bytes of the response were: 'The page 
cannot be displayed because an internal server error has occurred.'.

服务器堆栈跟踪:

at 
System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory`1.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 TrainCbw.cbw.ICBW2Service.GetAARCompanyProfileData(Int32 customerNo, String callerID)
   at TrainCbw.cbw.CBW2ServiceClient.GetAARCompanyProfileData(Int32 customerNo, String callerID) in c:\Users\ramakrishna.j\Documents\Visual Studio 2013\Projects\TrainCbw\TrainCbw\Service References\cbw\Reference.cs:line 6271
   at TrainCbw.Program.Main(String[] args) in c:\Users\ramakrishna.j\Documents\Visual Studio 2013\Projects\TrainCbw\TrainCbw\Program.cs:line 17
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttp_XXXService">
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint 
address="http://dasdassd0343.icdd.net/XXX2Services.svc/XXXService"
            binding="basicHttpBinding" 
bindingConfiguration="BasicHttp_XXXService"
            contract="xxx.IXXX2Service" name="BasicHttp_XXXService" />
    </client>
</system.serviceModel>
</configuration>

0 个答案:

没有答案