Question

i've been doing some PHP lately to connect with an EPP server. When i send the xml over to the EPP server through a variable for example

$nxml ='<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
<login>
<clID>XXXX</clID>
<pw>XXXX<pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
<svcs>
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
</svcs>
</login>
<clTRID>nick-12345</clTRID>
</command>
</epp>';

Server respondes fine with the proper XML. Although now that i'm trying to pass the xml through simplexml_loadfile like this

    $nxml = simplexml_load_file('login.xml');

I get a response from the server

<response>
  <result code="2001">
       <msg lang="en">Command syntax error</msg>
  </result>
  <extension>
       <extcommon:resdata xmlns:extcommon="urn:ics-forth:params:xml:ns:extcommon-1.0" xsi:schemalocation="urn:ics-forth:params:xml:ns:extcommon-1.0 extcommon-1.0.xsd">
  </extension>
  <trid>
       <svtrid>607c6b1f-2093-4eef-9756-8d9e9f0689cb-72387</svtrid>
</trid>
</response>

Any ideas?

Was it helpful?

Solution

According to RFC 5730,

2001 - Command syntax error

This response code MUST be returned when a server receives an improperly formed command element.

It means your XML isn't valid. If you take a closer took, you can see that your opening tag doesn't match the closing tag in the following line:

<pw>XXXXpw>
        ^

Change that to:

<pw>XXXX</pw>

and you should be fine.


UPDATE:

It seems this is occuring when you use simplexml_load_file which interprets the XML file as an object. It seems to me like the server needs raw XML as the input, and with simplexml_load_file you're sending an object.

To fix this issue, you can just file_get_contents to get the contents of your XML file, and then send it as you normally would.

Note that this may not be the best approach, but this could solve your issue.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top