Post XML to Web page - help needed!

paasivirtapaasivirta Member Posts: 4
edited 2004-12-09 in Navision Attain
Hi! I am trying to post XML data to a web page via xmlHTTP30 automation object, and keep on getting "Invalid syntax" -message from MSXML3.dll. Here's the code:

r := '<?xml version="1.0"?>';
r := r + '<AccessRequest xml:lang="en-US">';
r := r + '<AccessLicenseNumber>2BAFE9FA08C33352</AccessLicenseNumber>';
r := r + '<UserId>myid</UserId>';
r := r + '<Password>mypass</Password>';
r := r + '</AccessRequest>';
CREATE(xmlHTTP2);
t1:='POST';
t2:='httsp://www.ups.com/ups.app/xml/Rate';
b:=FALSE;
xmlHTTP2.open (t1,t2,b);
t1:='Content-Type';
t2:='application/x-www-form-urlencoded';
xmlHTTP2.setRequestHeader (t1,t2);
xmlHTTP2.send (xmlHTTP);

Variables:
r, Text, 250
t1, Text, 250
t2, Text,250
b, Boolean
xmlHTTP2, Automation, 'Microsoft XML, v3.0'.XMLHTTP30

I'm running Navision Attain 3.01b on XP. Any help would be greatly appreciated!

Thanks,

Pete

Comments

  • dr.burnsdr.burns Member Posts: 6
    Hello,

    your code shows:

    t2:='httsp://www.ups.com/ups.app/xml/Rate'

    but httsp is not a correct protocol name!

    did you try to replace it by the correct one: https://...?

    best regards,

    dr.burns
  • paasivirtapaasivirta Member Posts: 4
    I can not believe that I did that... here's the next thing: Everything works fine until I send the xml string. At that point I get a message that the length of the string exceeds the size of the text buffer. Any ideas? Here's the modified code:

    Code:

    r := '<?xml version="1.0"?>';
    r := r + '<AccessRequest xml:lang="en-US">';
    r := r + '<AccessLicenseNumber>2BAFE9FAFG62252</AccessLicenseNumber>';
    r := r + '<UserId>myid</UserId>';
    r := r + '<Password>mypwd</Password>';
    r := r + '</AccessRequest>';
    s1 := '<?xml version="1.0"?>';
    s1 := s1 + '<RatingServiceSelectionRequest xml:lang="en-US">';
    s1 := s1 + '<Request>';
    s1 := s1 + '<TransactionReference>';
    s1 := s1 + '<CustomerContext>Bare Bones Rate Request</CustomerContext>';
    s1 := s1 + '<XpciVersion>1.0001</XpciVersion>';
    s2 := '</TransactionReference>';
    s2 := s2 + '<RequestAction>Rate</RequestAction>';
    s2 := s2 + '<RequestOption>Shop</RequestOption>';
    s2 := s2 + '</Request>';
    s2 := s2 + '<PickupType>';
    s2 := s2 + '<Code>01</Code>';
    s3 := '</PickupType>';
    s3 := s3 + '<Shipment>';
    s3 := s3 + '<Shipper>';
    s3 := s3 + '<Address>';
    s3 := s3 + '<PostalCode>54311</PostalCode>';
    s3 := s3 + '<CountryCode>US</CountryCode>';
    s4 := '</Address>';
    s4 := s4 + '</Shipper>';
    s4 := s4 + '<ShipTo>';
    s4 := s4 + '<Address>';
    s4 := s4 + '<PostalCode>60626</PostalCode>';
    s4 := s4 + '<CountryCode>US</CountryCode>';
    s5 := '</Address>';
    s5 := s5 + '</ShipTo>';
    s5 := s5 + '<ShipFrom>';
    s5 := s5 + '<Address>';
    s5 := s5 + '<PostalCode>54311</PostalCode>';
    s6 := '<CountryCode>US</CountryCode>';
    s6 := s6 + '</Addrss>';
    s6 := s6 + '</ShipFrom>';
    s6 := s6 + '<Service>';
    s6 := s6 + '<Code>01</Code>';
    s6 := s6 + '</Service>';
    s7 := '<Package>';
    s7 := s7 + '<PackagingType>';
    s7 := s7 + '<Code>02</Code>';
    s7 := s7 + '</PackagingType>';
    s7 := s7 + '<PackageWeight>';
    s7 := s7 + '<UnitOfMeasurement>';
    s8 := '<Code>LBS</Code>';
    s8 := s8 + '</UnitOfMeasurement>';
    s8 := s8 + '<Weight>75</Weight>';
    s8 := s8 + '</PackageWeight>';
    s8 := s8 + '</Package>';
    s8 := s8 + '</Shipment>';
    s8 := s8 + '</RatingServiceSelectionRequest>';
    MESSAGE(r+s1+s2+s3+s4+s5+s6+s7+s8);
    CREATE(xmlHTTP2);
    t1:='POST';
    t2:='https://www.ups.com/ups.app/xml/Rate';
    b:=FALSE;
    xmlHTTP2.open (t1,t2,b);
    t1:='Content-Type';
    t2:='application/x-www-form-urlencoded';
    xmlHTTP2.setRequestHeader (t1,t2);
    xmlHTTP2.send (r+s1+s2+s3+s4+s5+s6+s7+s8);
    MESSAGE(xmlHTTP2.responseText);

    Globals:

    Name DataType Subtype Length
    r Text 250
    xmlHTTP2 Automation 'Microsoft XML, v3.0'.XMLHTTP30
    t1 Text 250
    t2 Text 250
    t3 Text 250
    b Boolean
    s1 Text 255
    s2 Text 255
    s3 Text 255
    s4 Text 255
    s5 Text 255
    s6 Text 255
    s7 Text 255
    s8 Text 255

    Thanks!
  • NaviTools.comNaviTools.com Member Posts: 88
    Hi,

    I believe MESSAGE accepts only 1024 charactes as its parameter.

    Why don't you use OUTSTREAM instead?
    http://www.NaviTools.com
    Documentation for Microsoft Navision
    E/R diagrams, Workflow diagrams, UML diagrams, process diagrams
  • paasivirtapaasivirta Member Posts: 4
    Actually, the MESSAGE statement is not a problem and naturally can be commented out. The error message is generated at the xmlHTTP2.send -call.

    Thanks!
Sign In or Register to comment.