Convert Objects from c# to php for SOAP php
I have problem in getting the right parameter to a certain method that I request. They gave me a sample of c# sample code on how to implement it.
DateTime versionDate = Convert.ToDateTime("01/01/2008");
string stateAbbreviation = "CA";
string AuthenticationKey = “MzU=”;
VehicleConfiguration vehicleConfiguration = new VehicleConfiguration();
vehicleConfiguration.Year = new IdNamePair();
vehicleConfiguration.Year.Id = 2005;
vehicleConfiguration.Year.Name = “2005”;
vehicleConfiguration.Make = new IdNamePair();
vehicleConfiguration.Make.Id = 5;
vehicleConfiguration.Make.Name = “BMW”;
vehicleConfiguration.Model = new IdNamePair();
vehicleConfiguration.Model.Id = 5;
vehicleConfiguration.Model.Name = “M3”;
vehicleConfiguration.Trim = new IdNamePair();
vehicleConfiguration.Trim.Id = 151;
vehicleConfiguration.Trim.Name = “Coupe 2D”;
vehicleConfiguration.Engine = new IdNamePair();
vehicleConfiguration.开发者_C百科Engine.Id = 5044;
vehicleConfiguration.Engine.Name = “6-Cyl. 3.2 Liter”;
vehicleConfiguration.Drivetrain = new IdNamePair();
vehicleConfiguration.Drivetrain.Id = 5049;
vehicleConfiguration.Drivetrain.Name = “RWD”;
vehicleConfiguration.Transmission = new IdNamePair();
vehicleConfiguration.Transmission.Id = 5049;
vehicleConfiguration.Transmission.Name = “6-Spd SMG”;
vehicleConfiguration.Mileage = 20000;
vehicleConfiguration.VehicleCondition = VehicleCondition.Excellent;
VehicleValuation vehicleValuation = proxy. GetVehicleValuesByVehicleConfiguration(authenticationKey, versionDate, true, stateAbbreviation,vehicleConfiguration)
How can I convert this to php.?
I already started to code this one, and I already accessed the other method which has simple parameter.
I'm stuck only at the part of "VehicleConfiguration" which is an object I think.
Someone, help me, I'll give credit.
thanks.
<?php
$dateTime = date('m/d/Y',strtotime("01/01/2008"));
$stateAbbreviation = "CA";
$authenticationKey = "MzU=";
$vehicleConfiguration = new VehicleConfiguration();
echo "<pre>";
var_dump($vehicleConfiguration);
echo "</pre>";
class VehicleConfiguration {
public $Year;
public $Make;
public $Model;
public $Trim;
public $Engine;
public $Drivetrain;
public $Transmission;
public $Mileage;
public $VehicleCondition;
public function __construct(){
$this->Year = new IdNamePair(2005, '2005');
$this->Make = new IdNamePair(5, 'BMW');
$this->Model = new IdNamePair(5, 'M3');
$this->Trim = new IdNamePair(151, 'Coupe 2D');
$this->Engine = new IdNamePair(5044, '6-Cyl. 3.2 Liter');
$this->Drivetrain = new IdNamePair(5049, 'RWD');
$this->Transmission = new IdNamePair(5049, '6-Spd SMG');
$this->Mileage = 20000;
$this->VehicleCondition = 'Excellent';
return $this;
}
}
class IdNamePair{
public $Id;
public $Name;
public function __construct($id = NULL, $name = NULL){
$this->Id = $id;
$this->Name = $name;
return $this;
}
}
?>
ana pre?
CLASS vehicleConfiguration (library folder)
class vehicleConfiguration {
public $Year;
public $Make;
public $Model;
public $Engine;
public $Transmission;
public $Mileage;
public $VehicleCondition;
public function __construct()
{
// parent::__construct();
$this->Year = (object) array();
$this->Make = (object) array();
$this->Model = (object) array();
$this->Engine = (object) array();
$this->Transmission = (object) array();
$this->Mileage = (object) array('Mileage' => '');
$this->VehicleCondition = (object) array('VehicleCondition' => '');
}
function Mileage($mileage)
{
$this->Mileage = $mileage;
}
function VehicleCondition($mileage)
{
$this->VehicleCondition = $mileage;
}
}
CLASS IdNamePair (library folder)
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class IdNamePair {
public function __construct()
{
// parent::__construct();
}
function IdNamePair($id, $name)
{
$this->Id = $id;
$this->Name = $name;
}
}
Class request (Controller)
$this->load->library('vehicleConfiguration');
$this->load->library('IdNamePair');
$soap_connect = new SoapClient('http://sample.idws.syndication.kbb.com/VehicleInformationService2008R2.svc?wsdl', array('trace' => 1));
$trim = $this->input->post('car_id'); //trim ID
$consumer_category = 'Consumer'; //Consumer, Dealer
$key = $this->input->post('Key');
$var_date = strtotime($this->input->post('Ver_date'));
$car_type = $this->input->post('Type');
$stateAbbrev= "CA";
$get_car_value->authenticationKey = $key;
$get_car_value->versionDate = $var_date;
$get_car_value->stateAbbreviation = $stateAbbrev;
$config = $this->vehicleconfiguration;
$config->Year = $this->idnamepair;
$config->Make = $this->idnamepair;
$config->Model = $this->idnamepair;
$config->Trim = $this->idnamepair;
$config->Engine = $this->idnamepair;
$config->Transmission = $this->idnamepair;
$config->Year->IdNamePair($this->input->post('year'),$this->input->post('year')) ;
$config->Make->IdNamePair($this->input->post('make'),$this->input->post('make')) ;
$config->Model->IdNamePair($this->input->post('model'),$this->input->post('model')) ;
$config->Trim->IdNamePair($this->input->post('car_id'),$this->input->post('car_id')) ;
$config->Engine->IdNamePair($this->input->post('engine'),$this->input->post('engine')) ;
$config->Transmission->IdNamePair($this->input->post('trans'),$this->input->post('trans')) ;
$config->Mileage = $this->input->post('mileage');
$config->VehicleCondition = 'Excellent';
$params = array(
'authenticationKey' => $key,
'versionDate' => $var_date,
'stateAbbreviation' => $stateAbbrev,
'Id' => $this->input->post('car_id'),
$config
);
$result = $soap_connect->__soapCall('GetVehicleValuesByVehicleConfiguration', array($params));
精彩评论