clasikcars
Programmer
I have been asked to add postal rates to a web page shopping cart checkout
procedure. After contacting the post office I discovered that they used XML
to receive postal rate requests and send back the rate for a certain size,
"from:" address, "To:" address and delivery service speed. The examples
they showed used a HTML "Text Area" and a HTTP post statement to send the
request however I need to use input from an input box and then insert this
information into the HTTP post. I have tried using variables but they are
sent literally rather than being substituted with the information from the
input statements. Is there a way to include the variable information as
part of the post? I am new to XML and would have thought that variable
substitution should be easy however I had no luck.
<script>
function go()
{
document.MyForm.action = " document.MyForm.submit();
}
</script>
<CENTER><H3>Sample HTTP Request to eParcel</H3></CENTER>
<FORM name=Config>
<CENTER>
Server IP Address <INPUT size = 15 name=IP value="206.191.4.228"> and port (TCP) <INPUT size=5 name=PORT value="30000">
</CENTER>
</FORM>
<FORM METHOD=POST name="MyForm">
<CENTER>
<TEXTAREA NAME=XMLRequest ROWS=20 COLS=80>
<?xml version="1.0" ?>
<eparcel>
<!--********************************-->
<!-- Prefered language for the -->
<!-- response (FR/EN) (optional) -->
<!--********************************-->
<language>en</language>
<ratesAndServicesRequest>
<!--**********************************-->
<!-- Merchant Identification assigned -->
<!-- by Canada Post -->
<!-- -->
<!-- Note: Use 'CPC_DEMO_HTML' or ask -->
<!-- our Help Desk to change your -->
<!-- profile if you want HTML to be -->
<!-- returned to you -->
<!--**********************************-->
<merchantCPCID> CPC_DEMO_XML </merchantCPCID>
<!--*********************************-->
<!--Origin Postal Code -->
<!--This parameter is optional -->
<!--*********************************-->
<fromPostalCode>m1p1c0</fromPostalCode>
<!--**********************************-->
<!-- Turn Around Time (hours) -->
<!-- This parameter is optional -->
<!--**********************************-->
<turnAroundTime> 24 </turnAroundTime>
<!--**********************************-->
<!-- Total amount in $ of the items -->
<!-- for insurance calculation -->
<!-- This parameter is optional -->
<!--**********************************-->
<itemsPrice>0.00</itemsPrice>
<!--**********************************-->
<!-- List of items in the shopping -->
<!-- cart -->
<!-- Each item is defined by : -->
<!-- - quantity (mandatory) -->
<!-- - size (mandatory) -->
<!-- - weight (mandatory) -->
<!-- - description (mandatory) -->
<!-- - ready to ship (optional) -->
<!--**********************************-->
<lineItems>
<item>
<quantity> 1 </quantity>
<weight> 1.491 </weight>
<length> 1 </length>
<width> 1 </width>
<height> 1 </height>
<description> KAO Diskettes </description>
</item>
<item>
<quantity> 1 </quantity>
<weight> 1.5 </weight>
<length> 20 </length>
<width> 30 </width>
<height> 20 </height>
<description> My Ready To Ship Item</description>
<!--******************************************-->
<!-- By adding the 'readyToShip' tag, eParcel -->
<!-- will not pack this item in the boxes -->
<!-- defined in the merchant profile. -->
<!-- Instead, this item will be shipped in its-->
<!-- original box: 1.5 kg and 20x30x20 cm -->
<!--******************************************-->
<readyToShip/>
</item>
</lineItems>
<!--********************************-->
<!-- City where the parcel will be -->
<!-- shipped to -->
<!--********************************-->
<city> </city>
<!--********************************-->
<!-- Province (Canada) or State (US)-->
<!-- where the parcel will be -->
<!-- shipped to -->
<!--********************************-->
<provOrState> Wisconsin </provOrState>
<!--********************************-->
<!-- Country or ISO Country code -->
<!-- where the parcel will be -->
<!-- shipped to -->
<!--********************************-->
<country> CANADA </country>
<!--********************************-->
<!-- Postal Code (or ZIP) where the -->
<!-- parcel will be shipped to -->
<!--********************************-->
<postalCode> H3K1E5</postalCode>
</ratesAndServicesRequest>
</eparcel>
Geoff.
procedure. After contacting the post office I discovered that they used XML
to receive postal rate requests and send back the rate for a certain size,
"from:" address, "To:" address and delivery service speed. The examples
they showed used a HTML "Text Area" and a HTTP post statement to send the
request however I need to use input from an input box and then insert this
information into the HTTP post. I have tried using variables but they are
sent literally rather than being substituted with the information from the
input statements. Is there a way to include the variable information as
part of the post? I am new to XML and would have thought that variable
substitution should be easy however I had no luck.
<script>
function go()
{
document.MyForm.action = " document.MyForm.submit();
}
</script>
<CENTER><H3>Sample HTTP Request to eParcel</H3></CENTER>
<FORM name=Config>
<CENTER>
Server IP Address <INPUT size = 15 name=IP value="206.191.4.228"> and port (TCP) <INPUT size=5 name=PORT value="30000">
</CENTER>
</FORM>
<FORM METHOD=POST name="MyForm">
<CENTER>
<TEXTAREA NAME=XMLRequest ROWS=20 COLS=80>
<?xml version="1.0" ?>
<eparcel>
<!--********************************-->
<!-- Prefered language for the -->
<!-- response (FR/EN) (optional) -->
<!--********************************-->
<language>en</language>
<ratesAndServicesRequest>
<!--**********************************-->
<!-- Merchant Identification assigned -->
<!-- by Canada Post -->
<!-- -->
<!-- Note: Use 'CPC_DEMO_HTML' or ask -->
<!-- our Help Desk to change your -->
<!-- profile if you want HTML to be -->
<!-- returned to you -->
<!--**********************************-->
<merchantCPCID> CPC_DEMO_XML </merchantCPCID>
<!--*********************************-->
<!--Origin Postal Code -->
<!--This parameter is optional -->
<!--*********************************-->
<fromPostalCode>m1p1c0</fromPostalCode>
<!--**********************************-->
<!-- Turn Around Time (hours) -->
<!-- This parameter is optional -->
<!--**********************************-->
<turnAroundTime> 24 </turnAroundTime>
<!--**********************************-->
<!-- Total amount in $ of the items -->
<!-- for insurance calculation -->
<!-- This parameter is optional -->
<!--**********************************-->
<itemsPrice>0.00</itemsPrice>
<!--**********************************-->
<!-- List of items in the shopping -->
<!-- cart -->
<!-- Each item is defined by : -->
<!-- - quantity (mandatory) -->
<!-- - size (mandatory) -->
<!-- - weight (mandatory) -->
<!-- - description (mandatory) -->
<!-- - ready to ship (optional) -->
<!--**********************************-->
<lineItems>
<item>
<quantity> 1 </quantity>
<weight> 1.491 </weight>
<length> 1 </length>
<width> 1 </width>
<height> 1 </height>
<description> KAO Diskettes </description>
</item>
<item>
<quantity> 1 </quantity>
<weight> 1.5 </weight>
<length> 20 </length>
<width> 30 </width>
<height> 20 </height>
<description> My Ready To Ship Item</description>
<!--******************************************-->
<!-- By adding the 'readyToShip' tag, eParcel -->
<!-- will not pack this item in the boxes -->
<!-- defined in the merchant profile. -->
<!-- Instead, this item will be shipped in its-->
<!-- original box: 1.5 kg and 20x30x20 cm -->
<!--******************************************-->
<readyToShip/>
</item>
</lineItems>
<!--********************************-->
<!-- City where the parcel will be -->
<!-- shipped to -->
<!--********************************-->
<city> </city>
<!--********************************-->
<!-- Province (Canada) or State (US)-->
<!-- where the parcel will be -->
<!-- shipped to -->
<!--********************************-->
<provOrState> Wisconsin </provOrState>
<!--********************************-->
<!-- Country or ISO Country code -->
<!-- where the parcel will be -->
<!-- shipped to -->
<!--********************************-->
<country> CANADA </country>
<!--********************************-->
<!-- Postal Code (or ZIP) where the -->
<!-- parcel will be shipped to -->
<!--********************************-->
<postalCode> H3K1E5</postalCode>
</ratesAndServicesRequest>
</eparcel>
Geoff.