Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove tag Headers in <soap:Header> #213

Open
bolatik opened this issue Aug 14, 2021 · 2 comments
Open

How to remove tag Headers in <soap:Header> #213

bolatik opened this issue Aug 14, 2021 · 2 comments

Comments

@bolatik
Copy link

bolatik commented Aug 14, 2021

<soap:Envelope> <soap:Header> <Headers><userId>1111111111</userId></Headers> </soap:Header> <soap:Body><test></test></soap:Body> </soap:Envelope>

Hello!
how to remove the 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>

@mahe54
Copy link

mahe54 commented Sep 21, 2021

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 :)

@JonLally
Copy link

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants