metaregistrar / php-epp-client

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

Unable to update extEmails on noridEppContact #238

Closed joveice closed 4 years ago

joveice commented 4 years ago

Error:

EPP parse error Parse error at line [2], column [1871]: Element '{http://www.norid.no/xsd/no-ext-contact-1.0}email': This element is not expected. Expected is one of ( {http://www.norid.no/xsd/no-ext-contact-1.0}identity, {http://www.norid.no/xsd/no-ext-contact-1.0}mobilePhone, {http://www.norid.no/xsd/no-ext-contact-1.0}disclose ).

I don't see what is wrong by looking at the code.

This is what I did

$update = new noridEppContact($postal_info,
            $email,
            $phone,
            null,
            null,
            null,
            $type,
            $contact_more['identity_type'] == 'organizationNumber' ? null : $identity_type,
            $identity_value,
            $mobile,
            $secondary_emails); //array of email strings

Is this something I do wrong or has norid changed something? @alexrsagen I can't remember having this issue before.

alexrsagen commented 4 years ago

Hi, this is caused by you specifying a noridEppContact with email addresses as the $updateInfo argument to a noridEppUpdateContactRequest.

This is supported by the Norid implementation in the library, but not correct as the Norid registry specifies that there can be multiple email addresses, which makes it an add/remove type rather than an update type.

https://github.com/metaregistrar/php-epp-client/blob/8786b3bf916b30736f08b7a944f21496e2dbcc91/Protocols/EPP/eppExtensions/no-ext-contact-1.0/eppRequests/noridEppUpdateContactRequest.php#L10

Please use the add/remove arguments for this purpose and read the Norid EPP Interface Specification for information about where to use add/rem and where to use chg. In this case, this is specified on page 34 in the form of an XML Schema Document. The XSDs are also published as a .tar.gz / .zip here.

joveice commented 4 years ago

Thank you!

joveice commented 4 years ago

Okey so I have now tried the addInfo and the removeInfo and I get this

 EPP parse error Parse error at line [2], column [1871]: Element '{urn:ietf:params:xml:ns:contact-1.0}add': This element is not expected. 

In this I pass a empty updateInfo, it gave the same result as when I gave it the $update too without the email this time so I guess that doesn't have anything to do with it since it doesn't work eather way.

to_add is a noridEppContact with just an array of emails on extEmails

new noridEppUpdateContactRequest($contact, $to_add ?? null, $to_remove ?? null, new noridEppContact());

Request

<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xmlns:host="urn:ietf:params:xml:ns:host-1.0" xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" xmlns:no-ext-epp="http://www.norid.no/xsd/no-ext-epp-1.0" xmlns:no-ext-result="http://www.norid.no/xsd/no-ext-result-1.0" xmlns:no-ext-domain="http://www.norid.no/xsd/no-ext-domain-1.1" xmlns:no-ext-contact="http://www.norid.no/xsd/no-ext-contact-1.0" xmlns:no-ext-host="http://www.norid.no/xsd/no-ext-host-1.0">
  <command>
    <update>
      <contact:update>
        <contact:id>NHS8O</contact:id>
        <contact:chg></contact:chg>
        <contact:add></contact:add>
      </contact:update>
    </update>
    <extension>
      <no-ext-contact:update>
        <no-ext-contact:add>
          <no-ext-contact:email>testbruker2@test.no</no-ext-contact:email>
        </no-ext-contact:add>
      </no-ext-contact:update>
    </extension>
    <clTRID>5e31612989064</clTRID>
  </command>
</epp>

Do I still do something wrong @alexrsagen ? it doesn't look like the request in the documentation you linked

alexrsagen commented 4 years ago

@joveice I've written a potential fix for this.

Norid does not seem to accept the empty <contact:chg> and <contact:add> produced by this library.

Could you try using our fork https://github.com/Konsept-IT/php-epp-client and checking if the issue is resolved?

FYI: For the $updateInfo argument of the noridEppUpdateContactRequest constructor, you do not need to (and should not) specify an "empty" new noridEppContact(), but rather simply null or not specify the argument at all.

joveice commented 4 years ago

@alexrsagen Seems to work. When I did not pass a $update norid said there was a missing status field

I can't see from the documentation that it does not support add and remove at the same time, do you know if this is the case?

EPP parse error Parse error at line [2], column [1871]: Element '{http://www.norid.no/xsd/no-ext-contact-1.0}add': This element is not expected. 
<extension>
      <no-ext-contact:update>
        <no-ext-contact:rem>
          <no-ext-contact:email>testbruker2@test.no</no-ext-contact:email>
        </no-ext-contact:rem>
        <no-ext-contact:add>
          <no-ext-contact:email>testbruker5@test.no</no-ext-contact:email>
        </no-ext-contact:add>
      </no-ext-contact:update>
    </extension>
alexrsagen commented 4 years ago

@joveice Simultaneous add and remove is supported and should work, but they are most likely expecting elements in the natural order (first add, then remove).

Can you test the new commit i just pushed to our fork which changes this? Hopefully works as expected, if it does I will create a new PR for that.

joveice commented 4 years ago

@alexrsagen Will test tomorrow!

joveice commented 4 years ago

@alexrsagen Yep, it depends on the order, with your fork it works like expected.

alexrsagen commented 4 years ago

Submitted a PR. @joveice @metaregistrar