metaregistrar / php-epp-client

Object-oriented PHP EPP Client
https://www.metaregistrar.com/docs/
MIT License
210 stars 154 forks source link

Element '{urn:ietf:params:xml:ns:epp-1.0}epp': No matching global declaration available for the validation root. #244

Closed matbcvo closed 4 years ago

matbcvo commented 4 years ago

Server replies with error when trying to login to EIF EPP server.

ERROR: Error 2001: 2:0: ERROR: Element '{urn:ietf:params:xml:ns:epp-1.0}epp': No matching global declaration available for the validation root.
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
  <response>
    <result code="2001">
      <msg lang="en">2:0: ERROR: Element '{urn:ietf:params:xml:ns:epp-1.0}epp': No matching global declaration available for the validation root.</msg>
    </result>
    <trID>
      <clTRID>5e62090277693</clTRID>
      <svTRID>ccReg-2612805609</svTRID>
    </trID>
  </response>
</epp>

==== LOG ====
-----Connection made-----2020-03-06 09:25:38-----
Stream opened with protocol TLSv1.2, cipher ECDHE-RSA-AES128-GCM-SHA256, 128 bits TLSv1.2
-----END-----2020-03-06 09:25:38-----

-----WRITE-----2020-03-06 09:25:38-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  <command>
    <login>
      <clID>XXXXXXXXXXXXXXXX</clID>
      <pw>XXXXXXXXXXXXXXXX</pw>
      <options>
        <version>1.0</version>
        <lang>en</lang>
      </options>
      <svcs>
        <objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
        <objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
      </svcs>
    </login>
    <clTRID>5e62090277693</clTRID>
  </command>
</epp>

-----END-----2020-03-06 09:25:38-----

-----READ-----2020-03-06 09:25:38-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
  <response>
    <result code="2001">
      <msg lang="en">2:0: ERROR: Element '{urn:ietf:params:xml:ns:epp-1.0}epp': No matching global declaration available for the validation root.</msg>
    </result>
    <trID>
      <clTRID>5e62090277693</clTRID>
      <svTRID>ccReg-2612805609</svTRID>
    </trID>
  </response>
</epp>

-----END-----2020-03-06 09:25:38-----

-----DISCONNECT-----2020-03-06 09:25:38-----
Disconnected
-----END-----2020-03-06 09:25:38-----

So error is about this line: <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">

But there are EIF EPP documentation: https://github.com/internetee/registry/blob/master/doc/epp_examples.md And it contains one example for login:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
  <command>
    <login>
      <clID>registrar2</clID>
      <pw>ghyt9e4fu</pw>
      <options>
        <version>1.0</version>
        <lang>en</lang>
      </options>
      <svcs>
        <objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
        <objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
        <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
        <svcExtension>
          <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
          <extURI>https://epp.tld.ee/schema/eis-1.0.xsd</extURI>
        </svcExtension>
      </svcs>
    </login>
    <clTRID>ABC-12345</clTRID>
  </command>
</epp>

This example has this line: <epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">

How I can change xmlns to this? At the moment I couldn't find that method.

PHP file

<?php
require("autoloader.php");

use Metaregistrar\EPP\eppConnection;
use Metaregistrar\EPP\eppException;
use Metaregistrar\EPP\eppCheckDomainRequest;
use Metaregistrar\EPP\eppCheckDomainResponse;
use Metaregistrar\EPP\eppDomain;
use Metaregistrar\EPP\eppContact;
use Metaregistrar\EPP\eppHost;
use Metaregistrar\EPP\eppContactHandle;
use Metaregistrar\EPP\eppContactPostalInfo;
use Metaregistrar\EPP\eppCheckContactRequest;
use Metaregistrar\EPP\eppCheckHostRequest;
use Metaregistrar\EPP\eppCreateDomainRequest;
use Metaregistrar\EPP\eppCreateHostRequest;
use Metaregistrar\EPP\eppPollRequest;
use Metaregistrar\EPP\eppPollResponse;

$conn = new Metaregistrar\EPP\eppConnection(true);
$conn->setHostname('tls://testepp.internet.ee');
$conn->setPort(700);
$conn->setUsername('***');
$conn->setPassword('***');
$conn->enableCertification('***.pem', null);
$conn->setServices(array(
        'https://epp.tld.ee/schema/domain-eis-1.0.xsd' => 'domain',
        'https://epp.tld.ee/schema/contact-ee-1.1.xsd' => 'contact',
));

try {
        // Connect and login to the EPP server
        if ($conn->login()) {
                $domains = ['example.ee'];
                checkdomains($conn, $domains);
                $conn->logout();
        }
} catch (eppException $e) {
    echo "ERROR: " . $e->getMessage()."\n";
    echo $e->getLastCommand();
    echo "\n\n";
}

/**
 * @param $conn eppConnection
 * @param $domains array of domain names
 */
function checkdomains($conn, $domains) {
    // Create request to be sent to EPP service
    $check = new eppCheckDomainRequest($domains);
    // Write request to EPP service, read and check the results
    if ($response = $conn->request($check)) {
        /* @var $response eppCheckDomainResponse */
        // Walk through the results
        $checks = $response->getCheckedDomains();
        foreach ($checks as $check) {
            echo $check['domainname'] . " is " . ($check['available'] ? 'free' : 'taken');
            if ($check['available']) {
                echo ' (' . $check['reason'] .')';
            }
            echo "\n";
        }
    }
}
?>

EIF EPP schemas: https://epp.tld.ee/schema/

matbcvo commented 4 years ago

I looked up eppConnection.php file again and found addDefaultNamespace. So I added: $conn->addDefaultNamespace('https://epp.tld.ee/schema/epp-ee-1.0.xsd', 'xmlns'); But still getting error from EIF EPP server.

ERROR: Error 2001: 2:0: ERROR: Element '{xmlns:https://epp.tld.ee/schema/epp-ee-1.0.xsd}epp': No matching global declaration available for the validation root.
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
  <response>
    <result code="2001">
      <msg lang="en">2:0: ERROR: Element '{xmlns:https://epp.tld.ee/schema/epp-ee-1.0.xsd}epp': No matching global declaration available for the validation root.</msg>
    </result>
    <trID>
      <clTRID>5e62145d65c7d</clTRID>
      <svTRID>ccReg-9217581279</svTRID>
    </trID>
  </response>
</epp>

==== LOG ====
-----Connection made-----2020-03-06 10:14:05-----
Stream opened with protocol TLSv1.2, cipher ECDHE-RSA-AES128-GCM-SHA256, 128 bits TLSv1.2
-----END-----2020-03-06 10:14:05-----

-----WRITE-----2020-03-06 10:14:05-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="xmlns:https://epp.tld.ee/schema/epp-ee-1.0.xsd">
  <command>
    <login>
      <clID>XXXXXXXXXXXXXXXX</clID>
      <pw>XXXXXXXXXXXXXXXX</pw>
      <options>
        <version>1.0</version>
        <lang>en</lang>
      </options>
      <svcs>
        <objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
        <objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
      </svcs>
    </login>
    <clTRID>5e62145d65c7d</clTRID>
  </command>
</epp>

-----END-----2020-03-06 10:14:05-----

-----READ-----2020-03-06 10:14:05-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
  <response>
    <result code="2001">
      <msg lang="en">2:0: ERROR: Element '{xmlns:https://epp.tld.ee/schema/epp-ee-1.0.xsd}epp': No matching global declaration available for the validation root.</msg>
    </result>
    <trID>
      <clTRID>5e62145d65c7d</clTRID>
      <svTRID>ccReg-9217581279</svTRID>
    </trID>
  </response>
</epp>

-----END-----2020-03-06 10:14:05-----

-----DISCONNECT-----2020-03-06 10:14:05-----
Disconnected
-----END-----2020-03-06 10:14:05-----
metaregistrar commented 4 years ago

The adddefaultnamespace will always add 'xmlns:', which is not applicable in this case.

Maybe you can try: $this->defaultnamespace['xmlns'] = 'https://epp.tld.ee/schema/epp-ee-1.0.xsd';

and see what that does?

matbcvo commented 4 years ago

Thanks for reply. I added another function in eppConnection.php file

    public function addDefaultNamespace2($xmlns, $namespace) {
        $this->defaultnamespace[$namespace] = $xmlns;
    }

and I added $conn->addDefaultNamespace2('https://epp.tld.ee/schema/epp-ee-1.0.xsd', 'xmlns');

Then it was able to login to EIF EPP server without error. Domain check even works.

==== LOG ====
-----Connection made-----2020-03-06 10:40:11-----
Stream opened with protocol TLSv1.2, cipher ECDHE-RSA-AES128-GCM-SHA256, 128 bits TLSv1.2
-----END-----2020-03-06 10:40:11-----

-----WRITE-----2020-03-06 10:40:11-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
  <command>
    <login>
      <clID>XXXXXXXXXXXXXXXX</clID>
      <pw>XXXXXXXXXXXXXXXX</pw>
      <options>
        <version>1.0</version>
        <lang>en</lang>
      </options>
      <svcs>
        <objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
        <objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
      </svcs>
    </login>
    <clTRID>5e621a7bed16b</clTRID>
  </command>
</epp>

-----END-----2020-03-06 10:40:11-----

-----READ-----2020-03-06 10:40:12-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
  <response>
    <result code="1000">
      <msg>Command completed successfully</msg>
    </result>
    <trID>
      <clTRID>5e621a7bed16b</clTRID>
      <svTRID>ccReg-0085268740</svTRID>
    </trID>
  </response>
</epp>

-----END-----2020-03-06 10:40:12-----

-----LOGIN-----2020-03-06 10:40:12-----
Logged in
-----END-----2020-03-06 10:40:12-----

-----WRITE-----2020-03-06 10:40:12-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd" xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
  <command>
    <check>
      <domain:check>
        <domain:name>example.ee</domain:name>
      </domain:check>
    </check>
    <clTRID>5e621a7c1d149</clTRID>
  </command>
</epp>

-----END-----2020-03-06 10:40:12-----

-----READ-----2020-03-06 10:40:13-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
  <response>
    <result code="1000">
      <msg>Command completed successfully</msg>
    </result>
    <resData>
      <domain:chkData xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
        <domain:cd>
          <domain:name avail="1">example.ee</domain:name>
        </domain:cd>
      </domain:chkData>
    </resData>
    <trID>
      <clTRID>5e621a7c1d149</clTRID>
      <svTRID>ccReg-6044630888</svTRID>
    </trID>
  </response>
</epp>

-----END-----2020-03-06 10:40:13-----

-----WRITE-----2020-03-06 10:40:13-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd" xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
  <command>
    <logout></logout>
    <clTRID>5e621a7de8dab</clTRID>
  </command>
</epp>

-----END-----2020-03-06 10:40:13-----

-----READ-----2020-03-06 10:40:14-----
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
  <response>
    <result code="1500">
      <msg>Command completed successfully; ending session</msg>
    </result>
    <trID>
      <clTRID>5e621a7de8dab</clTRID>
      <svTRID>ccReg-9163635710</svTRID>
    </trID>
  </response>
</epp>

-----END-----2020-03-06 10:40:14-----

-----LOGOUT-----2020-03-06 10:40:14-----
Logged out
-----END-----2020-03-06 10:40:14-----

-----DISCONNECT-----2020-03-06 10:40:14-----
Disconnected
-----END-----2020-03-06 10:40:14-----

Would be nice if addDefaultNamespace function has another argument, so you can specify to add 'xmlns' or not. eg

    public function addDefaultNamespace($xmlns, $namespace, $arg = true) {
    if($arg == false) {
        $this->defaultnamespace[$namespace] = $xmlns;
    } else {
            // 'xmlns' will be added by default
            $this->defaultnamespace[$namespace] = 'xmlns:' . $xmlns;
    }
    }
metaregistrar commented 4 years ago

i will see to that - this is the first time that i encounter a registry that messes with the standard epp-1.0 namespace (normally they only add their namespaces to the 'extension' part of the epp message).

metaregistrar commented 4 years ago

Done