Giter Club home page Giter Club logo

Comments (8)

geoffgarside avatar geoffgarside commented on September 16, 2024

This is probably whats causing the problems. In this format xml.to_s gives me this

<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
  <command>
    <dnsbe:create>
      <dnsbe:contact>
        <dnsbe:type>licensee</dnsbe:type>
        <dnsbe:vat>BE 123 4567 8900</dnsbe:vat>
        <dnsbe:lang>nl</dnsbe:lang>
      </dnsbe:contact>
    </dnsbe:create>
    <dnsbe:ext xmlns:dnsbe="http://www.dns.be/xml/epp/dnsbe-1.0"/>
    <clTRID>ABC-123</clTRID>
  </command>
</epp>

If I change the EPP::Commands::Create variable name to cmd and change the EPP::Requests::Command.new to use the cmd variable instead then my xml.to_s gives me

<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
  <command>
    <create>
      <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
        <contact:id>UK-4398495</contact:id>
        <contact:postalInfo type="loc">
          <contact:name>Enoch Root</contact:name>
          <contact:org>Epiphyte</contact:org>
          <contact:addr>
            <contact:street>1 Test Avenue</contact:street>
            <contact:city>Testington</contact:city>
            <contact:sp>Testshire</contact:sp>
            <contact:pc>TE57 1NG</contact:pc>
            <contact:cc>GB</contact:cc>
          </contact:addr>
        </contact:postalInfo>
        <contact:voice>+44.1234567890</contact:voice>
        <contact:email>[email protected]</contact:email>
        <contact:authInfo>
          <contact:pw>2381728348</contact:pw>
        </contact:authInfo>
        <contact:disclose flag="0">
          <contact:voice/>
          <contact:email/>
        </contact:disclose>
      </contact:create>
    </create>
    <dnsbe:ext xmlns:dnsbe="http://www.dns.be/xml/epp/dnsbe-1.0">
      <dnsbe:create>
        <dnsbe:contact>
          <dnsbe:type>licensee</dnsbe:type>
          <dnsbe:vat>BE 123 4567 8900</dnsbe:vat>
          <dnsbe:lang>nl</dnsbe:lang>
        </dnsbe:contact>
      </dnsbe:create>
    </dnsbe:ext>
    <clTRID>ABC-123</clTRID>
  </command>
</epp>

If this more what you were expecting to get?

Most of this gem is built to facilitate the m247/nominet-epp gem. The Nominet contact:create command uses extensions which might help you though.

from epp-client.

geoffgarside avatar geoffgarside commented on September 16, 2024

Damn I nuked half my words at the top of that comment. I started off by saying that it looks like you've got to create variables. One is an instance of EPP::Commands::Create the other XML::Node and that this was probably what was causing your problems.

from epp-client.

geoffgarside avatar geoffgarside commented on September 16, 2024

Oops, I forgot to put the extension into an EPP::Requests::Extension object. Heres the code thats working for me

client = EPP::Client.new('username', 'password', 'epp.registry.tryout.dns.be', {
  :port => 33128,
  :extensions => [
    "http://www.dns.be/xml/epp/dnsbe-1.0",
    "http://www.dns.be/xml/epp/nsgroup-1.0",
    "http://www.dns.be/xml/epp/keygroup-1.0",
    "urn:ietf:params:xml:ns:secDNS-1.1",
  ]})

# From your tests, which I'm using as examples now
contact_create = EPP::Contact::Create.new('UK-4398495',
    :voice       => "+44.1234567890",
    :email       => "[email protected]",
    :postal_info => {
      :org       => "Epiphyte",
      :name      => "Enoch Root",
      :addr      => {
        :street  => "1 Test Avenue",
        :city    => "Testington",
        :sp      => "Testshire",
        :pc      => "TE57 1NG",
        :cc      => "GB" } },
    :auth_info   => {:pw => '2381728348'},
    :disclose    => {"0" => %w(voice email)})

cmd  = EPP::Commands::Create.new(contact_create)

extension = XML::Node.new("ext")
dnsbe = XML::Namespace.new(extension, 'dnsbe', 'http://www.dns.be/xml/epp/dnsbe-1.0')
create = XML::Node.new("create", nil, dnsbe)

extension.namespaces.namespace = dnsbe

contact = XML::Node.new("contact", nil, dnsbe)
contact << XML::Node.new("type", "licensee", dnsbe)
contact << XML::Node.new("vat", "BE 123 4567 8900", dnsbe)
contact << XML::Node.new("lang", "nl", dnsbe)

create << contact
extension << create

ext     = EPP::Requests::Extension.new(extension)
command = EPP::Requests::Command.new('ABC-123', cmd, ext)
request = EPP::Request.new(command)
xml     = request.to_xml

client.create request

and the xml.to_s output

<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
  <command>
    <create>
      <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
        <contact:id>UK-4398495</contact:id>
        <contact:postalInfo type="loc">
          <contact:name>Enoch Root</contact:name>
          <contact:org>Epiphyte</contact:org>
          <contact:addr>
            <contact:street>1 Test Avenue</contact:street>
            <contact:city>Testington</contact:city>
            <contact:sp>Testshire</contact:sp>
            <contact:pc>TE57 1NG</contact:pc>
            <contact:cc>GB</contact:cc>
          </contact:addr>
        </contact:postalInfo>
        <contact:voice>+44.1234567890</contact:voice>
        <contact:email>[email protected]</contact:email>
        <contact:authInfo>
          <contact:pw>2381728348</contact:pw>
        </contact:authInfo>
        <contact:disclose flag="0">
          <contact:voice/>
          <contact:email/>
        </contact:disclose>
      </contact:create>
    </create>
    <extension>
      <dnsbe:ext xmlns:dnsbe="http://www.dns.be/xml/epp/dnsbe-1.0">
        <dnsbe:create>
          <dnsbe:contact>
            <dnsbe:type>licensee</dnsbe:type>
            <dnsbe:vat>BE 123 4567 8900</dnsbe:vat>
            <dnsbe:lang>nl</dnsbe:lang>
          </dnsbe:contact>
        </dnsbe:create>
      </dnsbe:ext>
    </extension>
    <clTRID>ABC-123</clTRID>
  </command>
</epp>

Hope that helps.

from epp-client.

dv avatar dv commented on September 16, 2024

Thanks for the quick response!

The double-used create var was because I copy-pasted some code that I had in different methods, sorry about that :)

So the missing link was the Extension object! Ah, so obvious now! Thanks for your help Geoff, that does look like what I'm looking for. Also thanks for the link to the nominet-epp lib example, just what I needed.

🎆

from epp-client.

geoffgarside avatar geoffgarside commented on September 16, 2024

Glad thats sorted it. Best of luck with EPP, its an interesting beast. Depending on how strict the EPP server you're talking to is, I'd recommend making sure you create your EPP payloads in the exact same order as the XML schema documents define, that's bitten me too many time in the past.

from epp-client.

dv avatar dv commented on September 16, 2024

Welp, I cried victory too soon!

First of it's a real problem that you can't call to_xml on any object twice, since it throws "Nodes belong to different documents" errors after the first time. It makes debugging really hard :) I don't understand how client.last_response or client.last_request even exists because this bug makes me unable to call .to_xml on them to inspect them.

Second, I'm getting the error from the server that:

<dnsbe:msg>line:2 column:172: Element 'create@urn:ietf:params:xml:ns:epp-1.0' with element-only content type cannot have text content.</dnsbe:msg>
<dnsbe:msg>line:2 column:172: Expected element(s) in element create@urn:ietf:params:xml:ns:epp-1.0</dnsbe:msg>

I'm guessing this is because the namespaces xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd" need to be an attribute in the root node while now they're included in the contact:create node. Here's what according to their docs they're expecting:

<epp xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd http://www.dns.be/xml/epp/dnsbe-1.0 dnsbe-1.0.xsd" xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xmlns:dnsbe="http://www.dns.be/xml/epp/dnsbe-1.0">
  <command>
    <create>
<contact:create> <contact:id>you_choose_it</contact:id> <contact:postalInfo type="loc">
<contact:name>Smith Jonathan</contact:name> <contact:org>Great Company Inc.</contact:org> <contact:addr>
<contact:street>Greenstreet 23</contact:street> <contact:city>Brussels</contact:city> <contact:sp/>
<contact:pc>1000</contact:pc> <contact:cc>BE</contact:cc>
</contact:addr>
</contact:postalInfo> <contact:voice>+32.16284970</contact:voice> <contact:fax>+32.16284971</contact:fax> <contact:email>[email protected]</contact:email> <contact:authInfo>
          <contact:pw>Polar Ice</contact:pw>
        </contact:authInfo>
      </contact:create>
    </create>
    <extension>
      <dnsbe:ext>
        <dnsbe:create>
<dnsbe:contact> <dnsbe:type>licensee</dnsbe:type> <dnsbe:vat>BE 123 4576 5645</dnsbe:vat> <dnsbe:lang>nl</dnsbe:lang>
          </dnsbe:contact>
        </dnsbe:create>
</dnsbe:ext>
</extension> <clTRID>clientref-00002</clTRID>
  </command>
</epp>

Any insight at all would be appreciated :)

from epp-client.

geoffgarside avatar geoffgarside commented on September 16, 2024

The location of the xmlns attribute shouldn't be too critical so long as its at least on the first element which uses that namespace.

How are you constructing your EPP payload? I've not experienced any nodes belongs to different documents issues with any of the stuff I've been writing.

from epp-client.

geoffgarside avatar geoffgarside commented on September 16, 2024

This seems to be working to generate the XML they're expecting

require 'epp-client'

client = EPP::Client.new('username', 'password', 'epp.registry.tryout.dns.be', {
  :port => 33128,
  :extensions => [
    "http://www.dns.be/xml/epp/dnsbe-1.0",
    "http://www.dns.be/xml/epp/nsgroup-1.0",
    "http://www.dns.be/xml/epp/keygroup-1.0",
    "urn:ietf:params:xml:ns:secDNS-1.1",
  ]})

# From your tests, which I'm using as examples now
contact_create = EPP::Contact::Create.new('you_choose_it',
    :voice       => "+32.16284970",
    :fax         => "+32.16284971",
    :email       => "[email protected]",
    :postal_info => {
      :org       => "Great Company Inc.",
      :name      => "Smith Jonathan",
      :addr      => {
        :street  => "Greenstreet 23",
        :city    => "Brussels",
        :pc      => "1000",
        :cc      => "BE" } },
    :auth_info   => {:pw => 'Polar Ice'})

extension = XML::Node.new("ext")
dnsbe = XML::Namespace.new(extension, 'dnsbe', 'http://www.dns.be/xml/epp/dnsbe-1.0')
create = XML::Node.new("create", nil, dnsbe)

extension.namespaces.namespace = dnsbe

contact = XML::Node.new("contact", nil, dnsbe)
contact << XML::Node.new("type", "licensee", dnsbe)
contact << XML::Node.new("vat", "BE 123 4576 5645", dnsbe)
contact << XML::Node.new("lang", "nl", dnsbe)

create << contact
extension << create

cmd     = EPP::Commands::Create.new(contact_create)
ext     = EPP::Requests::Extension.new(extension)
command = EPP::Requests::Command.new('clientref-00002', cmd, ext)
request = EPP::Request.new(command)
xml     = request.to_xml

puts xml.to_s(:indent => 2)
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
  <command>
    <create>
      <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
        <contact:id>you_choose_it</contact:id>
        <contact:postalInfo type="loc">
          <contact:name>Smith Jonathan</contact:name>
          <contact:org>Great Company Inc.</contact:org>
          <contact:addr>
            <contact:street>Greenstreet 23</contact:street>
            <contact:city>Brussels</contact:city>
            <contact:pc>1000</contact:pc>
            <contact:cc>BE</contact:cc>
          </contact:addr>
        </contact:postalInfo>
        <contact:voice>+32.16284970</contact:voice>
        <contact:fax>+32.16284971</contact:fax>
        <contact:email>[email protected]</contact:email>
        <contact:authInfo>
          <contact:pw>Polar Ice</contact:pw>
        </contact:authInfo>
      </contact:create>
    </create>
    <extension>
      <dnsbe:ext xmlns:dnsbe="http://www.dns.be/xml/epp/dnsbe-1.0">
        <dnsbe:create>
          <dnsbe:contact>
            <dnsbe:type>licensee</dnsbe:type>
            <dnsbe:vat>BE 123 4576 5645</dnsbe:vat>
            <dnsbe:lang>nl</dnsbe:lang>
          </dnsbe:contact>
        </dnsbe:create>
      </dnsbe:ext>
    </extension>
    <clTRID>clientref-00002</clTRID>
  </command>
</epp>

The xmlns are only defined on the first element which needs that namespace, this should be fine per XML, and the contact:sp element is not included, but its optional per the XMLSchema for contact-1.0 so again that should be fine.

from epp-client.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.