我有一个肥皂请求,我需要做一个xml来提出请求。所以我做了什么来制作xml如下:
type Command struct {
XMLName xml.Name
}
type XMLEnvelop struct {
XMLName xml.Name `xml:"soapenv:Envelope"`
Xmlns string `xml:"xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/,"`
CalculatePrice Command `xml:"soapenv:Body>FunctionName"`
}
v := &XMLEnvelop{Xmlns: "namespace1", CalculatePrice: Command{xml.Name{"namespace2", "CalculatePrice"}}}
output, err := xml.MarshalIndent(v, "", " ")
if err != nil {
fmt.Printf("error: %v\n", err)
}
// Write the output to check
os.Stdout.Write(output)
这将给我这个输出:
<soapenv:Envelope>
<xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/>namespace1</xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/>
<soapenv:Body>
<CalculatePrice xmlns="namespace2"></CalculatePrice>
</soapenv:Body>
</soapenv:Envelope>
现在我想在网络上找不到它的一些字段,所以作为例子,xml会是这样的:calculateprice
<CalculatePrice xmlns="namespace2">
<test>somevalue</test>
<someothertest>somevalue</someothertest>
</CalculatePrice>
Helenr
相关分类