With a set of types generated by gowsdl based on the NetSuite SuiteTalk web service definition:
<complexType name="TokenPassportSignature">
<simpleContent>
<extension base="xsd:string">
<attribute name="algorithm" type="xsd:string" use="required"/>
</extension>
</simpleContent>
</complexType>
<complexType name="TokenPassport">
<sequence>
<element name="account" type="xsd:string"/>
<element name="consumerKey" type="xsd:string"/>
<element name="token" type="xsd:string"/>
<element name="nonce" type="xsd:string"/>
<element name="timestamp" type="xsd:long"/>
<element name="signature" type="platformCore:TokenPassportSignature"/>
</sequence>
</complexType>
It has created the following types:
type TokenPassportSignature struct {
XMLName xml.Name `xml:"urn:core_2018_2.platform.webservices.netsuite.com TokenPassportSignature"`
Value string
Algorithm string `xml:"algorithm,attr,omitempty"`
}
type TokenPassport struct {
XMLName xml.Name `xml:"urn:core_2018_2.platform.webservices.netsuite.com TokenPassport"`
Account string `xml:"account,omitempty"`
ConsumerKey string `xml:"consumerKey,omitempty"`
Token string `xml:"token,omitempty"`
Nonce string `xml:"nonce,omitempty"`
Timestamp int64 `xml:"timestamp,omitempty"`
Signature *TokenPassportSignature `xml:"signature,omitempty"`
}
When I try to process it through the client, the XML encoding process doesn't like that the Signature field has a conflicting name.
xml: name "signature" in tag of main.TokenPassport.Signature conflicts with name "TokenPassportSignature" in *main.TokenPassportSignature.XMLName
I've extracted out the relevant bits into Go Playground to confirm that this is the encoder that is throwing the error. Based on the docs for Marhsal it seems that the field must match:
If the XML name for a struct field is defined by both the field tag and the struct's XMLName field, the names must match.
Any thoughts on how to proceed?
Alternatively, one might prefer to keep the name of the embedded structure TokenPassportSignature
instead of the name signature
. If the naming of the field, the line becomes:
Signature *TokenPassportSignature `xml:",omitempty"`