Reputation: 21
My Service has one OperationContract that returns DataTable. Whenever I get access from this, The server error says "An existing connection was forcibly closed by the remote host"
In IServie1.svc in service side,
[ServiceContract]
public interface IService1
{
[OperationContract]
bool HandShake(int branchId);
[OperationContract]
Investigation Synchronize(string tblName);
[OperationContract]
DataTable Synchronize1(string tblName);
In my client side code,
Service1Client client = new Service1Client();
GridView1.DataSource = client.Synchronize1("inv");
GridView1.DataBind();
In Web.config at service,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basic1" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WcfService2.Service1" behaviorConfiguration="Service1Behavior">
<endpoint
address=""
binding="basicHttpBinding"
contract="WcfService2.IService1"
bindingConfiguration="basic1"></endpoint>
<endpoint
address="Add2"
binding="wsHttpBinding"
contract="WcfService2.IService1"></endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost/WcfService2/Service1.svc"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
In Web.config in client side,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WcfService2/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
<!--<endpoint address="http://localhost/WcfService2/Service1.svc/Add2"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
<identity>
<servicePrincipalName value="host/Jenny-PC" />
</identity>
</endpoint>-->
</client>
Upvotes: 1
Views: 4089
Reputation: 137
Returning a DataTable is not always a best practice in doing web service, imaging your consumers are not using .NET, how would they serialize the message, what is the counterpart of DataTable in their language, blah blah.
Regarding your questions, I think you should add diagnostics to be able to see the exactly happened: Add the following section to serviceModel
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="300000"
maxSizeOfMessageToLog="2000000"/>
</diagnostics>
And this section to 1st level of app.config or web.config
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\SdrConfigExample.e2e" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\messages.svclog" />
</listeners>
</source>
</sources>
Let us know when you found out ;)
Upvotes: 1