我之前的WCF服务是使用的BasicHttpBinding,服务的web.config只要这样配置 <system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="5242880000" maxBufferSize="655360000" maxReceivedMessageSize="655360000">
<security mode="None"/>
<readerQuotas maxArrayLength="655360000" maxStringContentLength="655360000" maxBytesPerRead="655360000" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>后台通道工厂直接创建通道this._Binding.MaxReceivedMessageSize = int.MaxValue;
this._Binding.MaxBufferPoolSize = int.MaxValue;
this._Binding.MaxBufferSize = int.MaxValue;
this._Binding.SendTimeout = new TimeSpan(1, 1, 1);
this._ReaderQuotas.MaxArrayLength = int.MaxValue;
this._ReaderQuotas.MaxStringContentLength = int.MaxValue;
this._ReaderQuotas.MaxBytesPerRead = int.MaxValue;
this._Binding.ReaderQuotas = this._ReaderQuotas;
EndpointAddress address = new EndpointAddress(ConfigurationManager.AppSettings[key]);
this._Factory = new ChannelFactory<T>(this._Binding, address);
this._Channel = this._Factory.CreateChannel();
客户端我只需要在app.config指定服务 <appSettings>
<add key="svc" value="http://localhost:5802/Service.svc"/>
</appSettings>
客户端代码就可以直接调用服务的方法
DataTable dt = factory.Channel.GetData("select * from t_parameters", null, true, "BaseConnString");但是因为BasicHttpBinding不支持事务,现在想要换成wsHttpBinding,我的配置需要如何修改
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="5242880000" maxBufferSize="655360000" maxReceivedMessageSize="655360000">
<security mode="None"/>
<readerQuotas maxArrayLength="655360000" maxStringContentLength="655360000" maxBytesPerRead="655360000" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>后台通道工厂直接创建通道this._Binding.MaxReceivedMessageSize = int.MaxValue;
this._Binding.MaxBufferPoolSize = int.MaxValue;
this._Binding.MaxBufferSize = int.MaxValue;
this._Binding.SendTimeout = new TimeSpan(1, 1, 1);
this._ReaderQuotas.MaxArrayLength = int.MaxValue;
this._ReaderQuotas.MaxStringContentLength = int.MaxValue;
this._ReaderQuotas.MaxBytesPerRead = int.MaxValue;
this._Binding.ReaderQuotas = this._ReaderQuotas;
EndpointAddress address = new EndpointAddress(ConfigurationManager.AppSettings[key]);
this._Factory = new ChannelFactory<T>(this._Binding, address);
this._Channel = this._Factory.CreateChannel();
客户端我只需要在app.config指定服务 <appSettings>
<add key="svc" value="http://localhost:5802/Service.svc"/>
</appSettings>
客户端代码就可以直接调用服务的方法
DataTable dt = factory.Channel.GetData("select * from t_parameters", null, true, "BaseConnString");但是因为BasicHttpBinding不支持事务,现在想要换成wsHttpBinding,我的配置需要如何修改
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货