如何更改WCF中的绑定? [英] How to changed the binding in WCF?

查看:76
本文介绍了如何更改WCF中的绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

我创建了wcf服务来插入并获取员工的详细信息。它默认具有basichttp绑定,现在我需要更改绑定wshttpbinding。我更改了web.config,如下所示。

Hi sir,
I created wcf service to insert and get the details of employee. Its have the basichttp binding by default, now
i need to change the binding wshttpbinding. I change the web.config like below.

<configuration>
	<system.web>
		<compilation debug="true" targetframework="4.0" />
	</system.web>
	<system.servicemodel>
		
		<!--<behaviors>
			<servicebehaviors>
				<behavior>
					--><!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --><!--
					<servicemetadata httpgetenabled="true" />
					--><!-- 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="false" />
				</behavior>
			</servicebehaviors>
		</behaviors>
		<servicehostingenvironment multiplesitebindingsenabled="true" />-->
		
		<!-- Now editting-->

		<behaviors>
			<servicebehaviors>
				<behavior>

					<servicemetadata httpgetenabled="true" />

					<servicedebug includeexceptiondetailinfaults="false" />
				</behavior>
			</servicebehaviors>
		</behaviors>
		
		<bindings>

			<wshttpbinding>
				<binding name="WsHttpBinding_IService" closetimeout="00:01:00">
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" 
                    useDefaultWebProxy="true">

					<readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
					<security mode="None">
						<transport clientcredentialtype="None" proxycredentialtype="None">
                            realm="" />
						<message clientcredentialtype="UserName" algorithmsuite="Default" />
					</transport></security>

				</readerquotas></binding>
				
			</wshttpbinding>
			
			
		</bindings>
		<client>
			<endpoint address="http://localhost:3823/EmpDetails/Service.svc">
                binding="wsHttpBinding" bindingConfiguration="WsHttpBinding_IService"
                contract="IService" name="WsHttpBinding_IService" />
		</endpoint></client>
		
		
		
	</system.servicemodel>
	<system.webserver>
		<modules runallmanagedmodulesforallrequests="true" />
	</system.webserver>
	<connectionstrings>
		<add name="con" connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\checking.mdf;Integrated Security=True;User Instance=True" providername="System.Data.SqlClient" />
	</connectionstrings>
</configuration>



如果我使用wcftestclient工具测试wcf服务,它会显示基本的http绑定。我的问题是如何更改该wcf服务的

绑定。请给我这个问题的解决方案。


If i test the wcf service using wcftestclient tool, it shows basic http binding. My question is how to change the
binding for that wcf service. Kindly give me the solution for this problem.

推荐答案

您好,



这可能对您有所帮助.. 。



BasicHttpBinding之间的区别和WsHttpBinding [ ^ ]


取决于您定义服务的位置。



通过http://msdn.microsoft.com/en-us/library/ms731833.aspx [ ^ ]和http://msdn.microsoft.com/en-us/library/ms733051.aspx [ ^ ]。
Depends on where you have defined your service.

Go through http://msdn.microsoft.com/en-us/library/ms731833.aspx[^] and http://msdn.microsoft.com/en-us/library/ms733051.aspx[^].


取决于您定义服务的位置。



浏览如何:在代码中指定服务绑定 [< a href =http://msdn.microsoft.com/en-us/library/ms731833.aspxtarget =_ blanktitle =New Window> ^ ]和如何:在配置中指定服务绑定 [ ^ ]。
Depends on where you have defined your service.

Go through How to: Specify a Service Binding in Code[^] and How to: Specify a Service Binding in Configuration[^].


这篇关于如何更改WCF中的绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆