zoukankan      html  css  js  c++  java
  • WCF测试程序

    新建console application,添加服务引用,主要Address要到.svc部分。点击Go,找到对应服务后,点击OK。

    双击ServiceReference2可以看到服务的名称,在Main函数中添加应用,如using ConsoleApplication2.ServiceReference2;调用服务中的函数

    CallServiceClient client = new CallServiceClient();

    client.方法名();

    PS:需要在app文件中作如下设置:

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

      <system.serviceModel>

        <bindings>

          <basicHttpBinding>

            <binding name="BasicHttpBinding_ICallService" closeTimeout="00:10:00"

                openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"

                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                maxBufferSize="1111165536" maxBufferPoolSize="11111524288" maxReceivedMessageSize="1111165536"

                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

                useDefaultWebProxy="true">

              <readerQuotas maxDepth="32" maxStringContentLength="111118192" maxArrayLength="111116384"

                  maxBytesPerRead="4096" maxNameTableCharCount="111116384" />

              <security mode="None">

                <transport clientCredentialType="None" proxyCredentialType="None"

                    realm="" />

                <message clientCredentialType="UserName" algorithmSuite="Default" />

              </security>

            </binding>

          </basicHttpBinding>

        </bindings>

        <client>

          <endpoint address="http://localhost:3741/CallService.svc/Call"

              binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICallService"

              contract="ServiceReference1.ICallService" name="BasicHttpBinding_ICallService" />

        </client>

      </system.serviceModel>

    </configuration>

    除红色部分的设置外,其它非必须。

    WCF的web.config文件中的设置:

     <!--behaviorConfiguration="web"-->

            <endpoint address="Call" binding="basicHttpBinding" contract="Call.ICallService" ></endpoint>

            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

     

    http绑定协议设置为basichttp。

    程序发布时,endpoint改为:

     <!--behaviorConfiguration="web"-->

            <endpoint address="Call" binding="webHttpBinding" contract="Call.ICallServicebehaviorConfiguration="web"></endpoint>

            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

    并且要把basicHttpBinding节点改为webHttpBinding。

  • 相关阅读:
    爬过的第一个坑
    Ecshop后台邮件群发
    ECShop 首页调用积分商城里面的的商品
    隐藏select右边的箭头按钮
    让IE6支持PNG透明图片
    PHP替换函数,一些正则!
    php判断终端是手机还是电脑访问网站代码
    ECshop在文章列表页调用文章简介
    Ecshop删除no_license点击查看 云登陆失败,您未有license
    Ecshop商品相册鼠标经过小图切换显示大图
  • 原文地址:https://www.cnblogs.com/ttssrs/p/2777119.html
Copyright © 2011-2022 走看看