initial commit
[namibia] / public / test.php
1 <?php 
2         
3         
4 //echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';  
5         
6          //Data, connection, auth
7         //$dataFromTheForm = $_POST['fieldName']; // request data from the form
8         $soapUrl = "http://secureuat.decisionsystems.co.za/AISConvergedB2BService/AISConvergedB2BService.svc?singleWsdl"; // asmx URL of WSDL
9        // $soapUser = "username";  //  username
10        // $soapPassword = "password"; // password
11
12         // xml post structure
13
14         $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
15                             <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:tran="http://schemas.datacontract.org/2004/07/Transunion.Auto.Convergence.B2B.BusinessModels">
16                                       <tem:GetConvergedData>
17                                                                  <!--Optional:-->
18                                                                  <tem:value>
19                                                             <!--Optional:-->
20                                                             <tran:ClientReference>Test002</tran:ClientReference>
21                                                             <!--Optional:-->
22                                                             <tran:Colour>KINETIC BLUE</tran:Colour>
23                                                             <!--Optional:-->
24                                                             <tran:Condition>FAIR</tran:Condition>
25                                                             <!--Optional:-->
26                                                             <tran:CustomerProductId>0</tran:CustomerProductId>
27                                                             <!--Optional:-->
28                                                             <tran:EngineNumber>DR20169</tran:EngineNumber>
29                                                             <!--Optional:-->
30                                                             <tran:GuideMonth>1</tran:GuideMonth>
31                                                             <!--Optional:-->
32                                                             <tran:GuideYear>2013</tran:GuideYear>
33                                                             <!--Optional:-->
34                                                             <tran:LoginId>181306</tran:LoginId>
35                                                             <!--Optional:-->
36                                                             <tran:OptionCodeNew>0</tran:OptionCodeNew>
37                                                             <!--Optional:-->
38                                                             <tran:OptionCodeUsed>0</tran:OptionCodeUsed>
39                                                             <!--Optional:-->
40                                                             <tran:Password>PW181306#</tran:Password>
41                                                             <!--Optional:-->
42                                                             <tran:RegistrationNumber>CR08RTGP</tran:RegistrationNumber>
43                                                             <tran:RegistrationYear>2005</tran:RegistrationYear>
44                                                             <!--Optional:-->
45                                                             <tran:RequestorPerson>ANDRE</tran:RequestorPerson>
46                                                             <!--Optional:-->
47                                                             <tran:RequestorTelNumber>0</tran:RequestorTelNumber>
48                                                             <!--Optional:-->
49                                                             <tran:VehicleCode>22020110</tran:VehicleCode>
50                                                             <tran:VehicleMileage>0</tran:VehicleMileage>
51                                                             <!--Optional:-->
52                                                             <tran:VinOrChasisNumber>MAJ1XXMRJ1DR20169</tran:VinOrChasisNumber>
53                                                          </tem:value>
54                                                       </tem:GetConvergedData>
55                            </soap:Envelope>';   // data from the form, e.g. some ID number
56
57            $headers = array(
58                         "Content-type: text/xml;charset=\"utf-8\"",
59                         "Accept: text/xml",
60                         "Cache-Control: no-cache",
61                         "Pragma: no-cache",
62                         "SOAPAction: http://tempuri.org/IAISConvergedB2BService/GetConvergedData", 
63                         "Content-length: ".strlen($xml_post_string),
64                     ); //SOAPAction: your op URL
65
66             $url = $soapUrl;
67
68             // PHP cURL  for https connection with auth
69             $ch = curl_init();
70             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
71             curl_setopt($ch, CURLOPT_URL, $url);
72             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
73           //  curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
74          //   curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
75             curl_setopt($ch, CURLOPT_TIMEOUT, 10);
76             curl_setopt($ch, CURLOPT_POST, true);
77             curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
78             curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
79
80             // converting
81             $response = curl_exec($ch); 
82            
83             
84            print_r ( $response );
85             // converting
86             $response1 = str_replace("<soap:Body>","",$response);
87             $response2 = str_replace("</soap:Body>","",$response1);
88
89             // convertingc to XML
90             $parser = simplexml_load_string($response2);
91             // user $parser to get your data out of XML response and to display it.
92             curl_close($ch);
93
94 ?>