Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: WSDL import for UPS RateWS service API creates XML in the wrong format


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: May 30, 2014 4:16 AM Last Post By: Christophe LACH
Mark Skeels

Posts: 1
Registered: 11/11/11
WSDL import for UPS RateWS service API creates XML in the wrong format  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 29, 2014 9:35 AM
I am a newbie to using XML soap services.

Using Delphi XE2, I used the WSDL importer to create a .pas unit wrapper for UPS's Rate API.

I then translated a C# demo program into Delphi code.

My code generated a XML block request and sent it to the UPS server but it failed; the program unit nested the UPS security header container into the <SOAP-ENV:Body>. According to UPS dev tech support, it should have been outside of this element.

The error begins with the text "<NS1:UPSSecurity:" It is the position of the block that is in error.

Before you read all this my questions:

How can I get the importer to create code to generate the proper XML form, or

is there a property or something that I have to set to get this to work?


Below is the XML containing the error:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Body>
      <RateRequest xmlns="http://www.ups.com/XMLSchema/XOLTWS/Rate/v1.1">
         <Request xmlns="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
            <RequestOption>Rate</RequestOption>
         </Request>
         <Shipment>
            <Shipper>
          <ShipperNumber>FakeShipperNumber</ShipperNumber>
               <Address>
                  <AddressLine>5555 main</AddressLine>
                  <AddressLine>4 Case Cour</AddressLine>
                  <AddressLine>Apt 3B</AddressLine>
                  <City>Roswell</City>
                  <StateProvinceCode>GA</StateProvinceCode>
                  <PostalCode>30076</PostalCode>
                  <CountryCode>US</CountryCode>
               </Address>
            </Shipper>
            <ShipTo>
               <Address>
                  <AddressLine>10 E. Ritchie Way</AddressLine>
                  <AddressLine>2</AddressLine>
                  <AddressLine>Apt 3B</AddressLine>
                  <City>Palm Springs</City>
                  <StateProvinceCode>CA</StateProvinceCode>
                  <PostalCode>92262</PostalCode>
                  <CountryCode>US</CountryCode>
               </Address>
            </ShipTo>
            <ShipFrom>
               <Address>
                  <AddressLine>5555 main</AddressLine>
                  <AddressLine>4 Case Cour</AddressLine>
                  <AddressLine>Apt 3B</AddressLine>
                  <City>Roswell</City>
                  <StateProvinceCode>GA</StateProvinceCode>
                  <PostalCode>30076</PostalCode>
                  <CountryCode>US</CountryCode>
               </Address>
            </ShipFrom>
            <Service>
               <Code>02</Code>
            </Service>
            <Package>
               <PackagingType>
                  <Code>02</Code>
               </PackagingType>
               <PackageWeight>
                  <UnitOfMeasurement>
                     <Code>LBS</Code>
                     <Description>pounds</Description>
                  </UnitOfMeasurement>
                  <Weight>125</Weight>
               </PackageWeight>
            </Package>
         </Shipment>
      </RateRequest>
      <NS1:UPSSecurity xmlns:NS1="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">
         <NS1:UsernameToken>
            <Username xmlns="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">FakeUserName</Username>
            <Password xmlns="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">FakePassword</Password>
         </NS1:UsernameToken>
         <NS1:ServiceAccessToken>
            <AccessLicenseNumber xmlns="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">FakeLicenseNumber</AccessLicenseNumber>
         </NS1:ServiceAccessToken>
      </NS1:UPSSecurity>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 
 


Below is the XML the UPS support says should have been generated:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Body>
    <RateRequest xmlns="http://www.ups.com/XMLSchema/XOLTWS/Rate/v1.1">
      <Request xmlns="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
        <RequestOption>Rate</RequestOption>
      </Request>
      <Shipment>
        <Shipper>
          <ShipperNumber>FakeShipperNumber</ShipperNumber>
          <Address>
            <AddressLine>5555 main</AddressLine>
            <AddressLine>4 Case Cour</AddressLine>
            <AddressLine>Apt 3B</AddressLine>
            <City>Roswell</City>
            <StateProvinceCode>GA</StateProvinceCode>
            <PostalCode>30076</PostalCode>
            <CountryCode>US</CountryCode>
          </Address>
        </Shipper>
        <ShipTo>
          <Address>
            <AddressLine>10 E. Ritchie Way</AddressLine>
            <AddressLine>2</AddressLine>
            <AddressLine>Apt 3B</AddressLine>
            <City>Palm Springs</City>
            <StateProvinceCode>CA</StateProvinceCode>
            <PostalCode>92262</PostalCode>
            <CountryCode>US</CountryCode>
          </Address>
        </ShipTo>
        <ShipFrom>
          <Address>
            <AddressLine>5555 main</AddressLine>
            <AddressLine>4 Case Cour</AddressLine>
            <AddressLine>Apt 3B</AddressLine>
            <City>Roswell</City>
            <StateProvinceCode>GA</StateProvinceCode>
            <PostalCode>30076</PostalCode>
            <CountryCode>US</CountryCode>
          </Address>
        </ShipFrom>
        <Service>
          <Code>02</Code>
        </Service>
        <Package>
          <PackagingType>
            <Code>02</Code>
          </PackagingType>
          <PackageWeight>
            <UnitOfMeasurement>
              <Code>LBS</Code>
              <Description>pounds</Description>
            </UnitOfMeasurement>
            <Weight>125</Weight>
          </PackageWeight>
        </Package>
      </Shipment>
    </RateRequest>
  </SOAP-ENV:Body>
  <SOAP-ENV:Header>
    <NS1:UPSSecurity xmlns:NS1="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">
      <NS1:UsernameToken>
        <Username xmlns="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">FakeUserName</Username>
        <Password xmlns="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">FakePassword</Password>
      </NS1:UsernameToken>
      <NS1:ServiceAccessToken>
        <AccessLicenseNumber xmlns="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">FakeLicenseNumber</AccessLicenseNumber>
      </NS1:ServiceAccessToken>
    </NS1:UPSSecurity>
  </SOAP-ENV:Header>
</SOAP-ENV:Envelope>
 


I appreciate your consideration,
Mark
Christophe LACH

Posts: 37
Registered: 12/2/01
Re: WSDL import for UPS RateWS service API creates XML in the wrong format  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 30, 2014 4:12 AM   in response to: Mark Skeels in response to: Mark Skeels
Hi Mark,

Httprio does not handle "security descriptors" you have to craft them manually (unless it has changed with most recent dephi versions). It's just a header sent before every soap enveloppe and you must read it and check on the server side (if you wrote the server).

Jean marie BABET (aka Bruneau) wrote a unit called wsse.pas to generate a security descriptor on the client side. you can use this to customize your own header.

see this thread https://forums.embarcadero.com/thread.jspa?messageID=522465 and follow the links, or search the forums for wsse.pas (extend the date range to all or you'll find nothing).

or go directly here https://forums.embarcadero.com/message.jspa?messageID=463953

But you are lucky, usualy webservice provider do not include the "security descriptors" in the WDSL. That's why people have to craft it manually. In your case it's easyer, you just have to remove the security descriptor from source code generated by wsdlimp and paste it into wsse.pas unit.

Cheers
Chris
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02