第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

如何將空的xmlns=“”添加到請求的結(jié)構(gòu)標(biāo)記中?

如何將空的xmlns=“”添加到請求的結(jié)構(gòu)標(biāo)記中?

Go
嗶嗶one 2022-08-24 10:45:26
你好,我是golang和編程的新手,我有一個(gè)新手問題。我無法在谷歌上找到答案。soap 服務(wù)器因 gowsdl 生成的代碼而失敗。但是我添加這個(gè)xmlns=“”來驗(yàn)證標(biāo)簽,它的工作原理就像一個(gè)魅力。那么我怎么能不通過字符串替換而是習(xí)慣性的方式將其添加到標(biāo)簽中呢?服務(wù)器不接受<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>服務(wù)器接受 <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使用快速修復(fù):buffers := new(bytes.Buffer)buffers.WriteString(strings.ReplaceAll(buffer.String(),"<auth>","<auth xmlns=\"\">"))req, err := http.NewRequest("POST", s.url, buffers)我應(yīng)該添加什么結(jié)構(gòu)標(biāo)簽來查看空的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"`}阿洛斯我試過了;type Authentication struct {   XMLName xml.Name `xml:""`   AppKey string `xml:"appKey,omitempty" json:"appKey,omitempty"`   AppSecret string `xml:"appSecret,omitempty" json:"appSecret,omitempty"`}   auth := Authentication{AppKey:"secret",AppSecret:"secret"}   auth.XMLName.Local= "auth"   auth.XMLName.Space = ""我也嘗試 auth.XMLName.Space = “ ” 空白空間,但xml.marshal將其轉(zhuǎn)換為轉(zhuǎn)義字符,如“&quote,#34”我想了解我如何做到像專業(yè)的方式,但不是菜鳥的方式。任何幫助贊賞。謝謝。
查看完整描述

1 回答

?
繁花不似錦

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超4個(gè)贊

https://golang.org/pkg/encoding/xml/#Marshal

  • 帶有標(biāo)記“name,attr”的字段將成為 XML 元素中具有給定名稱的屬性。

  • 帶有標(biāo)記 “,attr” 的字段將成為 XML 元素中具有字段名稱的屬性。

type Authentication struct {
    Xmlns     string `xml:"xmlns,attr" json:"-"`
    AppKey    string `xml:"appKey,omitempty" json:"appKey,omitempty"`
    AppSecret string `xml:"appSecret,omitempty" json:"appSecret,omitempty"`}

https://play.golang.org/p/iIvlUoaYvgB


查看完整回答
反對 回復(fù) 2022-08-24
  • 1 回答
  • 0 關(guān)注
  • 95 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號