WCF服务

解决方案-》添加新建项目-》WCF服务应用程序

每个服务都包含一个ServiceContract 默认的IService1

然后添加对服务的引用

      static void Main()
{
using (Service1Client client = new Service1Client())//使用服务
{
Console.WriteLine(client.ClientCredentials);
Console.WriteLine(client.Add(1, 3));
}
Console.ReadKey();
}

生成的XML文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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:9557/Service1.svc" binding="basicHttpBinding"
bindingConfiguration
="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name
="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>




posted @ 2011-12-29 17:17  Rookier  阅读(362)  评论(0编辑  收藏  举报