2
    $client = new SoapClient($path_to_wsdl, ['trace' => 1]);

    $this->packageLineItem = [['SequenceNumber'=>1,
              'GroupPackageCount' => 1,
              'MasterTrackingId' => '123123123123',
              'TotalShipmentWeight' =>['Value' => '256', 'Units' => 'LB'],
              'Weight' => ['Value' => 1, 'Units' => 'LB'],
        ],
        ['SequenceNumber'=>2,
              'GroupPackageCount' => 1,
              'MasterTrackingId' => '123123123123',
              'TotalShipmentWeight' =>['Value' => '256', 'Units' => 'LB'],
              'Weight' => ['Value' => 1, 'Units' => 'LB'],
        ],
        ['SequenceNumber'=>3,
              'GroupPackageCount' => 1,
              'MasterTrackingId' => '123123123123',
              'TotalShipmentWeight' =>['Value' => '256', 'Units' => 'LB'],
              'Weight' => ['Value' => 1, 'Units' => 'LB'],
        ],
        ['SequenceNumber'=>4,
              'GroupPackageCount' => 1,
              'MasterTrackingId' => '123123123123',
              'TotalShipmentWeight' =>['Value' => '256', 'Units' => 'LB'],
              'Weight' => ['Value' => 1, 'Units' => 'LB'],
        ]
    ];
    $i = 0;
    foreach ($this->packageLineItem as $key => $value)
    {
        $request = [
        'WebAuthenticationDetail' => $this->WebAuthentication,
        'ClientDetail' => $this->ClientDetail,
        'TransactionDetail' => $this->TransactionDetail,
        'Version' => $this->Version,
        'RequestedShipment' => [
            'ShipTimestamp' => date('c'),
            'DropoffType' => 'REGULAR_PICKUP',
            'ServiceType' => $ServiceType,
            'PackagingType' => 'YOUR_PACKAGING',
            'Shipper' => $this->Shipper,
            'Recipient' => $this->Recipient,
            'ShippingChargesPayment' => $this->ShippingChargesPayment,
            'LabelSpecification' => $this->LabelSpecification,
            'PackageCount' => 10,
            'MasterTrackingId' => '123123123123',
            'PackageDetail' => 'INDIVIDUAL_PACKAGES',
            'RequestedPackageLineItems' => $value
        ]
        ];
        print_r($request);
        $response = $client->processShipment($request);
        print_r($response);
        $i++;
    }

This code only works for the first piece of the shipment. It prints one label but after that it gives me error "Master Tracking ID invalid". I need to print label for each piece of that shipment. Does any one has any idea about that?

Shubh
  • 51
  • 4

0 Answers0