I am trying to return only one specific rate set from the FedEx Web Service Rate Reply (XML). The Rate Reply Returns several rate types in multiple sets and I am only currently able to return the first set.
我试图从FedEx Web服务费率回复(XML)中仅返回一个特定的费率集。 Rate Reply在多个集合中返回多种速率类型,我目前只能返回第一个集合。
This is the current code that grabs the first set of results.
这是抓取第一组结果的当前代码。
set xml = CreateObject("MSXML2.ServerXMLHTTP")
xml.open "POST", "https://ws.fedex.com:443/web-services"
xml.send soapEnvelope
set parser = xml.responseXML
set rates = CreateObject("Scripting.Dictionary")
for each item in parser.SelectNodes("//RateReplyDetails")
rates.add item.SelectSingleNode("ServiceType").text, item.SelectSingleNode("RatedShipmentDetails[0]").SelectSingleNode("ShipmentRateDetail").SelectSingleNode("TotalNetCharge").text
next
set GetFedExRates = rates
Here is an example of the rate request. What I need for data is the TotalNetCharge under <v4:ActualRateType>PAYOR_LIST</v4:ActualRateType>
.
以下是费率请求的示例。我需要的数据是
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<v4:RateReply xmlns:rate="http://fedex.com/ws/rate/v5" xmlns:v4="http://fedex.com/ws/rate/v4">
<ns1:TransactionDetail xmlns:ns1="http://fedex.com/ws/rate/v4" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:CustomerTransactionId> *** Rate Request v4 using PHP ***</ns1:CustomerTransactionId>
</ns1:TransactionDetail>
<ns1:Version xmlns:ns1="http://fedex.com/ws/rate/v4" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:ServiceId>crs</ns1:ServiceId>
<ns1:Major>4</ns1:Major>
<ns1:Intermediate>0</ns1:Intermediate>
<ns1:Minor>0</ns1:Minor>
</ns1:Version>
<v4:RateReplyDetails>
<v4:ServiceType>PRIORITY_OVERNIGHT</v4:ServiceType>
<v4:PackagingType>YOUR_PACKAGING</v4:PackagingType>
<v4:IneligibleForMoneyBackGuarantee>false</v4:IneligibleForMoneyBackGuarantee>
<v4:OriginServiceArea>A1</v4:OriginServiceArea>
<v4:DestinationServiceArea>A1</v4:DestinationServiceArea>
<v4:SignatureOption>SERVICE_DEFAULT</v4:SignatureOption>
<v4:ActualRateType>PAYOR_ACCOUNT</v4:ActualRateType>
<v4:RatedShipmentDetails>
<v4:EffectiveNetDiscount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>28.02</v4:Amount>
</v4:EffectiveNetDiscount>
<v4:ShipmentRateDetail>
<v4:RateType>PAYOR_ACCOUNT</v4:RateType>
<v4:RateScale>1</v4:RateScale>
<v4:PricingCode>PACKAGE</v4:PricingCode>
<v4:DimDivisor>194</v4:DimDivisor>
<v4:FuelSurchargePercent>16.5</v4:FuelSurchargePercent>
<v4:TotalBillingWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalBillingWeight>
<v4:TotalDimWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalDimWeight>
<v4:TotalBaseCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:TotalBaseCharge>
<v4:TotalFreightDiscounts>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalFreightDiscounts>
<v4:TotalNetFreight>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:TotalNetFreight>
<v4:TotalSurcharges>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:TotalSurcharges>
<v4:TotalNetFedExCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:TotalNetFedExCharge>
<v4:TotalTaxes>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalTaxes>
<v4:TotalNetCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:TotalNetCharge>
<v4:TotalRebates>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalRebates>
<v4:Surcharges>
<v4:SurchargeType>INSURED_VALUE</v4:SurchargeType>
<v4:Description>Insured value</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:Amount>
</v4:Surcharges>
<v4:Surcharges>
<v4:SurchargeType>FUEL</v4:SurchargeType>
<v4:Description>Fuel</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:Amount>
</v4:Surcharges>
</v4:ShipmentRateDetail>
<v4:RatedPackages>
<v4:EffectiveNetDiscount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>28.02</v4:Amount>
</v4:EffectiveNetDiscount>
<v4:PackageRateDetail>
<v4:RateType>PAYOR_ACCOUNT</v4:RateType>
<v4:RatedWeightMethod>DIM</v4:RatedWeightMethod>
<v4:BillingWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:BillingWeight>
<v4:DimWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:DimWeight>
<v4:BaseCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:BaseCharge>
<v4:TotalFreightDiscounts>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalFreightDiscounts>
<v4:NetFreight>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:NetFreight>
<v4:TotalSurcharges>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:TotalSurcharges>
<v4:NetFedExCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:NetFedExCharge>
<v4:TotalTaxes>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalTaxes>
<v4:NetCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:NetCharge>
<v4:TotalRebates>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalRebates>
<v4:Surcharges>
<v4:SurchargeType>INSURED_VALUE</v4:SurchargeType>
<v4:Description>Insured value</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:Amount>
</v4:Surcharges>
<v4:Surcharges>
<v4:SurchargeType>FUEL</v4:SurchargeType>
<v4:Description>Fuel</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:Amount>
</v4:Surcharges>
</v4:PackageRateDetail>
</v4:RatedPackages>
</v4:RatedShipmentDetails>
<v4:RatedShipmentDetails>
<v4:EffectiveNetDiscount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>28.02</v4:Amount>
</v4:EffectiveNetDiscount>
<v4:ShipmentRateDetail>
<v4:RateType>RATED_ACCOUNT</v4:RateType>
<v4:RateScale>1</v4:RateScale>
<v4:PricingCode>PACKAGE</v4:PricingCode>
<v4:DimDivisor>194</v4:DimDivisor>
<v4:FuelSurchargePercent>16.5</v4:FuelSurchargePercent>
<v4:TotalBillingWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalBillingWeight>
<v4:TotalDimWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalDimWeight>
<v4:TotalBaseCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:TotalBaseCharge>
<v4:TotalFreightDiscounts>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalFreightDiscounts>
<v4:TotalNetFreight>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:TotalNetFreight>
<v4:TotalSurcharges>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:TotalSurcharges>
<v4:TotalNetFedExCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:TotalNetFedExCharge>
<v4:TotalTaxes>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalTaxes>
<v4:TotalNetCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:TotalNetCharge>
<v4:TotalRebates>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalRebates>
<v4:Surcharges>
<v4:SurchargeType>INSURED_VALUE</v4:SurchargeType>
<v4:Description>Insured value</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:Amount>
</v4:Surcharges>
<v4:Surcharges>
<v4:SurchargeType>FUEL</v4:SurchargeType>
<v4:Description>Fuel</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:Amount>
</v4:Surcharges>
</v4:ShipmentRateDetail>
<v4:RatedPackages>
<v4:EffectiveNetDiscount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>28.02</v4:Amount>
</v4:EffectiveNetDiscount>
<v4:PackageRateDetail>
<v4:RateType>RATED_ACCOUNT</v4:RateType>
<v4:RatedWeightMethod>DIM</v4:RatedWeightMethod>
<v4:BillingWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:BillingWeight>
<v4:DimWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:DimWeight>
<v4:BaseCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:BaseCharge>
<v4:TotalFreightDiscounts>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalFreightDiscounts>
<v4:NetFreight>
<v4:Currency>USD</v4:Currency>
<v4:Amount>52.25</v4:Amount>
</v4:NetFreight>
<v4:TotalSurcharges>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:TotalSurcharges>
<v4:NetFedExCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:NetFedExCharge>
<v4:TotalTaxes>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalTaxes>
<v4:NetCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>60.87</v4:Amount>
</v4:NetCharge>
<v4:TotalRebates>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalRebates>
<v4:Surcharges>
<v4:SurchargeType>INSURED_VALUE</v4:SurchargeType>
<v4:Description>Insured value</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:Amount>
</v4:Surcharges>
<v4:Surcharges>
<v4:SurchargeType>FUEL</v4:SurchargeType>
<v4:Description>Fuel</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>8.62</v4:Amount>
</v4:Amount>
</v4:Surcharges>
</v4:PackageRateDetail>
</v4:RatedPackages>
</v4:RatedShipmentDetails>
<v4:RatedShipmentDetails>
<v4:ShipmentRateDetail>
<v4:RateType>PAYOR_LIST</v4:RateType>
<v4:RateScale>1552</v4:RateScale>
<v4:RateZone>5</v4:RateZone>
<v4:PricingCode>PACKAGE</v4:PricingCode>
<v4:DimDivisor>194</v4:DimDivisor>
<v4:FuelSurchargePercent>16.5</v4:FuelSurchargePercent>
<v4:TotalBillingWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalBillingWeight>
<v4:TotalDimWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalDimWeight>
<v4:TotalBaseCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>76.3</v4:Amount>
</v4:TotalBaseCharge>
<v4:TotalFreightDiscounts>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalFreightDiscounts>
<v4:TotalNetFreight>
<v4:Currency>USD</v4:Currency>
<v4:Amount>76.3</v4:Amount>
</v4:TotalNetFreight>
<v4:TotalSurcharges>
<v4:Currency>USD</v4:Currency>
<v4:Amount>12.59</v4:Amount>
</v4:TotalSurcharges>
<v4:TotalNetFedExCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>88.89</v4:Amount>
</v4:TotalNetFedExCharge>
<v4:TotalTaxes>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalTaxes>
<v4:TotalNetCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>88.89</v4:Amount>
</v4:TotalNetCharge>
<v4:TotalRebates>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalRebates>
<v4:Surcharges>
<v4:SurchargeType>INSURED_VALUE</v4:SurchargeType>
<v4:Description>Insured value</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:Amount>
</v4:Surcharges>
<v4:Surcharges>
<v4:SurchargeType>FUEL</v4:SurchargeType>
<v4:Description>Fuel</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>12.59</v4:Amount>
</v4:Amount>
</v4:Surcharges>
</v4:ShipmentRateDetail>
<v4:RatedPackages>
<v4:PackageRateDetail>
<v4:RateType>PAYOR_LIST</v4:RateType>
<v4:RatedWeightMethod>DIM</v4:RatedWeightMethod>
<v4:BillingWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:BillingWeight>
<v4:DimWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:DimWeight>
<v4:BaseCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>76.3</v4:Amount>
</v4:BaseCharge>
<v4:TotalFreightDiscounts>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalFreightDiscounts>
<v4:NetFreight>
<v4:Currency>USD</v4:Currency>
<v4:Amount>76.3</v4:Amount>
</v4:NetFreight>
<v4:TotalSurcharges>
<v4:Currency>USD</v4:Currency>
<v4:Amount>12.59</v4:Amount>
</v4:TotalSurcharges>
<v4:NetFedExCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>88.89</v4:Amount>
</v4:NetFedExCharge>
<v4:TotalTaxes>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalTaxes>
<v4:NetCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>88.89</v4:Amount>
</v4:NetCharge>
<v4:TotalRebates>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalRebates>
<v4:Surcharges>
<v4:SurchargeType>INSURED_VALUE</v4:SurchargeType>
<v4:Description>Insured value</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:Amount>
</v4:Surcharges>
<v4:Surcharges>
<v4:SurchargeType>FUEL</v4:SurchargeType>
<v4:Description>Fuel</v4:Description>
<v4:Amount>
<v4:Currency>USD</v4:Currency>
<v4:Amount>12.59</v4:Amount>
</v4:Amount>
</v4:Surcharges>
</v4:PackageRateDetail>
</v4:RatedPackages>
</v4:RatedShipmentDetails>
<v4:RatedShipmentDetails>
<v4:ShipmentRateDetail>
<v4:RateType>RATED_LIST</v4:RateType>
<v4:RateScale>1552</v4:RateScale>
<v4:RateZone>5</v4:RateZone>
<v4:PricingCode>PACKAGE</v4:PricingCode>
<v4:DimDivisor>194</v4:DimDivisor>
<v4:FuelSurchargePercent>16.5</v4:FuelSurchargePercent>
<v4:TotalBillingWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalBillingWeight>
<v4:TotalDimWeight>
<v4:Units>LB</v4:Units>
<v4:Value>13.0</v4:Value>
</v4:TotalDimWeight>
<v4:TotalBaseCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>76.3</v4:Amount>
</v4:TotalBaseCharge>
<v4:TotalFreightDiscounts>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalFreightDiscounts>
<v4:TotalNetFreight>
<v4:Currency>USD</v4:Currency>
<v4:Amount>76.3</v4:Amount>
</v4:TotalNetFreight>
<v4:TotalSurcharges>
<v4:Currency>USD</v4:Currency>
<v4:Amount>12.59</v4:Amount>
</v4:TotalSurcharges>
<v4:TotalNetFedExCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>88.89</v4:Amount>
</v4:TotalNetFedExCharge>
<v4:TotalTaxes>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalTaxes>
<v4:TotalNetCharge>
<v4:Currency>USD</v4:Currency>
<v4:Amount>88.89</v4:Amount>
</v4:TotalNetCharge>
<v4:TotalRebates>
<v4:Currency>USD</v4:Currency>
<v4:Amount>0.0</v4:Amount>
</v4:TotalRebates>
<v4:Surcharges>
1 个解决方案
#1
0
Here's a quick example I tested using the Rate Reply XML from here. It should provide guidance on how to implement it in your case.
这是我在这里使用Rate Reply XML测试的一个简单示例。它应该提供有关如何在您的情况下实现它的指导。
set xml = CreateObject("MSXML2.DOMDocument")
xml.Load "fedex.xml"
set rates = CreateObject("Scripting.Dictionary")
for each item in xml.SelectNodes("//rate:RateReplyDetails")
serviceType = item.SelectSingleNode("rate:ServiceType").text
netCharge = item.SelectSingleNode("rate:RatedShipmentDetails/rate:ShipmentRateDetail/rate:TotalNetCharge/rate:Amount").text
Wscript.Echo "ServiceType " & serviceType & vbCrlF
Wscript.Echo "TotalNedCharge " & netCharge & vbCrlF
rates.add serviceType, netCharge
next
#1
0
Here's a quick example I tested using the Rate Reply XML from here. It should provide guidance on how to implement it in your case.
这是我在这里使用Rate Reply XML测试的一个简单示例。它应该提供有关如何在您的情况下实现它的指导。
set xml = CreateObject("MSXML2.DOMDocument")
xml.Load "fedex.xml"
set rates = CreateObject("Scripting.Dictionary")
for each item in xml.SelectNodes("//rate:RateReplyDetails")
serviceType = item.SelectSingleNode("rate:ServiceType").text
netCharge = item.SelectSingleNode("rate:RatedShipmentDetails/rate:ShipmentRateDetail/rate:TotalNetCharge/rate:Amount").text
Wscript.Echo "ServiceType " & serviceType & vbCrlF
Wscript.Echo "TotalNedCharge " & netCharge & vbCrlF
rates.add serviceType, netCharge
next