深圳网站建设、深圳建网站、网站建设公司定制属于您的高端个性化网站!

搜索深圳网站建设相关案例及相关信息 服务热线:13530005572/15112579390
首页 > 网站建设知识 > .net webserver连接soap而且还需要输入用户名还有密码的方法

.net webserver连接soap而且还需要输入用户名还有密码的方法

  • 所属分类:网站建设知识
  • 作者: 独占网络
  • 更新时间: 2015-2-22 13:17:45
  • 返回列表
我们经常通过.net的webserver去调用其它项目的webserver来实现交换信息,但是如果我们交换信息的方法是采用java的soap写的方法,而且这个方法还有加密的方法,那我们需要怎样调用吧,下面我们先来书写一个.net的类,这个类是用于我们传递参数的。
由于代码大多我们就只贴出部分的代码
public ClientInspector ClientInspector { get; set; }
    public InspectorBehavior(ClientInspector clientInspector)
    {
        ClientInspector = clientInspector;
    }

    public InspectorBehavior()
    {

    }
    public void Validate(ServiceEndpoint endpoint)
    { }
    public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
    {
    }
    public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
    { }
    public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
    {
        if (this.ClientInspector == null) throw new InvalidOperationException("Caller must supply ClientInspector.");
        clientRuntime.MessageInspectors.Add(ClientInspector);
    }
}
其它我们这解决方法里面重要的方法还是我们下面的方法。
ProductWebServiceClient productclient = new ProductWebServiceClient();
productclient.Endpoint.Behaviors.Add(new InspectorBehavior(new ClientInspector(new SecurityHeader("duzhan", "sz886"))));
通过我们上面的代码我们可以看出,我们这里面重要的方法还是使用new SecurityHeader("duzhan", "sz886")方法将我们用户名还有密码传递过去给到用户引用。
如有不懂,联系独占网络(http://www.sz886.com)

相关推荐

您值得信任的网站建设专家!

为其提供系统的基于互联网的品牌行销策略 、 创意执行 、 追踪运营服务 。