Click here to Skip to main content
11,633,978 members (77,673 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XML PHP illegal
Dear Experts,
 
I am trying to send address information to Canada Post using xml code with PHP
 
When ever I send data I get this error message:
 
HTTP Response Status: 400 Error Code: 1623 Error Msg: A name or address field contains an invalid character such as |.
 
This is a data I am trying to send $shipping_city = "St. Philip's";
 
This is the xml code I use:
 
<pre lang="PHP"><pre lang="PHP">$xmlRequest = <<&lt;XML
<?xml version="1.0" encoding="UTF-8"?>
<shipment xmlns="http://www.canadapost.ca/ws/shipment">
    <group-id>{$groupId}</group-id>
    <requested-shipping-point>{$requestedShippingPoint}</requested-shipping-point>
    <expected-mailing-date>{$mailingDate}</expected-mailing-date>
    <delivery-spec>
        <service-code>DOM.EP</service-code>
            <sender>
                <name>ahhahah</name>
                <company>hahha Importers</company>
                <contact-phone>613 611 1112</contact-phone>
                <address-details>
                    <address-line-1>1501 Liiight Ave. Bay 7</address-line-1>
                    <city>OTTAWA</city>
                    <prov-state>ON</prov-state>
                    <country-code>CA</country-code>
                    <postal-zip-code>K1T1M5</postal-zip-code>
                </address-details>
            </sender>
            <destination>
                <name>$name</name>
                    <address-details>
                    <address-line-1>$address1</address-line-1>
                    <address-line-2>$address2</address-line-2>
                    <city>$shipping_city</city>
                    <prov-state>$shipping_state</prov-state>
                    <country-code>$shipping_country_code</country-code>
                    <postal-zip-code>$shipping_zip</postal-zip-code>
                </address-details>
            </destination>
        &lt;options>


Can someone guide me to stop the error message and send data to Canada post

Thank you very much
Posted 2-Oct-12 15:38pm
Edited 2-Oct-12 17:05pm
v2
Comments
Sergey Alexandrovich Kryukov at 2-Oct-12 22:59pm
   
Yes... it looks like Canada post system has hallucination... I wonder if they could have some stupid bug.
Did you try to send more realistic name, for an attempt of a workaround? Seriously, it could be some stupid bug which reports your "ahhahah" in a weird way. What if it checks for proper capitalization or something like that?

The fact that the server-side software is pretty bad is visible with a unarmed eye. For example, reasonable software won't tell you "a name or address field", it will tell what exactly field it was.
--SA
Sergey Alexandrovich Kryukov at 2-Oct-12 23:07pm
   
However, it could be $address1, $address2 or something. Please output all variables (you don't tell us the values) to check them up. It could be another source of the bug, in this case -- yours.
--SA
Member 9478973 at 2-Oct-12 23:10pm
   
Dear SA, Thank you very much for your comments. I am sorry, I may be did not explain my issue. "ahhahah" is just a name I put to avoid putting my company personal's name. Error show up because of $shipping_city data has a '(apostrophe) Do you know a way to include apostrophe in $shipping_city data and send it to Canada Post. Thank you very much again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,658
1 Sergey Alexandrovich Kryukov 8,204
2 Mika Wendelius 6,645
3 F-ES Sitecore 2,321
4 Suvendu Shekhar Giri 2,095


Advertise | Privacy | Mobile
Web01 | 2.8.150728.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100