1

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?

LefterisL
  • 1,132
  • 3
  • 17
  • 37

1 Answers1

0

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!

Community
  • 1
  • 1
Amal Murali
  • 75,622
  • 18
  • 128
  • 150
  • Sorry but missed the < when i was typing XXX to hide the password. – LefterisL Aug 29 '13 at 12:21
  • The problem appears when i try to send it though simpleXML_load NOT when i pass the XML to a variable through the code. – LefterisL Aug 29 '13 at 12:22
  • @TerisL: ah, I see. How are you sending the variable to the server? Also, do you use `simplexml_load_string()` on the variable to interpret it as an object or do you simply send it as raw XML? If you're doing the latter, then that's probably why your code isn't working. – Amal Murali Aug 29 '13 at 12:30
  • After the '$nxml = simplexml_load_file('hello.xml');' I simply send it to the sever with curl_setopt($ch, CURLOPT_POSTFIELDS, $nxml); Ill try they way you suggested and i'll let you know – LefterisL Aug 29 '13 at 12:48
  • When i send the variable i do is as simple XML, no load_string() used. And the server responds fine. Although when i send it as an object (load_file) returns an object right? I get this error. – LefterisL Aug 29 '13 at 13:09