Remove WS-Addressing/WS-Security sections from WSE 3.0 Client request

后端 未结 5 1399
旧巷少年郎
旧巷少年郎 2020-12-09 23:27

I\'ve got a simple C# web service proxy class that I created with WSDL.exe. I am invoking a method on the remote web service, and it is including a bunch of WS-Addressing a

5条回答
  •  青春惊慌失措
    2020-12-09 23:43

    Based on the answer in this page, I added the code below to remove specific header (by tagname) recursively from XML.

    Public Overrides Function ProcessMessage(ByVal envelope As SoapEnvelope) As SoapFilterResult
        ' Remove all WS-Addressing and WS-Security header info
        RemoveTag(envelope.DocumentElement, "wsa:Action")
        RemoveTag(envelope.DocumentElement, "wsa:MessageID")
        RemoveTag(envelope.DocumentElement, "wsa:To")
        Return SoapFilterResult.[Continue]
    End Function
    
    Private Sub RemoveTag(ByVal XE As System.Xml.XmlElement, ByVal TagName As String)
        For Each N As XmlNode In XE
            If N.ChildNodes.Count > 0 Then
                RemoveTag(N, TagName)
            End If
            If N.Name = TagName Then
                XE.RemoveChild(N)
            End If
        Next
    End Sub
    

提交回复
热议问题