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);
  • 相关阅读:
    Dev gridControl 按回车增加一行
    Web自动化----常见组件操作
    Web自动化----切换(iframe,浏览器窗口,alret)
    Web自动化----元素等待方法(显式等待和隐式等待)
    Web自动化----模拟动作(鼠标,快捷键,拖拽)
    MySQL的20条基本优化 加参考资料
    国内IT技术博客对比
    博客客户端文章测试
    QQ登录网站接入
    微信公众号本地开发调试工具
  • 原文地址:https://www.cnblogs.com/akingyao/p/2673300.html
Copyright © 2011-2022 走看看