Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4617010
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:03:48+00:00 2026-05-22T02:03:48+00:00

I’m getting this error The remote server returned an unexpected response: (400) Bad Request..

  • 0

I’m getting this error “The remote server returned an unexpected response: (400) Bad Request.”.
I’ve looked at a lot of threads even at stackoverflow and tried those solutions but they dont work for me…like increasing timeouts and buffersizes..

Here’s my code on the server..

 protected override System.ServiceModel.ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {

        BasicHttpBinding basichttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);

        basichttpbinding.CloseTimeout=TimeSpan.MaxValue;
        basichttpbinding.OpenTimeout=TimeSpan.MaxValue;
        basichttpbinding.ReceiveTimeout=TimeSpan.MaxValue;
        basichttpbinding.SendTimeout=TimeSpan.MaxValue;
       // basichttpbinding.TransferMode = TransferMode.Buffered;

        ServiceEndpoint servicepoint=new ServiceEndpoint(ContractDescription.GetContract(serviceType));
         servicepoint.Binding=basichttpbinding;

        ServiceHost servicehost = new ServiceHost(serviceType, baseAddresses);

        ((ServiceDebugBehavior)servicehost.Description.Behaviors[typeof(ServiceDebugBehavior)]).IncludeExceptionDetailInFaults=true;

        servicehost.OpenTimeout = TimeSpan.MaxValue;
        servicehost.CloseTimeout = TimeSpan.MaxValue;
        servicepoint.Binding.SendTimeout = TimeSpan.MaxValue;
        servicepoint.Binding.ReceiveTimeout = TimeSpan.MaxValue;
        basichttpbinding.MaxBufferPoolSize = 999999999;
       // basichttpbinding.MaxConnections = 999999999;
        //basichttpbinding.MaxConnections = 999999999;
        basichttpbinding.MaxReceivedMessageSize = 999999999;
        XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
        quotas.MaxArrayLength = 999999999;
        quotas.MaxBytesPerRead = 999999999;
        quotas.MaxDepth = 999999999;
        quotas.MaxNameTableCharCount = 999999999;
        quotas.MaxStringContentLength = 999999999;
        basichttpbinding.ReaderQuotas = quotas;

        //foreach (Uri uri in baseAddresses)
        //{

        servicehost.AddServiceEndpoint(typeof(IService), basichttpbinding, "");

       // }

        return servicehost;
    }

And here’s the code I’m using on the client..

 static void Main(string[] args)
        {
            BasicHttpBinding basichttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            ServiceEndpoint endpoint=new ServiceEndpoint(ContractDescription.GetContract(typeof(IService)));
            endpoint.Binding=basichttpbinding;


            basichttpbinding.CloseTimeout = TimeSpan.MaxValue;
            basichttpbinding.OpenTimeout = TimeSpan.MaxValue;
            basichttpbinding.ReceiveTimeout = TimeSpan.MaxValue;
            basichttpbinding.SendTimeout = TimeSpan.MaxValue;
            basichttpbinding.TransferMode = TransferMode.Streamed;



            endpoint.Binding.SendTimeout = TimeSpan.MaxValue;
            endpoint.Binding.ReceiveTimeout = TimeSpan.MaxValue;
            basichttpbinding.MaxBufferPoolSize = 999999999;
           // basichttpbinding.MaxConnections = 999999999;
            //basichttpbinding.MaxConnections = 999999999;
            basichttpbinding.MaxReceivedMessageSize = 999999999;
            XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
            quotas.MaxArrayLength = 999999999;
            quotas.MaxBytesPerRead = 999999999;
            quotas.MaxDepth = 999999999;
            quotas.MaxNameTableCharCount = 999999999;
            quotas.MaxStringContentLength = 999999999;
            basichttpbinding.ReaderQuotas = quotas;




         EndpointAddress address=new EndpointAddress("http://localhost:52855/WCFService1/Service.svc");

         ChannelFactory<IService> objClient = new ChannelFactory<IService>(basichttpbinding,address);



         IService obj =   objClient.CreateChannel(address);
         obj.GetData(1);

        }

Please help me..
Thanks..

Edit: Please don’t say “use a config file” etc. I’m doing this only because I have no other choice and have to do it this way.Thanks

Edit: More detailed info after tracing…

  </PRE>This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:</DIV></BODY></HTML></MessageLogTraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>262164</EventID><Type>3</Type><SubType Name="Information">0</SubType><Level>8</Level><TimeCreated SystemTime="2011-05-14T07:42:42.6268846Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{927d4271-a71b-43e6-a8c8-b5b69f5a1b4d}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="6" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Channels.MessageSent.aspx</TraceIdentifier><Description>Sent a message over a channel.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><Source>System.ServiceModel.Activation.HostedHttpContext+HostedRequestHttpOutput/65311427</Source><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/MessageTraceRecord"><MessageProperties><Encoder>application/xml; charset=utf-8</Encoder><AllowOutputBatching>False</AllowOutputBatching></MessageProperties><MessageHeaders></MessageHeaders></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Stop">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-05-14T07:42:42.6278847Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{927d4271-a71b-43e6-a8c8-b5b69f5a1b4d}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="6" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Stop"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Process action ''.</ActivityName><ActivityType>ProcessAction</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>262168</EventID><Type>3</Type><SubType Name="Information">0</SubType><Level>8</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2142614Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Channels.ConnectToIPEndpoint.aspx</TraceIdentifier><Description>Connection information.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><Source>System.ServiceModel.Activation.HostedHttpTransportManager/5669220</Source><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><LocalEndpoint>::1:52855</LocalEndpoint><RemoteEndpoint>::1:0</RemoteEndpoint></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Transfer">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2142614Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" RelatedActivityID="{91bc1c27-5688-4e02-956b-48a9a7e6872c}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Suspend">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2142614Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Suspend"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Listen at 'http://localhost:52855/WCFService1/Service.svc'.</ActivityName><ActivityType>ListenAt</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Start">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2142614Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{91bc1c27-5688-4e02-956b-48a9a7e6872c}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Start"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Processing message 2.</ActivityName><ActivityType>ProcessMessage</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Transfer">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2142614Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{91bc1c27-5688-4e02-956b-48a9a7e6872c}" RelatedActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Stop">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2142614Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{91bc1c27-5688-4e02-956b-48a9a7e6872c}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Stop"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Processing message 2.</ActivityName><ActivityType>ProcessMessage</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Resume">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2142614Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Resume"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Listen at 'http://localhost:52855/WCFService1/Service.svc'.</ActivityName><ActivityType>ListenAt</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131075</EventID><Type>3</Type><SubType Name="Error">0</SubType><Level>2</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2172616Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier><Description>Throwing an exception.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><Exception><ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>There is a problem with the XML that was received from the network. See inner exception for more details.</Message><StackTrace>   at System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
   at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
   at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
   at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details. ---&amp;gt; System.Xml.XmlException: The body of the message cannot be read because it is empty.
   --- End of inner exception stack trace ---</ExceptionString><InnerException><ExceptionType>System.Xml.XmlException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>The body of the message cannot be read because it is empty.</Message><StackTrace>   at System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
   at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
   at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
   at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.Xml.XmlException: The body of the message cannot be read because it is empty.</ExceptionString></InnerException></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>262164</EventID><Type>3</Type><SubType Name="Information">0</SubType><Level>8</Level><TimeCreated SystemTime="2011-05-14T07:42:49.2912658Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Channels.MessageSent.aspx</TraceIdentifier><Description>Sent a message over a channel.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><Source>System.ServiceModel.Activation.HostedHttpContext+HostedRequestHttpOutput/2389992</Source><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/MessageTraceRecord"><MessageProperties><AllowOutputBatching>False</AllowOutputBatching></MessageProperties><MessageHeaders></MessageHeaders></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131076</EventID><Type>3</Type><SubType Name="Information">0</SubType><Level>8</Level><TimeCreated SystemTime="2011-05-14T07:42:49.3462690Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a38d441f-464e-4816-a084-8d6c8b484b59}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="4596" ThreadID="9" /><Channel/><Computer>UNIQUETOP</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.TraceHandledException.aspx</TraceIdentifier><Description>Handling an exception.</Description><AppDomain>46847491-1-129498325594327019</AppDomain><Exception><ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>There is a problem with the XML that was received from the network. See inner exception for more details.</Message><StackTrace>   at System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
   at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)</StackTrace><ExceptionString>System.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details. ---&amp;gt; System.Xml.XmlException: The body of the message cannot be read because it is empty.
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
   at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)</ExceptionString><InnerException><ExceptionType>System.Xml.XmlException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>The body of the message cannot be read because it is empty.</Message><StackTrace>   at System.ServiceModel.Diagnostics.ExceptionUtility.TraceHandledException(Exception exception, TraceEventType eventType)
   at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
   at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
   at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:03:49+00:00Added an answer on May 22, 2026 at 2:03 am

    From the code you posted, it looks like your client is expecting to interact with an IIS-hosted service, given the .svc extension in the URI:

    EndpointAddress address=new EndpointAddress("http://localhost:52855/WCFService1/Service.svc");
    

    You didn’t state whether your service is IIS-hosted or self-hosted, but you did say a config file is not an option. I see two ways to resolve the issue you encountered:

    IIS-Hosted

    1. In order to programatically configure the ServiceHost under IIS, you will need to either:

      a. Implement your own classes deriving from ServiceHost and ServiceHostFactory.

      b. Put the code in-line in the .svc file.

    2. If you choose to implement your own derived ServiceHost and ServiceHostFactory classes, you’ll need to specify your ServiceHostFactory-derived class in the @ServiceHost tag in the .svc file.

    Self-Hosted

    1. In your server code, specify an URI for each endpoint in the AddServiceEndpoint method call.
    2. In your client code, pass the same URI to ChannelFactory when creating the channel.
    3. In this case, you will not have a .svc file.
    4. Don’t forget to close the proxy on the client when you’re done – especially if you’re using IIS.

    I hope this helps get you pointed in the right direction. If you need more information, just ask.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.