Post XML to Web page - help needed!

paasivirta
Member Posts: 4
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
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
0
Comments
-
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.burns0 -
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!0 -
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 diagrams0 -
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!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions