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 add xmlns="" <tag xmlns=""> </tag> #200

Open
ironytr opened this issue Apr 1, 2021 · 1 comment
Open

how to add xmlns="" <tag xmlns=""> </tag> #200

ironytr opened this issue Apr 1, 2021 · 1 comment

Comments

@ironytr
Copy link

ironytr commented Apr 1, 2021

hello i'm new at golang and programming and i have a noobish question. i couldn't find on google the answer. the soap server fails with generated code by gowsdl. but i add this xmlns="" to auth tag its working like a charm. So how can i add this to tags?

Not accepted by server


<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body xmlns="http://schemas.xmlsoap.org/soap/envelope/">
	<GetCitiesRequest xmlns="http://www.n11.com/ws/schemas">
		<auth>                     <<<<<<<<<<<<<<<<------------ fails because no xmlns=""
			<appKey>xxx</appKey>
			<appSecret>xx</appSecret>
		</auth>
	</GetCitiesRequest>
	</Body>
</Envelope>

Accepted by server


 <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <GetCitiesRequest xmlns="http://www.n11.com/ws/schemas">
            <auth xmlns="">
                <appKey>[string]</appKey>
                <appSecret>[string]</appSecret>
            </auth>
        </GetCitiesRequest>
    </Body>
</Envelope>

im using quick fix:

buffers := new(bytes.Buffer)
buffers.WriteString(strings.ReplaceAll(buffer.String(),"<auth>","<auth xmlns=\"\">"))

req, err := http.NewRequest("POST", s.url, buffers)

what should i add struct tag to see empty xmlns="" ?

type GetCitiesRequest struct {
	XMLName xml.Name `xml:"http://www.n11.com/ws/schemas GetCitiesRequest"`

	Auth *Authentication `xml:"auth,omitempty" json:"auth,omitempty"`
}
type Authentication struct {
	AppKey string `xml:"appKey,omitempty" json:"appKey,omitempty"`

	AppSecret string `xml:"appSecret,omitempty" json:"appSecret,omitempty"`
}

Any help appreciated, sorry for if i did something wrong with opening new issue.

@ironytr
Copy link
Author

ironytr commented Apr 3, 2021

found answer on stackoverflow, add as attr.
https://stackoverflow.com/questions/66928251/how-to-add-empty-xmlns-to-struct-tag-for-request

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

1 participant