zoukankan      html  css  js  c++  java
  • Silverlight引用WCF 修改配置

    第一种

    可以修改*.xap文件中的ServiceReferences.ClientConfig将服务的地址改过来即可

    注:*.xap可以用winrar解压,ServiceReferences.ClientConfig中有 <client>
                <endpoint address="http://192.168.2.160/AppService/AppService.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDatabaseService"
                    contract="DrawseeAppService.IDatabaseService" name="BasicHttpBinding_IDatabaseService" />
                <endpoint address="http://192.168.2.160/AppService/AppService.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserManageService"
                    contract="DrawseeAppService.IUserManageService" name="BasicHttpBinding_IUserManageService" />
            </client>

    将其中的 http://192.168.2.160/AppService/AppService.svc改成你现在的服务地址。

    第二种 动态调用服务

    1.删除ServiceReferences.ClientConfig文件

    2.新建一个类

      public static DatabaseServiceClient GetDynamicClient()
            {
                BasicHttpBinding binding = new BasicHttpBinding(
                    Application.Current.Host.Source.Scheme.Equals(
                    "https", StringComparison.InvariantCultureIgnoreCase) ?
                    BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None);
                binding.MaxReceivedMessageSize = int.MaxValue;
                binding.MaxBufferSize = int.MaxValue;
                return new DatabaseServiceClient(binding, new EndpointAddress(new Uri(Application.Current.Host.Source, "../AppService.svc")));
            }

    在要调用的地方 DatabaseServiceClient client = 类名.GetDynamicClient();

    其它的和原来调用wcf服务都一样。

  • 相关阅读:
    1 TKinter小窗口及标题
    css之padding,marging
    css之opacity
    css之position
    Leetcode 1368 使网格图至少有一条有效路径的最小代价
    Leetcode 137 只出现一次的数字II
    Leetcode 135分发糖果
    Leetcode 134加油站
    Leetcode 124 二叉树的最大路径和
    Leetcode 5346 二叉树中的列表
  • 原文地址:https://www.cnblogs.com/ZJ199012/p/2540592.html
Copyright © 2011-2022 走看看