I am using the transactionCaller.php script in Laravel. It is giving me an error "
$transRequestXmlStr=<<<XML <?xml version="1.0" encoding="UTF-8"?> <createTransactionRequest xmlns="http://AnetApi/xml/v1/schema/AnetApiSchema.xsd">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.
Solved! Go to Solution.
โ12-31-2020 11:00 AM
Hello,
Authorize.Net uses a relative namespace path which the SDK's XML library complains about.
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.
Instead of this:
$element = new SimpleXMLElement('<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"/>');
Do this:
$element = new SimpleXMLElement('<createTransactionRequest/>'); $element->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');
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:
$result = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $result);
($result in this example is the raw XML as returned by Authorize.Net.)
โ01-04-2021 02:59 AM - edited โ01-04-2021 03:01 AM
Hello,
Authorize.Net uses a relative namespace path which the SDK's XML library complains about.
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.
Instead of this:
$element = new SimpleXMLElement('<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"/>');
Do this:
$element = new SimpleXMLElement('<createTransactionRequest/>'); $element->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');
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:
$result = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $result);
($result in this example is the raw XML as returned by Authorize.Net.)
โ01-04-2021 02:59 AM - edited โ01-04-2021 03:01 AM
I had the same problem on my website https://hoekstra-slotenmaker.nl/ by means of this code it is solved for me in any case:
$ transRequestXmlStr = <<< XML
<? xml version = "1.0" encoding = "UTF-8"?>
<createTransactionRequest xmlns = "http: //AnetApi/xml/v1/enschema/AnetApiSchema.xsd">
I do use a provider that automatically adjusts the XML code for the wordpress websites
โ01-11-2021 04:08 AM
Same for me this code did solved for me :
$ transRequestXmlStr = <<< XML
<? xml version = "1.0" encoding = "UTF-8"?>
<createTransactionRequest xmlns = "http: //AnetApi/xml/v1/enschema/AnetApiSchema.xsd">
https://slotenmaker-bouwmans.be/
โ06-30-2021 01:44 PM