Reputation: 1
I am trying to post XML request to ingram micro url the code shown below
<?php
$url = "https://newport.ingrammicro.com/mustang";
$post_string = '<BaseRateRequest>
<Version1.0></Version1.0>
<TransactionHeader>
<CountryCode>FT</CountryCode>
<LoginID>username</LoginID>
<Password>password</Password>
<TransactionID>TESTAIC12356</TransactionID>
</TransactionHeader>
<BaseRateInformation>
<BranchOrderNumber>4066000</BranchOrderNumber>
<PostalCode>L5R1V4</PostalCode>
<Suffix />
</BaseRateInformation>
</BaseRateRequest>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "XML=".$post_string);
$data = curl_exec($ch);
print_r($data);
?>
But, I don't know how to request and response in XML. I am getting the error: Invalid Inbound XML Document
.
What does that means and how to solve it ?
Upvotes: 0
Views: 971
Reputation: 11
you have to remove "XML="
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
and probably also add the XML header:
<?xml version="1.0" encoding="UTF-8"?>
<BaseRateRequest>
...
</BaseRateRequest>
Upvotes: 1