我从golang调用soap api,soap api上的响应包含标头部分和正文。如何在golang中处理标头响应
这是soap api响应
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<SessionId xmlns="http://schemas.com/2/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<TransactionId xmlns="http://schemas.com/2/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</S:Header>
<S:Body>
<GetResponse xmlns="http://schemas.ericsson.com/cai3g1.2/">
<MOAttributes>
<ilf:getResponseSubscription xmlns:ilf="http://schemas.com/ema/ILF/" publicIdentity="tel:+1234567890">
<ilf:publicIdEntry publicIdentity="tel:+1234567890">
</ilf:publicIdEntry>
</ilf:getResponseSubscription>
</MOAttributes>
</GetResponse>
</S:Body>
</S:Envelope>
这是我的肥皂客户端结构
type SOAPEnvelopeOutput struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Header SoapHeaderOutput
Body SOAPBodyOutput }
type SOAPBodyOutput struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
Content []byte `xml:",innerxml"` }
type SoapHeaderOutput struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header"`
Items []byte `xml:",innerxml"` }
这是我编写的解析代码:
type GetResponse struct {
XMLName xml.Name `xml:"http://schemas.ericsson.com/cai3g1.2/ GetResponse"`
GetMOAttributes MOAttributes `xml:"MOAttributes"`
}
type MOAttributes struct {
XMLName xml.Name `xml:"http://schemas.ericsson.com/cai3g1.2/ MOAttributes"`
GetResponseSubscription getResponseSubscription `xml:"ilf:getResponseSubscription"`
}
type getResponseSubscription struct {
XMLName xml.Name `xml:"http://schemas.ericsson.com/cai3g1.2/ ilf:getResponseSubscription"`
GetPublicIdEntry getPublicIdEntry `xml:"ilf:publicIdEntry"`
}
type getPublicIdEntry struct {
XMLName xml.Name `xml:"http://schemas.ericsson.com/cai3g1.2/ ilf:publicIdEntry"`
}