metro 访问WCF

METRO访问WCF的方式很简单,就和访问Webservice是一样的

在项目中添加WCF的引用,在address中填写所请求的地址,点击GO,OK(如果你引用的地址没有错误的话,引用就已经完成了),然后代码中间就可以直接调用了

 ServiceReference1.JokeClient client = new ServiceReference1.JokeClient();
 var query = client.GetJokeListAsync(10);
 List<ServiceReference1.Joke> jokes = query.Result.ToList();
 MessageDialog md = new MessageDialog(jokes[4].Title);
 md.ShowAsync();

另外WCF配置比较重要,这里贴上WCF的配置内容

 <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="NoneSecurity" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
          <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
          <security mode="None"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="JokeService.JokeServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="JokeService.JokeServiceBehavior" name="JokeService.JokeService">
        <endpoint address="" bindingConfiguration="NoneSecurity" binding="wsHttpBinding" contract="IJokeService.IJoke"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>

 

转载于:https://www.cnblogs.com/zhuzhenyu/archive/2012/11/27/2790292.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值