1

送信された SOAP リクエスト

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/ship/v12">
  <SOAP-ENV:Body>
    <ns1:ProcessShipmentRequest>
      <ns1:WebAuthenticationDetail>
        <ns1:UserCredential>
          <ns1:Key>kQyj3MtQGLJ3ZYWG</ns1:Key>
          <ns1:Password>66ywMwyasljK5uRkaNENRZCZW</ns1:Password>
        </ns1:UserCredential>
      </ns1:WebAuthenticationDetail>
      <ns1:ClientDetail>
        <ns1:AccountNumber>510087682</ns1:AccountNumber>
        <ns1:MeterNumber>100154483</ns1:MeterNumber>
      </ns1:ClientDetail>
      <ns1:TransactionDetail>
        <ns1:CustomerTransactionId>*** Express Domestic Shipping Request v12 using PHP ***</ns1:CustomerTransactionId>
      </ns1:TransactionDetail>
      <ns1:Version>
        <ns1:ServiceId>ship</ns1:ServiceId>
        <ns1:Major>12</ns1:Major>
        <ns1:Intermediate>1</ns1:Intermediate>
        <ns1:Minor>0</ns1:Minor>
      </ns1:Version>
      <ns1:RequestedShipment>
        <ns1:ShipTimestamp>2013-03-25T14:33:08+00:00</ns1:ShipTimestamp>
        <ns1:DropoffType>REGULAR_PICKUP</ns1:DropoffType>
        <ns1:ServiceType>FEDEX_GROUND</ns1:ServiceType>
        <ns1:PackagingType>YOUR_PACKAGING</ns1:PackagingType>
        <ns1:TotalWeight>
          <ns1:Units>LB</ns1:Units>
          <ns1:Value>17.22</ns1:Value>
        </ns1:TotalWeight>
        <ns1:Shipper>
          <ns1:Contact>
            <ns1:PersonName>Shipping Department</ns1:PersonName>
            <ns1:CompanyName>Big Dog Treestands</ns1:CompanyName>
            <ns1:PhoneNumber>3092636800</ns1:PhoneNumber>
          </ns1:Contact>
          <ns1:Address>
            <ns1:StreetLines>120 E. Detroit Parkway</ns1:StreetLines>
            <ns1:City>Morton</ns1:City>
            <ns1:StateOrProvinceCode>IL</ns1:StateOrProvinceCode>
            <ns1:PostalCode>61550</ns1:PostalCode>
            <ns1:CountryCode>US</ns1:CountryCode>
          </ns1:Address>
        </ns1:Shipper>
        <ns1:Recipient>
          <ns1:Contact>
            <ns1:PersonName>David Sinc</ns1:PersonName>
            <ns1:CompanyName>TEST COMPANY</ns1:CompanyName>
            <ns1:PhoneNumber>3093701229</ns1:PhoneNumber>
          </ns1:Contact>
          <ns1:Address>
            <ns1:StreetLines>1202 Chalet Ln</ns1:StreetLines>
            <ns1:StreetLines>HIDDLY- Test Account</ns1:StreetLines>
            <ns1:City>PEORIA</ns1:City>
            <ns1:StateOrProvinceCode>IL</ns1:StateOrProvinceCode>
            <ns1:PostalCode>61614</ns1:PostalCode>
            <ns1:CountryCode>US</ns1:CountryCode>
            <ns1:Residential>false</ns1:Residential>
          </ns1:Address>
        </ns1:Recipient>
        <ns1:ShippingChargesPayment>
          <ns1:PaymentType>SENDER</ns1:PaymentType>
          <ns1:Payor>
            <ns1:ResponsibleParty>
              <ns1:AccountNumber>510087682</ns1:AccountNumber>
              <ns1:Contact/>
              <ns1:Address>
                <ns1:CountryCode>US</ns1:CountryCode>
              </ns1:Address>
            </ns1:ResponsibleParty>
          </ns1:Payor>
        </ns1:ShippingChargesPayment>
        <ns1:LabelSpecification>
          <ns1:LabelFormatType>COMMON2D</ns1:LabelFormatType>
          <ns1:ImageType>PDF</ns1:ImageType>
          <ns1:LabelStockType>PAPER_8.5X11_TOP_HALF_LABEL</ns1:LabelStockType>
        </ns1:LabelSpecification>
        <ns1:RateRequestTypes>ACCOUNT</ns1:RateRequestTypes>
        <ns1:PackageCount>1</ns1:PackageCount>
        <ns1:RequestedPackageLineItems>
          <ns1:SequenceNumber>1</ns1:SequenceNumber>
          <ns1:GroupPackageCount>1</ns1:GroupPackageCount>
          <ns1:Weight>
            <ns1:Units>LB</ns1:Units>
            <ns1:Value>17.22</ns1:Value>
          </ns1:Weight>
        </ns1:RequestedPackageLineItems>
      </ns1:RequestedShipment>
    </ns1:ProcessShipmentRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Fedex アプリケーション コード

<?php

// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0

require_once('library/fedex-common.php5');


//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "http://bigdog.webdesign309.com/wp-content/themes/bigdogtreestands-new/woocommerce/emails/ShipWebServiceClient/wsdl/ShipService_v12.wsdl";
$uploads = wp_upload_dir();
define('SHIP_LABEL', $uploads['basedir'].'/shippinglabels/shipexpresslabel'.str_replace('#','',$order->get_order_number()).'.pdf');  // PNG label file. Change to file-extension .pdf for creating a PDF label (e.g. shiplabel.pdf)

ini_set("soap.wsdl_cache_enabled", "0");

$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information


$request['WebAuthenticationDetail'] = array(
    'UserCredential' => array(
        'Key' => getProperty('key'), 
        'Password' => getProperty('password')
    )
);
$request['ClientDetail'] = array(
    'AccountNumber' => getProperty('shipaccount'), 
    'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Express Domestic Shipping Request v12 using PHP ***');
$request['Version'] = array(
    'ServiceId' => 'ship', 
    'Major' => '12', 
    'Intermediate' => '1', 
    'Minor' => '0'
);
$ships = $order->get_shipping_method();
$shippingType = "FEDEX_GROUND";
if($ships == "Fedex  Ground"){
    $shippingType = "FEDEX_GROUND"; 
}
else if( $ships == "Fedex  2 Day"){
    $shippingType = "FEDEX_2_DAY"; 
}
else if($ships == "Fedex  Standard Overnight"){
    $shippingType = "STANDARD_OVERNIGHT"; 
}
else if($ships == "Fedex  Home Delivery"){
         $shippingType = "GROUND_HOME_DELIVERY"; 
}
function totalOrderWeight($orders) {
    $totalWeight = 0;
    $items = $orders->get_items();
    foreach($items as $item) {
        $product = get_product( $item['product_id'] );
        $quantity = intval( $item['qty'] );
        $totalWeight +=  $product->get_weight() * $quantity;
    }
    return $totalWeight;
}

$request['RequestedShipment'] = array(
    'ShipTimestamp' => date('c'),
    'DropoffType' => 'REGULAR_PICKUP', // valid values REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION
    'ServiceType' => $shippingType, // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
    'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
    'TotalWeight' => array('Value' => totalOrderWeight($order), 'Units' => 'LB'), // valid values LB and KG
    'Shipper' => addShipper(),
    'Recipient' => addRecipient($order),
    'ShippingChargesPayment' => addShippingChargesPayment(),
    'LabelSpecification' => addLabelSpecification(),  
    'RateRequestTypes' => array('ACCOUNT'), // valid values ACCOUNT and LIST
    'PackageCount' => 1,
    'RequestedPackageLineItems' => array(
        '0' => addPackageLineItem1(totalOrderWeight($order))
    )
);
try 
{
    if(setEndpoint('changeEndpoint'))
    {
        $newLocation = $client->__setLocation(setEndpoint('endpoint'));
    }

    $response = $client->processShipment($request);  // FedEx web service invocation

    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR')
    {       
        printSuccess($client, $response);


        $label = 
        // Create PNG or PDF label
        // Set LabelSpecification.ImageType to 'PDF' or 'PNG for generating a PDF or a PNG label       
        $fp = fopen(SHIP_LABEL, 'wb');   
        fwrite($fp, $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image); //Create PNG or PDF file
        fclose($fp);
     //   echo '<a href="'.$uploads['url'].'/shippinglabels/shipexpresslabel'.str_replace('#','',$order->get_order_number()).'.pdf">Click Here to Download Shipping Label</a> was generated.';
    }
    else
    {
        printError($client, $response);
    }

    writeToLog($client);    // Write to log file

} catch (SoapFault $exception) {
    printFault($exception, $client);
}
function addShipper(){
    $shipper = array(
        'Contact' => array(
            'PersonName' => 'Shipping Department',
            'CompanyName' => 'Big Dog Treestands',
            'PhoneNumber' => '3092636800'),
        'Address' => array(
            'StreetLines' => array('120 E. Detroit Parkway'),
            'City' => 'Morton',
            'StateOrProvinceCode' => 'IL',
            'PostalCode' => '61550',
            'CountryCode' => 'US')
    );
    return $shipper;
}
function addRecipient($orders){ 
    $residential = get_post_meta($orders->get_order_number(), '_residential-indicator');
/*  echo 'Shipping Address 2:'.$orders->shipping_address_2;
    echo 'Shipping Address 1:'.$orders->shipping_address_1; */
    if($orders->shipping_address_2){
        $addressArray = array($orders->shipping_address_1, $orders->shipping_address_2); 
/*      echo 'Shipping Address 2'; */
            /* $addressArray =array('StreetLines' => array('Address Line 1' => $orders->shipping_address_1, 'Address Line 2' => $orders->shipping_address_2)); */
    }
    else{
        $addressArray = array($orders->shipping_address_1);
/*      echo 'Shipping Address 1'; */
    }
    $joy = false;
    if($residential == 1){
        $joy = true;
    }
    else{
        $joy = false;
    }
            $recipient = array(
        'Contact' => array(
            'PersonName' =>  $orders->billing_first_name . ' ' . $orders->billing_last_name,
            'CompanyName' => $orders->shipping_company,
            'PhoneNumber' => $orders->billing_phone),
/*          'Address' => array(
            'StreetLines' =>  array($orders->shipping_address_1, $orders->shipping_address_2),
            'City' => $orders->shipping_city,
            'StateOrProvinceCode' => $orders->shipping_state,
            'PostalCode' => $orders->shipping_postcode,
            'CountryCode' => 'US',
            'Residential' => $joy) */
        'Address' => array(
             'StreetLines'=>array($orders->shipping_address_1, $orders->shipping_address_2),
            //array(utf8_encode($orders->shipping_address_1), utf8_encode($orders->shipping_address_2)),
            'City' => $orders->shipping_city,
            'StateOrProvinceCode' => $orders->shipping_state,
            'PostalCode' => $orders->shipping_postcode,
            'CountryCode' => 'US',
            'Residential' => $joy)
    );
    return $recipient;                                      
}
function addShippingChargesPayment(){
    $shippingChargesPayment = array('PaymentType' => 'SENDER',
        'Payor' => array(
        'ResponsibleParty' => array(
            'AccountNumber' => getProperty('billaccount'),
            'Contact' => null,
            'Address' => array('CountryCode' => 'US'))));
    return $shippingChargesPayment;
}
function addLabelSpecification(){
    $labelSpecification = array(
        'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
        'ImageType' => 'PDF',  // valid values DPL, EPL2, PDF, ZPLII and PNG
        'LabelStockType' => 'PAPER_8.5X11_TOP_HALF_LABEL');
    return $labelSpecification;
}
function addPackageLineItem1($weight){
    $packageLineItem = array(
        'SequenceNumber'=>1,
        'GroupPackageCount'=>1,
        'Weight' => array(
            'Value' => $weight,
            'Units' => 'LB')

    );
    return $packageLineItem;
}

?>

これを返しますhttp://bigdog.webdesign309.com/assets/shippinglabels/shipexpresslabel1303.pdf

フェデックスに電話してもすべて試してみましたが、コードはサービスではなく便利であるため、この問題のサポートは提供していないとのことです。2番目のアドレスフィールドが表示されない理由について、この最も不可解な問題に誰かが光を当てることができれば、それは素晴らしいことです. これについて何か考えはありますか?

4

3 に答える 3

4

他の誰かがこの問題に遭遇した場合に備えて、ステージング環境からの FedEx のテスト ラベルには 2 番目の住所行が含まれていないように見えることに注意してください。

すべてのテスト ラベルには 2 番目の住所行がありませんでしたが、運用サーバーに切り替えるとすぐに、ラベルに 2 番目の行が表示されました。

于 2016-05-03T19:00:51.050 に答える
0

XML が有効に見えるため、複数のアドレス行が必要です。FedEx サポートは、SOAP 要求/応答に基づいて支援を提供できるはずですが、PHP コーディングに関する支援は提供しません。

于 2013-11-14T17:08:11.383 に答える
0

Ship Service Docs によると、住所行は 2 つしかないため、次のように解決しました。

'Address' => array(
        'StreetLines' => array($array_recipient["address_1"],$array_recipient["address_2"]),
        'City' => $array_recipient["City"],
        'StateOrProvinceCode' => $array_recipient["StateOrProvinceCode"],
        'PostalCode' => $array_recipient["PostalCode"],
        'CountryCode' => 'MX',
        'Residential' => true
    )

さらに「スペース」が必要な場合は、CUSTOMER_REFERENCE (寸法の直後) を使用できます。

$packageLineItem = array(
    'SequenceNumber'=>1,
    'GroupPackageCount'=>1,
    'Weight' => array(
        'Value' => $dimension_array["weight"],
        'Units' => 'KG'
    ),
    'Dimensions' => array(
        'Length' => $dimension_array["length"],
        'Width' => $dimension_array["width"],
        'Height' => $dimension_array["height"],
        'Units' => 'CM'
    ),
    'CustomerReferences' => array(
    'CustomerReferenceType' => 'CUSTOMER_REFERENCE',
    'Value' => $dimension_array["more_references"]
    ),

テスト環境でリクエストを行うと、2 番目のアドレスは表示されませんが、本番環境になると 2 番目のアドレスが表示されます。

これがお役に立てば幸いです。

于 2018-10-24T18:01:22.610 に答える