title: XML request using post method
body: <p>I need to create payment module for opencart. The problem how to build xml output in php to post it to remote leasing server url: <code>https://ecredit.leasing.com/eshop_test/UBLOnline.aspx?eshopdata=?</code></p>
  
  <p>using post method.
  I trying to build this xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ContractRequest xmlns="http://e-credit.ubl.lt/eshop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://e-credit.ubl.lt/eshop http://e-credit.leasing.com/eshop/contractrequest.xsd"&gt;
      &lt;SaleLogin&gt;test&lt;/SaleLogin&gt;
      &lt;SaleConditionID&gt;111&lt;/SaleConditionID&gt;
      &lt;Person&gt;
          &lt;FirstName&gt;John&lt;/FirstName&gt;
          &lt;LastName&gt;Jones&lt;/LastName&gt;
      &lt;/Person&gt;
      &lt;Communication&gt;
          &lt;StreetOrVillage&gt;First&lt;/StreetOrVillage&gt;
          &lt;City&gt;New York&lt;/City&gt;
          &lt;PostCode&gt;21212&lt;/PostCode&gt;
          &lt;Phone&gt;+100000000&lt;/Phone&gt;
          &lt;Email&gt;john@mymail.com&lt;/Email&gt;
      &lt;/Communication&gt;
      &lt;ContractDetails&gt;
          &lt;CreditAmount&gt;617.60&lt;/CreditAmount&gt;
          &lt;CreditCurrency&gt;USD&lt;/CreditCurrency&gt;
      &lt;/ContractDetails&gt;
      &lt;OrderedItemsDetail&gt;
          &lt;Item&gt;
              &lt;Name&gt;1 x HP 250 G5 UMA Celeron N3060 15.6 HD SVA, 1 x HP 15-r101na 15.6 HD Brightview flat (B), &lt;/Name&gt;
              &lt;Amount&gt;2pcs.&lt;/Amount&gt;
              &lt;Price&gt;617.60&lt;/Price&gt;
              &lt;Currency&gt;USD&lt;/Currency&gt;
          &lt;/Item&gt;
      &lt;/OrderedItemsDetail&gt;
  
  &lt;/ContractRequest&gt;
  </code></pre>
  
  <p>I have tried create xml like this:</p>
  
  <pre><code>$XmlString =  '&lt;?xml version="1.0" encoding="UTF-8" ?&gt;'; 
                    $XmlString .= '&lt;ContractRequest 
      xmlns="http://e-credit.ubl.lt/eshop"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://e-credit.ubl.com/eshop http://e-credit.leasing.com/eshop/contractrequest.xsd"&gt;'; 
  
  
      $XmlString .= '&lt;SaleLogin&gt;' . $data['SaleLogin'] . '&lt;/SaleLogin&gt;';
      $XmlString .= '&lt;SaleConditionID&gt;' . $data['SaleConditionID'] . '&lt;/SaleConditionID&gt;'; 
  
      $XmlString .= '&lt;Person&gt;';  
          $XmlString .= '&lt;FirstName&gt;' . $data['first_name'] . '&lt;/FirstName&gt;'; 
          $XmlString .= '&lt;LastName&gt;' . $data['last_name'] . '&lt;/LastName&gt;'; 
  
      $XmlString .= '&lt;/Person&gt;'; 
  
      $XmlString .= '&lt;Communication&gt;';
          $XmlString .= '&lt;StreetOrVillage&gt;' . $data['street'] . '&lt;/StreetOrVillage&gt;'; 
          $XmlString .= '&lt;City&gt;' . $data['city'] . '&lt;/City&gt;'; 
          $XmlString .= '&lt;PostCode&gt;' . $data['postcode'] . '&lt;/PostCode&gt;'; 
          $XmlString .= '&lt;Phone&gt;' . $data['telephone'] . '&lt;/Phone&gt;'; 
          $XmlString .= '&lt;Email&gt;' . $data['email'] . '&lt;/Email&gt;'; 
      $XmlString .= '&lt;/Communication&gt;'; 
  
      $XmlString .= '&lt;ContractDetails&gt;';
  
          $XmlString .= '&lt;CreditAmount&gt;' . $data['amount'] . '&lt;/CreditAmount&gt;'; 
          $XmlString .= '&lt;CreditCurrency&gt;' . $data['currency'] . '&lt;/CreditCurrency&gt;'; 
      $XmlString .= '&lt;/ContractDetails&gt;'; 
  
      $XmlString .= '&lt;OrderedItemsDetail&gt;';
          $XmlString .= '&lt;Item&gt;';
              $XmlString .= '&lt;Name&gt;' . $data['description'] . '&lt;/Name&gt;'; 
              $XmlString .= '&lt;Amount&gt;' . $data['products_amount'] . '&lt;/Amount&gt;'; 
              $XmlString .= '&lt;Price&gt;' . $data['amount'] . '&lt;/Price&gt;'; 
              $XmlString .= '&lt;Currency&gt;' .$data['currency'] . '&lt;/Currency&gt;'; 
          $XmlString .= '&lt;/Item&gt;'; 
      $XmlString .= '&lt;/OrderedItemsDetail&gt;'; 
  
  
  $XmlString .= '&lt;/ContractRequest&gt;'; 
  </code></pre>
  
  <p>and after :</p>
  
  <pre><code>$url = https://ecredit.leasing.com/eshop_test/UBLOnline.aspx?eshopdata=?;
  $header = array();
  
                          $header[] = 'Content-Type: text/xml';
                          $header[] = 'Content-Length: ' . strlen($XmlString);
  
                          $ch = curl_init();
  
                          curl_setopt($ch, CURLOPT_URL, &amp;url);
                          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                          //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
                          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
                          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                          curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
                          curl_setopt($ch, CURLOPT_POSTFIELDS, $XmlString);
                          ///////////////////////
                          $response = curl_exec($ch);
  
                  curl_close($ch);
  
      $XmlString = simplexml_load_string($response);
  
              //create object to use as json
              $json = array();
  
  
  
                  $json['redirect'] = $this-&gt;url-&gt;link('checkout/success', '', true);
  
  
              $this-&gt;response-&gt;addHeader('Content-Type: application/json');
              $this-&gt;response-&gt;setOutput(json_encode($json));
  </code></pre>
  
  <p>but this does not work... sad.... what i miss?</p>
  
  <p>how to create properly xml request and  post it to url? </p>