gowsdl
gowsdl copied to clipboard
Extension types defined as pointers
If the app encounters an extension type such as the following from the NetSuite SuiteTalk WSDL:
<complexType name="BaseRef" abstract="true">
<sequence>
<element name="name" type="xsd:string" minOccurs="0"/>
</sequence>
</complexType>
<complexType name="RecordRef">
<complexContent>
<extension base="platformCore:BaseRef">
<attribute name="internalId" type="xsd:string"/>
<attribute name="externalId" type="xsd:string"/>
<attribute name="type" type="platformCoreTyp:RecordType"/>
</extension>
</complexContent>
</complexType>
<complexType name="GetRequest">
<sequence>
<element name="baseRef" type="platformCore:BaseRef"/>
</sequence>
</complexType>
It defines it as:
type BaseRef struct {
XMLName xml.Name `xml:"urn:core_2018_2.platform.webservices.netsuite.com BaseRef"`
Name string `xml:"name,omitempty"`
}
type RecordRef struct {
XMLName xml.Name `xml:"urn:core_2018_2.platform.webservices.netsuite.com RecordRef"`
*BaseRef
InternalId string `xml:"internalId,attr,omitempty"`
ExternalId string `xml:"externalId,attr,omitempty"`
Type *RecordType `xml:"type,attr,omitempty"`
}
type GetRequest struct {
XMLName xml.Name `xml:"urn:messages_2018_2.platform.webservices.netsuite.com GetRequest"`
BaseRef *BaseRef `xml:"baseRef,omitempty"`
}
In my code I can't seem to pass RecordRef which is the correct structure that the web service is expecting. At best I can pass a pointer to BaseRef which seems to result in the encoder ignoring RecordRef's contents:
var recordTypePartner RecordType
recordTypePartner = RecordTypePartner
var recordRef RecordRef
recordRef = RecordRef{Type:&recordTypePartner,InternalId:internalIdString}
var getRequest GetRequest
getRequest.BaseRef = recordRef.BaseRef
Given Go doesn't have a concept of inheritance in the same way languages like C# and Java do, how do we handle these sorts of override / extension scenarios?