[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FedEx API Using RPG
Chris,
We no longer do our own shipping as we were purchased by another
company and they handle it all.
I'm pretty sure this works, but it never went live.
You will have to get your own user credentials from FedEx and replace
my embedded credentials.
Hope this helps.
Craig Jacobsen
From: "Hayden, Chris" <CHayden@xxxxxxxxxxxx>
To: HTTPAPI and FTPAPI Projects
<ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Date: 01/21/2015 02:10 PM
Subject: FedEx API Using RPG
Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
Craig Jacobsen
Did you get this webservice call to work and return detailed
information about the tracking number ?
Can you send me the code as an .TXT attachment
Thanks,
Chris
We have an internal Fedex server that does the estimated shipping
charges.
It uses a FedEx service program called WEBAPICS that they provided.
However, we do track shipments through FedEx, so maybe that will help.
// set up the soap request
Soap='<soapenv:Envelope +
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<http://schema
s.xmlsoap.org/soap/envelope/%22>; +
xmlns:v2="http://fedex.com/ws/track/v2"<http://fedex.com/ws/track/v2%22
>;> +
<soapenv:Header/> +
<soapenv:Body> +
<v2:TrackRequest> +
<v2:WebAuthenticationDetail> +
<v2:UserCredential> +
<v2:Key>xxxxx</v2:Key> +
<v2:Password>xxxx</v2:Password> +
</v2:UserCredential> +
</v2:WebAuthenticationDetail> +
<v2:ClientDetail> +
<v2:AccountNumber>123</v2:AccountNumber> +
<v2:MeterNumber>123</v2:MeterNumber> +
</v2:ClientDetail> +
<v2:Version> +
<v2:ServiceId>trck</v2:ServiceId> +
<v2:Major>2</v2:Major> +
<v2:Intermediate>0</v2:Intermediate> +
<v2:Minor>0</v2:Minor> +
</v2:Version> +
<v2:PackageIdentifier> +
<v2:Value>' + %Trim(TrackNumber) + '</v2:Value> +
<v2:Type>TRACKING_NUMBER_OR_DOORTAG</v2:Type> +
</v2:PackageIdentifier> +
<v2:ShipmentAccountNumber>'+
FedXCompany +
</v2:ShipmentAccountNumber>+
</v2:TrackRequest> +
</soapenv:Body> +
</soapenv:Envelope>';
// post soap service to Fed Ex (ParseXML parses information)
RC = Http_Url_Post_Xml(
'https://gateway.fedex.com:443/+<https://gateway.fedex.com/+>
web-services'
: %Addr(SOAP) + 2
: %Len(SOAP)
: *NULL
: %PAddr(ParseXML)
: %Addr(RESP)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml;charset=UTF-8'
: '"track"');
P ParseXML B
D ParseXML PI
D Save * Value
D Depth 10I 0 Value
D Name 1024A Varying Const
D Path 24576A Varying Const
D Value 32767A Varying Const
D Attrs * Dim(32767)
D const options(*varsize)
/Free
If Name = 'v2:Severity';
Severity = Value;
Endif;
If Name = 'v2:ActualDeliveryTimestamp';
Delivery = Value;
Endif;
/End-Free
P E
Thanks,
Chris Hayden
Senior Systems Analyst
Pilot Corporation of America
3855 Regent Blvd, Jacksonville, FL 32224
(904) 645.9999
Ext. 1252
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
Confidentiality Notice: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply e-mail and destroy all
copies of the original message. Unless expressly stated in this e-mail,
nothing in this message or any attachment should be construed as a
digital or electronic signature.
H DftActGrp(*No) BndDir('HTTPAPI':'QC2LE')
H Option(*SrcStmt:*NoDebugIO) Debug(*Yes)
H Copyright(' ')
*?----------------------------------------------------------------*
*?Program : FXTrkShip *
*?Description : Track a shipment *
*?Created by : Craig Jacobsen *
*?Date Created: 01/29/2009 *
*?----------------------------------------------------------------*
*?Parms:
*? None
*?----------------------------------------------------------------*
*?Maintenance History: *
*? *
*?Update# Date Pgmr Description *
*?------- ---------- ---- ---------------------------------------*
*? *
*?----------------------------------------------------------------*
/Include HttpAPI_h
*?global data structure for FedEx xml
D Data ds Qualified
D All Dim(100)
D Path 50A OverLay(All:*Next)
D Name 25A OverLay(All:*Next)
D Value 25A OverLay(All:*Next)
D Count s 10i 0
*?===============
*?prototypes
*?===============
*?Incoming/outgoing parms
D FxTrack PR ExtPgm('FXTRKSHIP')
D Track# 20A
D #elements 5p 0
D ReturnData 10000A
D FxTrack PI
D Track# 20A
D #elements 5p 0
D ReturnData 10000A
*?get delivered date and time from fedex
D GetFedXData PR
D TrackNumber 20a Const
*?parse the xml response from fedex
D ParseXML PR
D Save * Value
D Depth 10I 0 Value
D Name 1024A Varying Const
D Path 24576A Varying Const
D Value 32767A Varying Const
D Attrs * Dim(32767)
D Const Options(*varsize)
/Free
//?======================================
//? M A I N L I N E
//?======================================
Clear Data;
Count = 0;
//?turn this on to get a debug log in /tmp/httpapi_debug.txt
http_debug(*OFF);
GetFedXData(Track#);
ReturnData = Data;
#elements = Count;
//?that's all
Return;
/End-Free
*?================
*?SubProcedures
*?================
*?==========================
*?get data from FedEx Web
*?==========================
P GetFedXData B
D GetFedXData PI
D TrackNumber 20a Const
D FedXCompany s 9A
D Soap s 65535A Varying
D Resp s 65535A Varying
D RC s 10I 0
D X s 10I 0
D ErrNum s 10i 0
/Free
//?set up the soap request
Soap='<soapenv:Envelope +
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" +
xmlns:v2="http://fedex.com/ws/track/v2"> +
<soapenv:Header/> +
<soapenv:Body> +
<v2:TrackRequest> +
<v2:WebAuthenticationDetail> +
<v2:UserCredential> +
<v2:Key>qGHlSFJbN3bNGszn</v2:Key> +
<v2:Password>Lg9IdSHL2lgrkrIyZrUaKH2Bd</v2:Password> +
</v2:UserCredential> +
</v2:WebAuthenticationDetail> +
<v2:ClientDetail> +
<v2:AccountNumber>281950444</v2:AccountNumber> +
<v2:MeterNumber>100441833</v2:MeterNumber> +
</v2:ClientDetail> +
<v2:Version> +
<v2:ServiceId>trck</v2:ServiceId> +
<v2:Major>2</v2:Major> +
<v2:Intermediate>0</v2:Intermediate> +
<v2:Minor>0</v2:Minor> +
</v2:Version> +
<v2:PackageIdentifier> +
<v2:Value>' + %Trim(TrackNumber) + '</v2:Value> +
<v2:Type>TRACKING_NUMBER_OR_DOORTAG</v2:Type> +
</v2:PackageIdentifier> +
</v2:TrackRequest> +
</soapenv:Body> +
</soapenv:Envelope>';
//?try this up to 5 times in case internet is slow
For X = 1 to 5;
//?post soap service to Fed Ex (ParseXML parses information)
RC = Http_Url_Post_Xml( 'https://gatewaybeta.fedex.com:443/+
web-services'
: %Addr(SOAP) + 2
: %Len(SOAP)
: *NULL
: %PAddr(ParseXML)
: %Addr(RESP)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml;charset=UTF-8'
: '"track"');
//?if request is valid
If (RC = 1);
Leave;
EndIf;
//?check for errors, stop the request if there is some
Http_Error(ErrNum);
If (ErrNum<>HTTP_XMLERR OR X=5);
Http_Crash();
EndIf;
EndFor;
/End-Free
P E
*?==========================
*?read each ending XML tag
*?==========================
P ParseXML B
D ParseXML PI
D Save * Value
D Depth 10I 0 Value
D Name 1024A Varying Const
D Path 24576A Varying Const
D Value 32767A Varying Const
D Attrs * Dim(32767)
D const options(*varsize)
D X s 10I 0
/Free
//?omit some of the data
If Value <> *Blanks and Count < 100 AND
Value <> '0' AND
Value <> '2' AND
Value <> 'trck' AND
Value <> 'true' AND
Value <> 'OTHER' AND
Value <> 'false';
//?omit some more
X = %Scan('Request':Value);
If X = 0;
X = %Scan('HighestSeverity':Name);
EndIf;
If X = 0;
X = %Scan('Unique':Name);
EndIF;
If X = 0;
Count += 1;
Monitor;
Data.Path(Count) = %Trim(%Subst(Path:45));
On-Error;
Data.Path(Count) = ' ';
EndMon;
Data.Name(Count) = %SubSt(Name:4);
Data.Value(Count) = Value;
//?reformat some headings
X = %Scan('DeliveryTime':Data.Name(Count));
If X > 0;
Data.Name(Count) = 'DeliveryTime';
EndIF;
X = %Scan('DeliverySign':Data.Name(Count));
If X > 0;
Data.Name(Count) = 'SignedBy';
EndIF;
//?reformat timestamps
X = %Scan('-':Data.Value(Count));
If X = 5;
//?date
Data.Value(Count) = %Char(%Int(%SubSt(Value:6:2))) + '/' +
%Char(%Int(%SubSt(Value:9:2))) + '/' +
%SubSt(Value:1:4) + ' ';
//?time
If %Int(%SubSt(Value:12:2)) >= 12;
If %Int(%SubSt(Value:12:2)) > 12;
Data.Value(Count) = %Trim(Data.Value(Count)) + '@' +
%Char(%Int(%Subst(Value:12:2))-12);
Else;
Data.Value(Count) = %Trim(Data.Value(Count)) + '@' +
%SubSt(Value:12:2);
EndIf;
Data.Value(Count) = %Trim(Data.Value(Count)) + ':' +
%Subst(Value:15:2) + 'pm';
Else;
Data.Value(Count) = %Trim(Data.Value(Count)) + '@' +
%Char(%Int(%Subst(Value:12:2))) + ':' +
%Subst(Value:15:2) + 'am';
EndIf;
EndIf;
EndIf;
EndIf;
/End-Free
P E
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------