zoukankan      html  css  js  c++  java
  • WCF框架基础(三)

    1.首先生成配置文件。服务代理,首先添

    加服务引用在地址栏里输入上文服务端创建的Uri地址

    2.点击确定将生成配置文件

    <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
              textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
              <security mode="Message">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                  realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                  algorithmSuite="Default" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
            contract="ServiceReference.IService" name="WSHttpBinding_IService">
            <identity>
              <userPrincipalName value="PC-201206011335\Administrator" />
            </identity>
          </endpoint>
        </client>
      </system.serviceModel>

    3.使用WCF客户端

    //创建端终结点  ServiceReference属性在配置文件有终节点处查找
    EndpointAddress epAddress = new EndpointAddress("http://localhost:8000/ServiceModelSamples/Service/CalculatorService");
    ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(new WSHttpBinding(),epAddress);

    至此就可以调用服务端定义的服务

      double x=client.Add(3.2, 2.1);
  • 相关阅读:
    Java多线程
    http网页请求状态码
    C++文件读写
    算法训练 最大的算式
    算法训练 2的次幂表示
    线段树- 算法训练 操作格子
    Prim算法(最小生成树)
    Kruskal算法(最小生成树)
    Dijkstra算法(最短路)
    HDU5692 dfs + 线段树维护区间最大值
  • 原文地址:https://www.cnblogs.com/akingyao/p/2673300.html
Copyright © 2011-2022 走看看