Конвертировать объекты из C # в PHP для SOAP PHP - PullRequest
0 голосов
/ 06 сентября 2011

У меня проблема с получением правильного параметра для определенного метода, который я запрашиваю. Они дали мне пример кода на c # о том, как его реализовать.

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.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)

Как я могу преобразовать это в php.?

Я уже начал кодировать этот, и я уже получил доступ к другому методу, который имеет простой параметр.

Я застрял только в части "VehicleConfiguration", которая, как мне кажется, является объектом.

Кто-нибудь, помогите мне, я дам кредит.

спасибо.

Ответы [ 2 ]

0 голосов
/ 08 сентября 2011

Конфигурация автомобиля CLASS (папка библиотеки)

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 (папка библиотеки)

<?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;
    }   
}

Запрос класса (Контроллер)

        $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));
0 голосов
/ 08 сентября 2011
<code><?php
$dateTime = date('m/d/Y',strtotime("01/01/2008"));
$stateAbbreviation = "CA";
$authenticationKey = "MzU=";

$vehicleConfiguration = new VehicleConfiguration();

echo "<pre>";
var_dump($vehicleConfiguration);
echo "
"; класс VehicleConfiguration {public $ Year; public $ Make; public $ Model; public $ Trim; public $ Engine; public $ Drivetrain; public $ Transmission; public $ Пробег; 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 = новый IdNamePair (151, «Coupe 2D»); $ this-> Engine = новый IdNamePair (5044, «6-цил. 3,2 литра»);); $ this-> Transmission = new IdNamePair (5049, '6-Spd SMG'); $ this-> Пробег = 20000; $ this-> VehicleCondition = 'Excellent'; вернуть $ this;}} класс IdNamePair {public $Id; public $ Name; открытая функция __construct ($ id = NULL, $ name = NULL) {$ this-> Id = $ id; $ this-> Name = $ name; вернуть $ this;}}?>

Ана пред?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...