2

FedEx Web Services docs state:

FedEx offers a plain XML web services solution that you can use to send transactions without having to use tools that provide SOAP protocol support for web services.

And here is an example they've used in their docs as well:

Example 3: HTTP POST
The following HTTP POST example is a valid working example. It is not guaranteed to work for all
programming languages, applications, and host systems:
POST /xml HTTP/1.0
Referrer: YourCompanyNameGoesHere
Host: ws.fedex.com
Port: 443
Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*
Content-Type: text/xml
Content-length: %d
Your FedEx Transaction

------------------------

Each line is followed by one new line character except Content-length and the FedEx transaction. Two new
line characters follow the Content-length line. The FedEx transaction has no extra characters. The Content length line should have the length of the FedEx transaction in place of the %d variable.

If I wanted to set up a plain xml transaction using an HTTP post call in kotlin, what would that entail of?

Here is the SOAP WSDL I'd like to send. Tracking a shipment via passing in a tracking number

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v18="http://fedex.com/ws/track/v18">
   <soapenv:Header/>
   <soapenv:Body>
      <v18:TrackRequest>
         <v18:WebAuthenticationDetail>
            <v18:ParentCredential>
               <v18:Key>INPUT YOUR INFORMATION</v18:Key>
               <v18:Password>INPUT YOUR INFORMATION</v18:Password>
            </v18:ParentCredential>
            <v18:UserCredential>
               <v18:Key>INPUT YOUR INFORMATION</v18:Key>
               <v18:Password>INPUT YOUR INFORMATION</v18:Password>
            </v18:UserCredential>
         </v18:WebAuthenticationDetail>
         <v18:ClientDetail>
            <v18:AccountNumber>INPUT YOUR INFORMATION</v18:AccountNumber>
            <v18:MeterNumber>INPUT YOUR INFORMATION</v18:MeterNumber>
            <v18:Localization>
               <v18:LanguageCode>EN</v18:LanguageCode>
            </v18:Localization>
         </v18:ClientDetail>
         <v18:TransactionDetail>
            <v18:CustomerTransactionId>Track By Number_v18</v18:CustomerTransactionId>
            <v18:Localization>
               <v18:LanguageCode>EN</v18:LanguageCode>
               <v18:LocaleCode>US</v18:LocaleCode>
            </v18:Localization>
         </v18:TransactionDetail>
         <v18:Version>
            <v18:ServiceId>trck</v18:ServiceId>
            <v18:Major>18</v18:Major>
            <v18:Intermediate>0</v18:Intermediate>
            <v18:Minor>0</v18:Minor>
         </v18:Version>
         <v18:SelectionDetails>
            <v18:CarrierCode>FDXE</v18:CarrierCode>
            <v18:PackageIdentifier>
               <v18:Type>TRACKING_NUMBER_OR_DOORTAG</v18:Type>
               <v18:Value>INPUT YOUR INFORMATION</v18:Value>
            </v18:PackageIdentifier>
            <v18:ShipmentAccountNumber/>
            <v18:SecureSpodAccount/>
            <v18:Destination>
               <v18:GeographicCoordinates>rates evertitque aequora</v18:GeographicCoordinates>
            </v18:Destination>
         </v18:SelectionDetails>
      </v18:TrackRequest>
   </soapenv:Body>
</soapenv:Envelope>
sisternight438
  • 153
  • 1
  • 1
  • 12

1 Answers1

5

I recently managed to successfully send a request and get a response back from Fedex. After you do your initial set up on the dev portal (get key, etc.), build and XML that looks something like this (Sample process shipment request).

The key missing piece though is the endpoint. You will not be able to work with the SOAP endpoint. Instead use https://wsbeta.fedex.com:443/xml

Also, change the following headers - as recommended by Fedex

Accept = image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*;

Content-Type = text/xml

Good luck!!

<?xml version="1.0" encoding="UTF-8"?>
<ProcessShipmentRequest xmlns="http://fedex.com/ws/ship/v26">
    <WebAuthenticationDetail>
        <UserCredential>
            <Key>Input your Key</Key>
            <Password>Input your pwd</Password>
        </UserCredential>
    </WebAuthenticationDetail>
    <ClientDetail>
        <AccountNumber>Input your Account Number</AccountNumber>
        <MeterNumber>Input your meter number</MeterNumber>
    </ClientDetail>
    <!-- <TransactionDetail>
        <CustomerTransactionId>Express Shipment Example</CustomerTransactionId>
    </TransactionDetail> -->
    <Version>
        <ServiceId>ship</ServiceId>
        <Major>26</Major>
        <Intermediate>0</Intermediate>
        <Minor>0</Minor>
    </Version>
    <RequestedShipment>
        <ShipTimestamp>2020-09-01T11:30:40.574Z</ShipTimestamp>
        <DropoffType>REGULAR_PICKUP</DropoffType>
        <ServiceType>FEDEX_GROUND</ServiceType>
        <PackagingType>YOUR_PACKAGING</PackagingType>
        <Shipper>
            <Contact>
                <PersonName>John Doe</PersonName>
                <CompanyName>FedEx</CompanyName>
                <PhoneNumber>9015551234</PhoneNumber>
            </Contact>
            <Address>
                <StreetLines>3610 Hacks Cross Road</StreetLines>
                <StreetLines>First Floor</StreetLines>
                <City>Memphis</City>
                <StateOrProvinceCode>TN</StateOrProvinceCode>
                <PostalCode>38125</PostalCode>
                <CountryCode>US</CountryCode>
            </Address>
        </Shipper>
        <Recipient>
            <Contact>
                <PersonName>Joe Customer</PersonName>
                <CompanyName>ABC Widget Co</CompanyName>
                <PhoneNumber>3305551234</PhoneNumber>
            </Contact>
            <Address>
                <StreetLines>1234 Main Street</StreetLines>
                <StreetLines>Suite 200</StreetLines>
                <City>Akron</City>
                <StateOrProvinceCode>OH</StateOrProvinceCode>
                <PostalCode>44333</PostalCode>
                <CountryCode>US</CountryCode>
                <Residential>false</Residential>
            </Address>
        </Recipient>
        <ShippingChargesPayment>
            <PaymentType>SENDER</PaymentType>
            <Payor>
                <ResponsibleParty>
                    <AccountNumber>Enter Account Number</AccountNumber>
                    <Contact />
                </ResponsibleParty>
            </Payor>
        </ShippingChargesPayment>
        <LabelSpecification>
            <LabelFormatType>COMMON2D</LabelFormatType>
            <ImageType>PDF</ImageType>
            <LabelStockType>PAPER_4X6</LabelStockType>
        </LabelSpecification>
        <PackageCount>1</PackageCount>
        <RequestedPackageLineItems>
            <SequenceNumber>1</SequenceNumber>
            <Weight>
                <Units>LB</Units>
                <Value>10.0</Value>
            </Weight>
            <Dimensions>
                <Length>5</Length>
                <Width>5</Width>
                <Height>5</Height>
                <Units>IN</Units>
            </Dimensions>
            <CustomerReferences>
                <CustomerReferenceType>CUSTOMER_REFERENCE</CustomerReferenceType>
                <Value>ref1234</Value>
            </CustomerReferences>
        </RequestedPackageLineItems>
    </RequestedShipment>
</ProcessShipmentRequest>
Sinu
  • 51
  • 1
  • 2
  • There is a special place in heaven for you. Would you be able to tell me where you found this? I am looking for rate service only. I am getting the correct rate with this, however it looks like this is actually creating the shipment. – KennethDale1 Nov 18 '20 at 15:14
  • 1
    @KennethDale1, I've been using the [FedEx Web Services Developers Guide](https://www.fedex.com/us/developer/webhelp/ws/2020/US/FedEx_WebServices_2020_Developer_Guide.htm), together with the [FedEx Ship Service Schema](https://www.fedex.com/us/developer/webhelp/ws/2020/WSDL_WebHelp/Ship%20Service%20Schema%202020/Ship_Service_2020.htm). FedEx provide a [Rate Service](https://www.fedex.com/us/developer/webhelp/ws/2020/US/FedEx_WebServices_2020_Developer_Guide.htm#t=wsdvg%2FRate_Services.htm) too. – dilico Nov 26 '20 at 16:49
  • @DiegoColantoni - I cannot seem to find how to send non-SOAP over to them for the Rate Service. In the documentation, it says it should be identical, minus the SOAP env and body. It does not work though. I also tried to send it through to the xml endpoint provided here, no luck. If you know something I don't, please let me know. I would really appreciate it. I am probably missing something trivial. As of right now, I am serializing the request myself, and before I send it over I am prepending the xml with the SOAP env and body tags. It works, feels sloppy to me though. – KennethDale1 Nov 30 '20 at 15:47
  • 1
    @KennethDale1, I've managed to get the rates using a plain XML POST request, so there might be something wrong in your xml. Things to look out for: the url is the same [https://wsbeta.fedex.com:443/xml](https://wsbeta.fedex.com:443/xml), the **xmlns** attribute of the root node is _http://fedex.com/ws/rate/v28_, the **ServiceId** of the Version node is _crs_ and the **Major** version is _28_. I've also noticed that I got 500 responses if the xml request had empty nodes, or the nodes were in the wrong order. If you want, start a new post with your xml request, and I'll have a look. – dilico Dec 01 '20 at 18:16
  • @DiegoColantoni - Here you go: https://stackoverflow.com/questions/65343524/cannot-send-non-soap-rate-request-to-fedex. Thank you in advance. Have been tied up with production issues, or else I would have gotten back sooner. – KennethDale1 Dec 17 '20 at 15:24