Hi,
I am trying to add a custom header to a message of a Webservice, which I can not change. When I add the Serfice Referenc to my app, it did not create an entry inside of my app.config. So I createt a proxyfile with wsdl.exe. Which has all the parts I need.
But the message I generate by default is not accepted by the server, because some parts in the header are missing. So I createt a SoapHeader class:
Public Class Security
Inherits SoapHeader
Public Token As Xml.XmlElement
Public Sub New()
Dim Doc As New XmlDocument()
Dim myXMLSubElement As Xml.XmlElement
myXMLSubElement = Doc.CreateElement( "Identifier")
myXMLSubElement.InnerText = Janitos. MessageInspector.allNodes(0).ToString
Token = Doc.CreateElement( "soapenv", "Token", "http://schemas.xmlsoap.org/ws/2005/02/sc")
Token.AppendChild(myXMLSubElement)
End Sub
End Class
But when I instanciate my new Header, and try to create the message like this:
Public MyHeader As New Security
<SoapHeader("MyHeader", Direction:=SoapHeaderDirection.In), _
System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:getEVBAbruf", RequestNamespace:="http://www.xyz.net/namespace/evb", ResponseNamespace:="http://www.xyz.net/namespace/evb", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function getAnswer(ByVal Request As CT_AnswerRequest) As <System.Xml.Serialization.XmlElementAttribute("Response")> CT_EVBAbrufResponse
Dim Doc As New XmlDocument()
MyHeader.SecurityContextToken.Prefix = "wsc"
MyHeader.MustUnderstand = "1"
Dim results() As Object = Me.Invoke("getAnswer", New Object() {Request})
Return CType(results(0), CT_EVBAbrufResponse)
End Function
I'll get this message:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Header>
- <Security soap:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
- <Token>
- <wsc:Token xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc">
<Identifier xmlns="">wsBu7GHhFcb+GOfT7cvJn5Gdmsmdn7DP+GgzfunG/4cVSQBDnJTJfYkm3CpVgn476D</Identifier>
</wsc:Token>
</Token>
</Security>
</soap:Header>
- <soap:Body>
It creates two entries "Token"( - <Token> AND- <wsc:Token) inside my header, but I need it only once. What is wrong in my header creation?
regards Lothar