Question

We have a webserice that rerceives a SOAP message with a soap header as shown below...

The following SOAP message is being sent to the webservice. However, the webservice failes to serialise the header into the MyMessageID object

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       
xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  
<soap:Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">  
<wsa:To>https://www.xxx.co.uk/webservices/xxxxDEV/Service.asmx?  
op=TradesmanAllNBAt</wsa:To>  
<wsa:From>  
<Address>FromAddress</Address>  
</wsa:From>  
<wsa:ReplyTo>  
<Address>ReplyToAddress</Address>  
</wsa:ReplyTo>  
<wsa:Action>https://www.xxxx.co.uk/webservices/xxxxxDEV/TradesmanAllNBAt</wsa:Action>  
<wsa:MessageId>uuid:c6555fee-8b51-4664-88c8-74345b04dda5</wsa:MessageId>  
</soap:Header>  

The web service is code is as defined below

    Imports System.Web.Services  
    Imports System.Web.Services.Protocols  
    Imports System.ComponentModel  
    Imports System.Xml  
    Imports Microsoft.Web.Services3  
    <System.Xml.Serialization.XmlRootAttribute(ElementName:="MessageId",  
    Namespace:="wsa", datatype:="string")> _  

    Public Class MessageId : Inherits SoapHeader  
        <System.Xml.Serialization.XmlTextAttribute()> _  
        Public TextValue As String  
    End Class  


    <System.Web.Services.WebService(Namespace:="https://www.xxxx.co.uk/webservices/xxxxDEV/")>   _    
    <ToolboxItem(False)> _  
    Public Class Service1  

        Inherits System.Web.Services.WebService  
        Public myMessageID As New MessageId  
        Public myRelatesTo As New RelatesTo  
        <WebMethod(), _  
            SoapHeader("myMessageID", Direction:=SoapHeaderDirection.InOut)>  
        Public Function TradesmanAllNBAt(ByVal objDocument As XmlDocument) As XmlDocument  

            Try  
                  myRelatesTo.TextValue = myMessageID.TextValue  


                Return (Nothing)  
            Catch ex As Exception  
                logError(ex.ToString)  
                Return Nothing  
            End Try  

        End Function  
    End Class  


The myMessageID object does not exists we accessing myMessageID.textvalue 

However, if I change the soap header and remove the name space as shown below

<soap:Header>

It works??  The third party insists on sending the name space in the soap header tag and I do not know how to resolve this issue.

Come on you SOAP gurus I really need help on this.

Many thanks in advance
Était-ce utile?

La solution

The issue was to do with the serialisation and the name space changing the MessageID Class serialisation to System.Xml.Serialization.XmlRoot and adding the correct namespace

<System.Xml.Serialization.XmlRoot(ElementName:="MessageId", Namespace:="http://schemas.xmlsoap.org/ws/2004/03/addressing", datatype:="string")> _
Public Class MessageId : Inherits SoapHeader
    <System.Xml.Serialization.XmlTextAttribute()> _
    Public TextValue As String
End Class
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top