ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

FedEx Package Rate Integration with NetSuite direct integrate by WebServices

2021-03-11 21:33:00  阅读:226  来源: 互联网

标签:XML xml XXXXXX Package NetSuite direct FedEx https com


Quick TECHNICAL Note:

Reality: UPS only support WebServices integration(or window platform exe application: FedEx Ship Manager® Lite),

We need to calling UPS SOAP services, so there is JSON -> XML for input expected XML parameters and parse API return result XML -> JSON action.  Different from UPS, There is high request for xml's element order/sequence for FedEx API.


Registration for the Developer Keys

We will need registration on webside got

Developer Test Key:   PFPtfQE9ME1N****
Required for FedEx Web Services for Intra Country Shipping in US and Global 

and the Email Box:

Title: Your Developer Test Key Registration is complete

Test Account Information
<spacer.gif>
Test URL: https://wsbeta.fedex.com:443/web-services
Test Password: H6F4kyFrYIQxALXOTbH53**** 


FedEx Web Services Testing Information:
 	FedEx Shipping Account Number: **0088000 
 	FedEx Meter Number: ***2012**

  

 

On NetSuite Side we are targeting to achieve xml files like the sample:

Example 1:Rate Request

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-
ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://fedex.com/ws/rate/v28">
   <SOAP-ENV:Body>
      <RateRequest>
         <WebAuthenticationDetail>
            <ParentCredential>
               <Key>XXXXXX</Key>
               <Password>XXXXXX</Password>
            </ParentCredential>
            <UserCredential>
               <Key>XXXXXX</Key>
               <Password>XXXXXX</Password>
            </UserCredential>
         </WebAuthenticationDetail>
         <ClientDetail>
            <AccountNumber>XXXXXX</AccountNumber>
            <MeterNumber>XXXXXX</MeterNumber>
         </ClientDetail>
         <TransactionDetail>
            <CustomerTransactionId>RateRequest_v28</CustomerTransactionId>
         </TransactionDetail>
         <Version>
            <ServiceId>crs</ServiceId>
            <Major>28</Major>
            <Intermediate>0</Intermediate>
            <Minor>0</Minor>
         </Version>
         <RequestedShipment>
            <ShipTimestamp>2020-02-25T12:34:56-06:00</ShipTimestamp>
            <DropoffType>REGULAR_PICKUP</DropoffType>
            <ServiceType>PRIORITY_OVERNIGHT</ServiceType>
            <PackagingType>FEDEX_BOX</PackagingType>

<TotalWeight>
   <Units>LB</Units>
   <Value>20.0</Value>
</TotalWeight>
<Shipper>
   <AccountNumber>XXXXXX</AccountNumber>
   <Contact>
      <CompanyName>FedEx-WAPI</CompanyName>
      <PhoneNumber>XXXXXX</PhoneNumber>
   </Contact>
   <Address>
      <StreetLines>SN2000 Test Meter 8</StreetLines>
      <StreetLines>10 Fedex Parkway</StreetLines>
      <City>AUSTIN</City>
      <StateOrProvinceCode>TX</StateOrProvinceCode>
      <PostalCode>XXXXXX</PostalCode>
      <CountryCode>US</CountryCode>
   </Address>
</Shipper>
<Recipient>
   <AccountNumber>XXXXXX</AccountNumber>
   <Contact>
      <PersonName>Recipient Contact</PersonName>
      <PhoneNumber>XXXXXX</PhoneNumber>
   </Contact>
   <Address>
      <StreetLines>Recipient Address Line 1</StreetLines>
      <StreetLines>Recipient Address Line 2</StreetLines>
      <City>Collierville</City>
      <StateOrProvinceCode>TN</StateOrProvinceCode>
      <PostalCode>XXXXXX</PostalCode>
      <CountryCode>US</CountryCode>
   </Address>
</Recipient>
<ShippingChargesPayment>
   <PaymentType>SENDER</PaymentType>
   <Payor>
      <ResponsibleParty>
         <AccountNumber>XXXXXX</AccountNumber>
         <Tins>
            <TinType>BUSINESS_STATE</TinType>
            <Number>123456</Number>
         </Tins>
      </ResponsibleParty>
   </Payor>
</ShippingChargesPayment>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
   <SequenceNumber>1</SequenceNumber>
   <GroupNumber>1</GroupNumber>
   <GroupPackageCount>1</GroupPackageCount>
   <Weight>
      <Units>LB</Units>
      <Value>20.0</Value>
   </Weight>
   <Dimensions>
      <Length>12</Length>
      <Width>12</Width>
      <Height>12</Height>
      <Units>IN</Units>
   </Dimensions>
   <ContentRecords>
      <PartNumber>XXXXXX</PartNumber>
<ItemNumber>XXXXXX</ItemNumber>
                  <ReceivedQuantity>12</ReceivedQuantity>
                  <Description>ContentDescription</Description>
               </ContentRecords>
            </RequestedPackageLineItems>
         </RequestedShipment>
      </RateRequest>
   </SOAP-ENV:Body>

And all above xml element is dynamically transfered from NetSuite Sales Order data(and also data from location, currency, custom record types, settings), We got those data(in expected order), using the Google Project's X2JS to convert from JSON to XML.

 

Next resolve the across domain ajax call by using NetSuite 2.0 API https.post

var response = https.post({
            url: 'https://wsbeta.fedex.com:443/web-services',
            body: new X2JS().json2xml_str(PostDataObj),
            headers: {
                "Accept": "image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*",
                "Content-Type": "text/xml",
                "Access-Control-Allow-Origin": '*',
            }
        });

Need to thanks this thread for useful notes: https://stackoverflow.com/questions/62523251/creating-a-http-post-call-for-fedex-web-services  

 

Share tools used between XML and JSON:

  • Testing/xmlTOjson/jsonTOxml: https://peterdaugaardrasmussen.com/json2xml/
  • Source Code: https://github.com/abdolence/x2js
  • Format XML: https://jsonformatter.org/xml-formatter
  • Format JSON: https://www.sojson.com/json/json_online.html
  • XML compare https://extendsclass.com/xml-diff.html
  • Comparing XML files: https://extendsclass.com/xml-diff.html
  • POSTMAN simulate and compare the input and output

Estimate Rate

  • UPS https://www.theupsstore.com/tools/estimate-shipping-cost
  • FedEx https://www.fedex.com/en-us/online/rating.html

 

标签:XML,xml,XXXXXX,Package,NetSuite,direct,FedEx,https,com
来源: https://www.cnblogs.com/backuper/p/14520695.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有