首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为FedEx创建HTTP调用

为FedEx创建HTTP调用
EN

Stack Overflow用户
提问于 2020-06-22 20:47:50
回答 1查看 1.8K关注 0票数 2

FedEx Web服务文档状态:

FedEx提供了一个简单的XML服务解决方案,您可以使用该解决方案发送事务,而不必使用为web服务提供SOAP协议支持的工具。

下面是他们在自己的文档中使用的一个例子:

代码语言:javascript
运行
复制
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.

如果我想使用kotlin中的HTTP调用来设置一个简单的xml事务,那将需要什么呢?

这是我想发送的SOAP WSDL。通过输入跟踪号码跟踪货件

代码语言:javascript
运行
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2020-09-01 21:47:19

最近,我成功地发送了一个请求,并从联邦快递那里得到了回复。在对dev门户进行初始设置(获取键等)之后,构建和XML如下所示(样例流程托运请求)。

不过,缺少的关键部分是端点。您将无法使用SOAP端点。而是使用https://wsbeta.fedex.com:443/xml

另外,按照联邦快递的建议,更改以下标头

接受= image/gif,image/jpeg,image/pjpeg,text/平原,text/html,*/*;

Content= text/xml

祝你好运!

代码语言:javascript
运行
复制
<?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>
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62523251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档