zoukankan      html  css  js  c++  java
  • [学习日记]对SOAP请求的头添加内容的方法

    方法主要是利用类的继承
    继承WEB服务的代理类,然后添加新的方法,实现对SOAP请求信封的头内添加信息。

    以下是生成的继类的代码,继承类的名为GetHttpHeadersProxy.vb

    Imports System.Net
    Imports System.Collections.Specialized

    Public Class GetHttpHeadersProxy
        
    Inherits getheaders.header
        
    Private headerstoadd As NameValueCollection

        
    Public Sub New()
            headerstoadd 
    = New NameValueCollection

        
    End Sub


        
    Public Sub addhttpheader(ByVal headername As StringByVal headervalue As String)
            headerstoadd.Add(headername, headervalue)
        
    End Sub


        
    Protected Overrides Function GetWebRequest(ByVal uri As Uri) As WebRequest
            
    Dim request As WebRequest
            request 
    = MyBase.GetWebRequest(uri)
            request.Headers.Add(headerstoadd)
            
    Return request
        
    End Function

    End Class

    其中用绿色底高亮显示的地方为对WEB服务生成的引用类

    在使用时如下方法
    dim proxy as GetHttpHeadersProxy=new GetHttpHeadersProxy
    proxy.AddHttpHeader(
    "name","aowind")
    proxy.AddHttpHeader(
    "sex","man")

    这样就可以在SOAP请求的头里加上所需要的值了。
  • 相关阅读:
    2月8日
    2月7日
    2月6日
    2月5日
    事务
    synchronized关键字详解(二)
    synchronized关键字详解(一)
    java.sql.SQLException: Access denied for user 'somebody'@'localhost' (using password: YES)
    wex5 教程 之 图文讲解 wex5集成HTML5 视频播放器
    wex5 实战 加密与解密系列(1) DES算法引入与调用
  • 原文地址:https://www.cnblogs.com/aowind/p/111970.html
Copyright © 2011-2022 走看看