WsdlToPhp / PackageGenerator

Generates a PHP SDK based on a WSDL, simple and powerful, WSDL to PHP
https://providr.io
MIT License
422 stars 73 forks source link

All tags defined by a Type outs empty in soap requests #36

Closed B-Gio-KGJ closed 9 years ago

B-Gio-KGJ commented 9 years ago

Hi,

Using the last version of PackageGenerator (compare to functional last may version again)

All tags that refer to an other object are empties, see below :

extract of old requestXML generated :

<ns1:AircraftDefinition xsi:type="ns1:ICAOIdentAircraftSpecification">
       <ns1:Equipment xsi:nil="true"/>
       <ns1:FuelBias>-10</ns1:FuelBias>
       <ns1:ICAOIdent>E55P</ns1:ICAOIdent>
       <ns1:MassAndBalanceData xsi:nil="true"/>
       <ns1:PreferedDataLevel>Global</ns1:PreferedDataLevel>
       <ns1:SpeedBias>0</ns1:SpeedBias>
       <ns1:MaxRampMass xsi:nil="true"/>
       <ns1:MaxTakeOffMass xsi:nil="true"/>
       <ns1:MaxLandingMass xsi:nil="true"/>
       <ns1:MaxZeroFuelMass xsi:nil="true"/>
</ns1:AircraftDefinition>

and generated with last version :

<ns1:AircraftDefinition/>

Same here :

old :

<ns1:FlightLevelDefinition xsi:type="ns1:OptimumFlightLevelDefinition">
       <ns1:UpperBound xsi:nil="true"/>
       <ns1:LowerBound>0</ns1:LowerBound>
</ns1:FlightLevelDefinition>

new : (here, upperBound value appears... )

<ns1:FlightLevelDefinition>
       <ns1:UpperBound>150</ns1:UpperBound>
</ns1:FlightLevelDefinition>

Same issues for all specific types tags.

I use this definitions : https://testservices.aviationcloud.aero/FlightGenerationService.svc?wsdl

Old code :

<?php

require 'AFS_AutoLoad.php';

function GenerateFlightPlan($route, $aircraftICAO, $depICAO, $desICAO, $altn1ICAO, $altn2ICAO, $date, $flightLevel, $trafficLoad, $routeToAlternate1, $routeToAlternate2)
{
    $wsdl = array();
    $wsdl[FGS_WsdlClass::WSDL_URL] = 'https://testservices.aviationcloud.aero/FlightGenerationService.svc?wsdl';
    $wsdl[FGS_WsdlClass::WSDL_CACHE_WSDL] = WSDL_CACHE_MEMORY;
    $wsdl[FGS_WsdlClass::WSDL_SOAP_VERSION] = SOAP_1_1;
    $wsdl[FGS_WsdlClass::WSDL_TRACE] = true;

    $serviceCalculate = new FGS_ServiceCalculate($wsdl);

    $paxNb = 1;
    $paxMassValue = $trafficLoad;

    $totalWeight = new FGS_StructWeight();
    $totalWeight->setUnit(FGS_EnumWeightUnit::VALUE_KILOGRAM);
    $totalWeight->setValue($paxMassValue);

    $paxLoad = new FGS_StructUnspecifiedPaxTypeLoad();
    $paxLoad->setNumberOfPax($paxNb);
    $paxLoad->setTotalWeight($totalWeight);

    $paxLoadSpecification = new FGS_StructSimplePaxLoadSpecification();
    $paxLoadSpecification->setEnableAutoLuggage(FALSE);
    $paxLoadSpecification->setPaxLoad($paxLoad);

    $flightSpecification = new FGS_StructFlightSpecification();

    $aircraftDefinition = new FGS_StructICAOIdentAircraftSpecification();
    $aircraftDefinition->setFuelBias(-10);
    $aircraftDefinition->setICAOIdent($aircraftICAO);
    $aircraftDefinition->setPreferedDataLevel(FGS_EnumDataLevel::VALUE_GLOBAL);
    $aircraftDefinition->setSpeedBias(0);

    $departureAirport = new FGS_StructAirport();
    $departureAirport->setICAOCode($depICAO);
    $departureAirport->setIsAirportOfEntry(FALSE);
    $departureAirport->setSupportsIFR(FALSE);
    $departureAirport->setType(FGS_EnumAirportType::VALUE_CIVIL);

    $destinationAirport = new FGS_StructAirport();
    $destinationAirport->setICAOCode($desICAO);
    $destinationAirport->setIsAirportOfEntry(FALSE);
    $destinationAirport->setMagneticVariation(0);
    $destinationAirport->setSupportsIFR(FALSE);
    $destinationAirport->setType(FGS_EnumAirportType::VALUE_CIVIL);

    $initialSpeed = new FGS_StructSpeed();
    $initialSpeed->setUnit(FGS_EnumSpeedUnit::VALUE_KNOTS);
    $initialSpeed->setValue(0);

    $routeToDestination = new FGS_StructRoute();
    //$routeToDestination->setFlightLevel($flightLevel);
    $routeToDestination->setInitialSpeed($initialSpeed);
    $routeToDestination->setATCroute($route);

    $upperBound = NULL;
    $lowerBound = 0;

    $optimumflightLevelDefinition = new FGS_StructOptimumFlightLevelDefinition();
    $optimumflightLevelDefinition->setLowerBound ( $lowerBound );
    $optimumflightLevelDefinition->setUpperBound ( $upperBound );

    $flightSpecification->setAircraftDefinition($aircraftDefinition);
    $flightSpecification->setDepartureAirport($departureAirport);
    $flightSpecification->setDestinationAirport($destinationAirport);
    $flightSpecification->setIsETOPSFlight(FALSE);
    $flightSpecification->setRouteToDestination($routeToDestination);
    $flightSpecification->setScheduledTimeOfDeparture($date);
    $flightSpecification->setPaxLoadSpecification($paxLoadSpecification);
    $flightSpecification->setFlightLevelDefinition($optimumflightLevelDefinition);

    if ( isset($altn1ICAO) && $altn1ICAO != "" )
    {
        $alternate1Airport = new FGS_StructAirport();
        $alternate1Airport->setICAOCode($altn1ICAO);
        $alternate1Airport->setIsAirportOfEntry(FALSE);
        $alternate1Airport->setMagneticVariation(0);
        $alternate1Airport->setSupportsIFR(FALSE);
        $alternate1Airport->setType(FGS_EnumAirportType::VALUE_CIVIL);
        $flightSpecification->setAlternateAirport1($alternate1Airport);

        if (isset($routeToAlternate1) && $routeToAlternate1 != "") {
            $route = new FGS_StructRoute();
            $route->setATCroute($routeToAlternate1);
            $flightSpecification->setRouteToAlternate1($route);
        }
    }

    if ( isset($altn2ICAO) && $altn2ICAO != "" )
    {
        $alternate2Airport = new FGS_StructAirport();
        $alternate2Airport->setICAOCode($altn2ICAO);
        $alternate2Airport->setIsAirportOfEntry(FALSE);
        $alternate2Airport->setMagneticVariation(0);
        $alternate2Airport->setSupportsIFR(FALSE);
        $alternate2Airport->setType(FGS_EnumAirportType::VALUE_CIVIL);
        $flightSpecification->setAlternateAirport2($alternate2Airport);

        if (isset($routeToAlternate2) && $routeToAlternate2 != "") {
            $route = new FGS_StructRoute();
            $route->setATCroute($routeToAlternate2);
            $flightSpecification->setRouteToAlternate2($route);
        }
    }

    $sIDSTAROptions = new FGS_StructFlightCalculationSIDSTAROptions();
    $sIDSTAROptions->setForceUseOfProceduresIfAvailable(TRUE);
    $sIDSTAROptions->setFullSIDSTARCalculation(TRUE);

    $calculationOptions = new FGS_StructFlightCalculationOptions();
    $calculationOptions->setSIDSTAROptions($sIDSTAROptions);

    $flightSpecification->setCalculationOptions($calculationOptions);
    //$flightSpecification->setWinds(new FGS_StructFixedWinds(1));
    $flightSpecification->setIncludeTCD(TRUE);

    $crewBriefingIntegrationDetails = new FGS_StructCrewBriefingIntegrationDetails();

    $flightCalculationRequest = new FGS_StructFlightCalculationRequest(NULL, $flightSpecification);
    $flightCalculationRequest->setAccountId(0);
    $flightCalculationRequest->setPassword('hidden');
    $flightCalculationRequest->setUserName('hidden');

    $calculateFlight = new FGS_StructCalculateFlightPlan($flightCalculationRequest);

    if($serviceCalculate->CalculateFlightPlan($calculateFlight))
    {
        $waypoints = '';
        file_put_contents('aax.xml', $serviceCalculate->getLastRequest());
        $estimatedDistance = $serviceCalculate->getResult()->getCalculateFlightPlanResult()->getFlightData()->getFlightDistances()->getDistanceToDestination()->getValue();
        //$estimatedDistance = $serviceCalculate->getResult()->getCalculateFlightResult()->getFlightDistances()->getDistanceToDestination()->getValue();
        $estimatedTime = $serviceCalculate->getResult()->getCalculateFlightPlanResult()->getFlightData()->getFlightTimes()->getTimeToDestination()->getValue() / 60;
        //$estimatedTime = $serviceCalculate->getResult()->getCalculateFlightResult()->getFlightTimes()->getTimeToDestination()->getValue() / 60;

        $dataPoints = $serviceCalculate->getResult()->getCalculateFlightPlanResult()->getFlightData()->getPathwayData()->getDestinationData()->getDataPoint();
        //$dataPoints = $serviceCalculate->getResult()->getCalculateFlightResult()->getPathwayData()->getDestinationData()->getDataPoint();
        foreach ($dataPoints as $dataPoint)
        {
            $waypoints .= $dataPoint->getWaypointData()->getWaypointId() . ';';
            $waypoints .= $dataPoint->getWaypointData()->getLatitude() . ';';
            $waypoints .= $dataPoint->getWaypointData()->getLongitude() . ';|';
        }
        return rtrim($waypoints, '|')."*****". $estimatedDistance."*****". $estimatedTime."*****".$serviceCalculate->getLastResponse();
    }
    else
        file_put_contents('bbx.xml', $serviceCalculate->getLastRequest()); //return null;//return($serviceCalculate->getLastRequest());
}

GenerateFlightPlan("N0430F450 BASUM3A BASUM UM170 NOR DCT LIMGO UN852 MOROK UZ24 BOLGI UN852 MILPA", "E55P", "EDDW", "LFLY", NULL, NULL, "2015-09-17T16:00:00", 350, 450, NULL, NULL);

And new code :

<?php

include 'loader.php';

function GenerateFlightPlan($route, $aircraftICAO, $depICAO, $desICAO, $altn1ICAO, $altn2ICAO, $date, $flightLevel, $trafficLoad, $routeToAlternate1, $routeToAlternate2)
{
    $wsdl = array (
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_URL => 'https://testservices.aviationcloud.aero/FlightGenerationService.svc?wsdl',
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_CLASSMAP => \FGS\ClassMap::get (),
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_SOAP_VERSION => 1,
        \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_TRACE => TRUE );

    $serviceCalculate = new \FGS\Service\Calculate ( $wsdl );

    $paxNb = 1;
    $paxMassValue = $trafficLoad;

    $totalWeight = new \FGS\Struct\Weight();
    $totalWeight->setUnit(\FGS\Enum\WeightUnit::VALUE_KILOGRAM);
    $totalWeight->setValue($paxMassValue);

    $paxLoad = new \FGS\Struct\UnspecifiedPaxTypeLoad();
    $paxLoad->setNumberOfPax($paxNb);
    $paxLoad->setTotalWeight($totalWeight);

    $paxLoadSpecification = new \FGS\Struct\SimplePaxLoadSpecification();
    $paxLoadSpecification->setEnableAutoLuggage(FALSE);
    $paxLoadSpecification->setPaxLoad($paxLoad);

    $flightSpecification = new \FGS\Struct\FlightSpecification();

    $aircraftDefinition = new \FGS\Struct\ICAOIdentAircraftSpecification();
    $aircraftDefinition->setFuelBias(-10);
    $aircraftDefinition->setICAOIdent($aircraftICAO);
    $aircraftDefinition->setPreferedDataLevel(\FGS\Enum\DataLevel::VALUE_GLOBAL);
    $aircraftDefinition->setSpeedBias(0);

    $departureAirport = new \FGS\Struct\Airport();
    $departureAirport->setICAOCode($depICAO);
    $departureAirport->setIsAirportOfEntry(FALSE);
    $departureAirport->setSupportsIFR(FALSE);
    $departureAirport->setType(\FGS\Enum\AirportType::VALUE_CIVIL);

    $destinationAirport = new \FGS\Struct\Airport();
    $destinationAirport->setICAOCode($desICAO);
    $destinationAirport->setIsAirportOfEntry(FALSE);
    $destinationAirport->setMagneticVariation(0);
    $destinationAirport->setSupportsIFR(FALSE);
    $destinationAirport->setType(\FGS\Enum\AirportType::VALUE_CIVIL);

    $initialSpeed = new \FGS\Struct\Speed();
    $initialSpeed->setUnit(\FGS\Enum\SpeedUnit::VALUE_KNOTS);
    $initialSpeed->setValue(0);

    $routeToDestination = new \FGS\Struct\Route();
    //$routeToDestination->setFlightLevel($flightLevel);
    $routeToDestination->setInitialSpeed($initialSpeed);
    $routeToDestination->setATCroute($route);

    $upperBound = 150;
    $lowerBound = 0;

    $optimumflightLevelDefinition = new \FGS\Struct\OptimumFlightLevelDefinition();
    $optimumflightLevelDefinition->setLowerBound ( $lowerBound );
    $optimumflightLevelDefinition->setUpperBound ( $upperBound );

    $flightSpecification->setAircraftDefinition($aircraftDefinition);   
    $flightSpecification->setDepartureAirport($departureAirport);
    $flightSpecification->setDestinationAirport($destinationAirport);
    $flightSpecification->setIsETOPSFlight(FALSE);
    $flightSpecification->setRouteToDestination($routeToDestination);
    $flightSpecification->setScheduledTimeOfDeparture($date);
    $flightSpecification->setPaxLoadSpecification($paxLoadSpecification);
    $flightSpecification->setFlightLevelDefinition($optimumflightLevelDefinition);

    if ( isset($altn1ICAO) && $altn1ICAO != "" )
    {
        $alternate1Airport = new \FGS\Struct\Airport();
        $alternate1Airport->setICAOCode($altn1ICAO);
        $alternate1Airport->setIsAirportOfEntry(FALSE);
        $alternate1Airport->setMagneticVariation(0);
        $alternate1Airport->setSupportsIFR(FALSE);
        $alternate1Airport->setType(\FGS\Enum\AirportType::VALUE_CIVIL);
        $flightSpecification->setAlternateAirport1($alternate1Airport);

        if (isset($routeToAlternate1) && $routeToAlternate1 != "") {
            $route = new \FGS\Struct\Route();
            $route->setATCroute($routeToAlternate1);
            $flightSpecification->setRouteToAlternate1($route);
        }
    }

    if ( isset($altn2ICAO) && $altn2ICAO != "" )
    {
        $alternate2Airport = new \FGS\Struct\Airport();
        $alternate2Airport->setICAOCode($altn2ICAO);
        $alternate2Airport->setIsAirportOfEntry(FALSE);
        $alternate2Airport->setMagneticVariation(0);
        $alternate2Airport->setSupportsIFR(FALSE);
        $alternate2Airport->setType(\FGS\Enum\AirportType::VALUE_CIVIL);
        $flightSpecification->setAlternateAirport2($alternate2Airport);

        if (isset($routeToAlternate2) && $routeToAlternate2 != "") {
            $route = new FGS_StructRoute();
            $route->setATCroute($routeToAlternate2);
            $flightSpecification->setRouteToAlternate2($route);
        }
    }

    $sIDSTAROptions = new \FGS\Struct\FlightCalculationSIDSTAROptions();
    $sIDSTAROptions->setForceUseOfProceduresIfAvailable(TRUE);
    $sIDSTAROptions->setFullSIDSTARCalculation(TRUE);

    $calculationOptions = new \FGS\Struct\FlightCalculationOptions();
    $calculationOptions->setSIDSTAROptions($sIDSTAROptions);

    $flightSpecification->setCalculationOptions($calculationOptions);
    //$flightSpecification->setWinds(new FGS_StructFixedWinds(1));
    $flightSpecification->setIncludeTCD(TRUE);

    $crewBriefingIntegrationDetails = new FGS\Struct\CrewBriefingIntegrationDetails();

    $flightCalculationRequest = new \FGS\Struct\FlightCalculationRequest(NULL, $flightSpecification);   
    $flightCalculationRequest->setAccountId(0);
    $flightCalculationRequest->setPassword('hidden');
    $flightCalculationRequest->setUserName('hidden');

    $calculateFlight = new \FGS\Struct\CalculateFlightPlan($flightCalculationRequest);

    //die("##" .$calculateFlight->getRequest()->getFlightSpecification()->getAircraftDefinition()->_get('ICAOIdent'));

    if($serviceCalculate->CalculateFlightPlan($calculateFlight))
    {
        $waypoints = '';
        file_put_contents('aaa.xml', $serviceCalculate->getLastRequest());
        $estimatedDistance = $serviceCalculate->getResult()->getCalculateFlightPlanResult()->getFlightData()->getFlightDistances()->getDistanceToDestination()->getValue();
        //$estimatedDistance = $serviceCalculate->getResult()->getCalculateFlightResult()->getFlightDistances()->getDistanceToDestination()->getValue();
        $estimatedTime = $serviceCalculate->getResult()->getCalculateFlightPlanResult()->getFlightData()->getFlightTimes()->getTimeToDestination()->getValue() / 60;
        //$estimatedTime = $serviceCalculate->getResult()->getCalculateFlightResult()->getFlightTimes()->getTimeToDestination()->getValue() / 60;

        $dataPoints = $serviceCalculate->getResult()->getCalculateFlightPlanResult()->getFlightData()->getPathwayData()->getDestinationData()->getDataPoint();
        //$dataPoints = $serviceCalculate->getResult()->getCalculateFlightResult()->getPathwayData()->getDestinationData()->getDataPoint();
        foreach ($dataPoints as $dataPoint)
        {
            $waypoints .= $dataPoint->getWaypointData()->getWaypointId() . ';';
            $waypoints .= $dataPoint->getWaypointData()->getLatitude() . ';';
            $waypoints .= $dataPoint->getWaypointData()->getLongitude() . ';|';
        }
        return rtrim($waypoints, '|')."*****". $estimatedDistance."*****". $estimatedTime."*****".$serviceCalculate->getLastResponse();
    }
    else
        file_put_contents('bbb.xml', $serviceCalculate->getLastRequest()); //return null;//return($serviceCalculate->getLastRequest());
}

GenerateFlightPlan("N0430F450 BASUM3A BASUM UM170 NOR DCT LIMGO UN852 MOROK UZ24 BOLGI UN852 MILPA", "E55P", "EDDW", "LFLY", NULL, NULL, "2015-09-17T16:00:00", 350, 450, NULL, NULL);

Regards,

mikaelcom commented 9 years ago

Have you tried using SOAP_1_1 instead of 1 (event if the constant should have this value)? I remember having trouble using the int value instead of the constant (I know it may seem stupid but I prefer having the exact same conditions).

let me know after that, thks

B-Gio-KGJ commented 9 years ago

I get same result

mikaelcom commented 9 years ago

Could you indicate the last commit of your may-version PackageGenerator? The goal is to lake a diff between between the two generated package in order to target the issue. Any best thought to identify the origin? Thanks

B-Gio-KGJ commented 9 years ago

I've no more the old generator locally, but i know i've downloaded it exactly the june 25 (no in may, sorry...)

mikaelcom commented 9 years ago

ok, thks, I'll see what I can do

B-Gio-KGJ commented 9 years ago

When i compare both codes classes generated, they're a lot of differences regarding soapclient... hard to tell where the problem comes.

Good chance !

mikaelcom commented 9 years ago

I found the origin of this issue: https://bugs.php.net/bug.php?id=69280 :smile:. Then it's on me as the generated classmap MUST not contain the full name class starting with \.

If you have another issues to report, feel free to report them before the soon-to-be-released release

B-Gio-KGJ commented 9 years ago

Hi,

Good news :smile:

Currently, except this, the xml request seem output correctly, I trust there will be no other bugs !

Your solution is powerful and very useful for big WSDL i use ! :wink: