<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic XML namespace throwing 500 Error. in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/XML-namespace-throwing-500-Error/m-p/74513#M46322</link>
    <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I am using the&amp;nbsp;transactionCaller.php script in Laravel. It is giving me an error &lt;FONT color="#FF0000"&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;local.ERROR&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;: simplexml_load_string(): namespace warning : xmlns: URI AnetApi/xml/v1/schema/AnetApiSchema.xsd is not absolute"&lt;/FONT&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;I was getting the same error on the creation of the XML. If found an answer that to make the namespace absolute I had to add HTTP:// before it. That worked.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;$transRequestXmlStr=&amp;lt;&amp;lt;&amp;lt;XML
        &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
        &amp;lt;createTransactionRequest xmlns="http://AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;&lt;/PRE&gt;&lt;SPAN&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;However, when I receive the XML back it has the namespace without the HTTP:// so I get the error. It is not a warning in Laravel it is a 500 error.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 31 Dec 2020 19:00:14 GMT</pubDate>
    <dc:creator>1MSC2020</dc:creator>
    <dc:date>2020-12-31T19:00:14Z</dc:date>
    <item>
      <title>XML namespace throwing 500 Error.</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/XML-namespace-throwing-500-Error/m-p/74513#M46322</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I am using the&amp;nbsp;transactionCaller.php script in Laravel. It is giving me an error &lt;FONT color="#FF0000"&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;local.ERROR&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;: simplexml_load_string(): namespace warning : xmlns: URI AnetApi/xml/v1/schema/AnetApiSchema.xsd is not absolute"&lt;/FONT&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;I was getting the same error on the creation of the XML. If found an answer that to make the namespace absolute I had to add HTTP:// before it. That worked.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;$transRequestXmlStr=&amp;lt;&amp;lt;&amp;lt;XML
        &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
        &amp;lt;createTransactionRequest xmlns="http://AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;&lt;/PRE&gt;&lt;SPAN&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;However, when I receive the XML back it has the namespace without the HTTP:// so I get the error. It is not a warning in Laravel it is a 500 error.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 31 Dec 2020 19:00:14 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/XML-namespace-throwing-500-Error/m-p/74513#M46322</guid>
      <dc:creator>1MSC2020</dc:creator>
      <dc:date>2020-12-31T19:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: XML namespace throwing 500 Error.</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/XML-namespace-throwing-500-Error/m-p/74555#M46358</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Authorize.Net uses a relative namespace path which the SDK's XML library complains about.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution is don't include the xmlns attribute in your construction of the SimpleXML element object and use SimpleXMLElement::addAttribute after the fact to add it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of this:&lt;/P&gt;&lt;PRE&gt;$element = new SimpleXMLElement('&amp;lt;createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"/&amp;gt;');&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do this:&lt;/P&gt;&lt;PRE&gt;$element = new SimpleXMLElement('&amp;lt;createTransactionRequest/&amp;gt;');

$element-&amp;gt;addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');&lt;/PRE&gt;&lt;P&gt;To avoid these errors when parsing the response, simply strip the xmlns attribute out of the response before parsing it with SimpleXML using the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$result = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $result);&lt;/PRE&gt;&lt;P&gt;($result in this example is the raw XML as returned by Authorize.Net.)&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 11:01:24 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/XML-namespace-throwing-500-Error/m-p/74555#M46358</guid>
      <dc:creator>NexusSoftware</dc:creator>
      <dc:date>2021-01-04T11:01:24Z</dc:date>
    </item>
  </channel>
</rss>

