zoukankan      html  css  js  c++  java
  • .net webservice 动态更换地址

    //Web服务对象    WebReference.Service1SoapClient objService = new WebReference.Service1SoapClient();
    如果你细心一点的话,右建这个构造方法查看一下转到定义试试

    这是转到定义之后最上面的五个方法大家来看一下吧

    对就是有这样五个自动生成的方法

     代码如下:
    public Service1SoapClient();        
    public Service1SoapClient(string endpointConfigurationName);
    public Service1SoapClient(Binding binding, EndpointAddress remoteAddress);
    public Service1SoapClient(string endpointConfigurationName, EndpointAddress remoteAddress);
    public Service1SoapClient(string endpointConfigurationName, string remoteAddress);

    大家一起看一下第四个方法和第五个方法
    我解释一下

     代码如下:
    //endpointConfigurationName 配置节的名称,remoteAddress配置节对象
    public Service1SoapClient(string endpointConfigurationName, EndpointAddress remoteAddress);
    //endpointConfigurationName 配置节的名称,remoteAddress配置节URL        
    public Service1SoapClient(string endpointConfigurationName, string remoteAddress);        //设置其它参数

    对就是这两个方法,我们只要修改第五个就行了,
    使用方法如下
    //Web服务对象

    代码如下:
    WebReference.Service1SoapClient objService = new WebReference.Service1SoapClient("Service1Soap","你要修改的URL例如:http://www.cckan.net/webservices.asmx");

    问题解决了,我们只要动态配置一下这个参数就行了,具体方法相信大家都会了,存储在数据库或者别的地方都是可以的。

  • 相关阅读:
    什么是代理
    简易的屏幕适配
    SourceTree 操作简介
    project/target/product的简易区别
    iOS申请真机调试证书-图文详解
    关于UINavigationController的backBarButtonItem定制问题
    pat1008
    pat1005
    pat1019-简单模拟题
    ie6-ie8中不支持opacity透明度的解决方法
  • 原文地址:https://www.cnblogs.com/MR---Zhang/p/8534364.html
Copyright © 2011-2022 走看看