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");

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

  • 相关阅读:
    Zuul token FIlter 验证失败结果输出
    springboot 使用 dev tool 导致 CastException
    索引失效的情况汇总
    JVM笔记-GC常用参数设置
    关于gdb和shp的FID问题
    配置mac百度云同步盘
    【python常用函数1】
    【python环境配置1】 环境变量与常用模块
    【nodejs笔记——小知识点汇总】
    ArcGIS标注
  • 原文地址:https://www.cnblogs.com/MR---Zhang/p/8534364.html
Copyright © 2011-2022 走看看