<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Default"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered" 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" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:8080/WCFService/ShowMyName.svc?wsdl"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Default"
contract="Contracts.IShowMyName"
name="BasicHttpBinding_IShowMyName" />
</client>
</system.serviceModel>
</configuration>
(2) 客户端调用服务
在客户端中添加引用:
using System.ServiceModel.Channels;
ChannelFactory<IShowMyName> factory = new ChannelFactory<IShowMyName> ("BasicHttpBinding_IShowMyName");
IShowMyName myobject = factory.CreateChannel();
//调用服务的方法
string time = myobject.showName(this.txtName.Text);
原文地址:http://blog.csdn.net/u010927139/article/details/43965977