gowsdl
gowsdl copied to clipboard
Namespace problem
During testing, I found the following error:
- use the following WSDL
- generate the go-code
Results in the following generated Request (getVServers)
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getVServers xmlns="http://enduser.service.web.vcp.netcup.de/">
<loginName>XXXXXX</loginName>
<password>XXXXXX</password>
</getVServers>
</soap:Body>
</soap:Envelope>
But it should be generated into something like this to work:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:end="http://enduser.service.web.vcp.netcup.de/">
<soapenv:Header/>
<soapenv:Body>
<end:getVServers>
<loginName>XXXX</loginName>
<password>XXXX</password>
</end:getVServers>
</soapenv:Body>
</soapenv:Envelope>
Can I configure the SOAP Client to use the right namespaces (soapenv and end)?
+1
+1
Hi guys, I'm facing that kind of issue too. You need to adapt the SOAP structs to your needs in soap.go, which means forking this repo with your modifications, not an ideal situation.
For example, your SOAPEnvelope struct should be something like that, notice the soapenv in the xml struct tag :
type SOAPEnvelope struct {
XMLName xml.Name `xml:"soapenv:Envelope"`
XmlNS string `xml:"xmlns:soapenv,attr"`
XmlCustomNS string `xml:"xmlns:end,attr"`
Header *SOAPHeader
Body SOAPBody
}
type SOAPHeader struct {
XMLName xml.Name `xml:"soapenv:Header"`
Headers []interface{}
}
type SOAPBody struct {
XMLName xml.Name `xml:"soapenv:Body"`
...
}
You will need to set your XmlCustomNS in the SOAPEnv instance : https://github.com/hooklift/gowsdl/blob/0f6b60ef6cd35ea2b7950f156660f72feb5caaa6/soap/soap.go#L418
envelope := SOAPEnvelope {
XmlNS: XmlNsSoapEnv,
XmlCustomNS: "http://enduser.service.web.vcp.netcup.de/",
}
I'm kinda thinking it could be a good use of the new golang generics : define your types and pass them at runtime to the soap Client... keep an eye on my fork, if I get around to implement that.
For <end:getVServers>
unfortunately, this "end" prefix depends on the templates used to generate the go code and I'm still wondering how to change that.
If you look at : https://github.com/hooklift/gowsdl/blob/0f6b60ef6cd35ea2b7950f156660f72feb5caaa6/types_tmpl.go#L206
That's where the "xmlns="url..."
comes from, but we want a prefix to the xml tag name instead.