gowsdl
gowsdl copied to clipboard
How to remove tag Headers in <soap:Header>
<soap:Envelope> <soap:Header> <Headers><userId>1111111111</userId></Headers> </soap:Header> <soap:Body><test></test></soap:Body> </soap:Envelope>
Hello!
how to remove the <Headers> tag from soap:Header?
I want to make such a request
<soap:Envelope> <soap:Header> <userId>1111111111</userId> </soap:Header> <soap:Body><test></test></soap:Body> </soap:Envelope>
You can try using version 0.4.0. I have the same problem that the implementation has changed regarding headers from v0.4.0 -> v0.5.0. For me it works in v0.4.0 :)
From the encoding/xml documentation https://pkg.go.dev/encoding/xml#Marshal
a field with tag ",chardata" is written as character data, not as an XML element. ... an anonymous struct field is handled as if the fields of its value were part of the outer struct.
Using an anonymous struct field and having a tag xml:",chardata"
like below should marshal into the desired XML
userId := struct {
XMLName xml.Name
UserId string `xml:",chardata"`
} {
XMLName: xml.Name{Local: "UserId"},
UserId: "1111111111"
}
soapClient.SetHeaders(userId)
Hope this helps :-)