我的服务有一个返回 DataTable 的 OperationContract。每当我从中获得访问权限时,服务器错误都会显示“现有连接被远程主机强行关闭”
在服务端的 IServie1.svc 中,
[ServiceContract]
public interface IService1
{
[OperationContract]
bool HandShake(int branchId);
[OperationContract]
Investigation Synchronize(string tblName);
[OperationContract]
DataTable Synchronize1(string tblName);
在我的客户端代码中,
Service1Client client = new Service1Client();
GridView1.DataSource = client.Synchronize1("inv");
GridView1.DataBind();
在服务的 Web.config 中,
<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" />
在客户端的 Web.config 中,
<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>