Skip to content

al0fayz/epp-pandi-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EPP Client

To generate XML to be used for a client, use the specified type for this.

domainInfo := types.DomainInfoType{
    Info: types.DomainInfo{
        Name: types.DomainInfoName{
            Name:  "example.se",
            Hosts: types.DomainHostsAll,
        },
    },
}

bytes, err := Encode(
    domainInfo,
    ClientXMLAttributes(),
)

if err != nil {
    panic(err)
}

The above code will generate the following XML.

<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  <command>
    <info>
      <domain:info xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xmlns="urn:ietf:params:xml:ns:domain-1.0">
        <domain:name hosts="all">example.se</domain:name>
      </domain:info>
    </info>
  </command>
</epp>

To unmarshal already created XML no matter the namespace or alias, use the auto genrated types. The XML listed above could be unmarshaled like this.

request := DomainInfoTypeIn{}

if err := xml.Unmarshal(inData, &request); err != nil {
    panic(err)
}

fmt.Println(request.Info.Name.Name) // Prints `example.se`

References

XSD files

All XSD schemas can be found att IANA web page. XSD files from this repository linked below.

EPP RFC