Templates - jasonknight/gobay GitHub Wiki

WSDL is really difficult and often buggy. Instead of trying to implement something so abstract, I've stuck to the age-old advice for SOAP SDKs - use XML templates and futz till it works. In my experience this is the least brittle and the most editable.

With that in mind, I wanted the SDK to also be self-contained. So each XML template is actually composed of hard coded template partials that you can override by writing them out to the root application directory. The name of the template must be the name of the call.xml. So if you wanted to override the AddItemsTemplate() call you'll have to create an AddItemsTemplate.xml file. gobay will ship with an example program that will dump all the templates.

The templates are in text/template language. All of those rules apply here.

Requests are split up into parts, only call specific fields are in a template, the rest of the standard data is wrapped around it. You can also override the wrapping template with WrapTemplate.xml

WrapTemplate.xml

<?xml version="1.0" encoding="utf-8"?>
<%sRequest xmlns="urn:ebay:apis:eBLBaseComponents">
	<RequesterCredentials> 
		<eBayAuthToken>{{ .EbayAuthToken }}</eBayAuthToken> 
	</RequesterCredentials> 
	<MessageID>{{ .MessageID }}</MessageID>
	<Version>{{ .CompatLevel }}</Version>
	<WarningLevel>{{ .WarningLevel }}</WarningLevel>
%s
%s
%s
</%sRequest>

It may be necessary to revisit this template as it is not actually very flexible, because it is passed through fmt.Sprintf, which may need to change. Also, I may implement a kind of hook/plugin system where you can provide some text processing functions for each call...We'll see about that...

⚠️ **GitHub.com Fallback** ⚠️