473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Send/Receive XML through HTTP

rrocket
116 100+
Does anyone know if this is possible with flash and/or know of any tutorials or examples of how to do this. What I want to do is create a page that sends an XML string to a site and get a returned XML string with specific rate information.

In a nutshell, I am going to send package information to DHL (zip code, weight, dimensions, etc) and they will return rate information through a XML string for me to post for my customers. I have done it with ASP, but would like to create a rate calculator with Flash to distribute on various other sites.

I am currently using Flash CS3.
Oct 25 '07 #1
5 5569
xNephilimx
213 Expert 100+
Hi rrocket!
XML parsing with AS2 or AS3 is really easy, and even more intuitive with AS3.
Are you willing to do this in AS2 or AS3?
Do you need to send the package info as an xml string? is that a requirement for the system DHL has?

Best regards
The_Nephilim

Does anyone know if this is possible with flash and/or know of any tutorials or examples of how to do this. What I want to do is create a page that sends an XML string to a site and get a returned XML string with specific rate information.

In a nutshell, I am going to send package information to DHL (zip code, weight, dimensions, etc) and they will return rate information through a XML string for me to post for my customers. I have done it with ASP, but would like to create a rate calculator with Flash to distribute on various other sites.

I am currently using Flash CS3.
Oct 25 '07 #2
rrocket
116 100+
AS3 would be fine at this point especially if it will be easier to deal with, but AS2 would not be a major issue either.

Yes, I have to send them a string populated by a few input fields. Once they get it I will get another string back from them with all of the rate information.

Thanks,
rrocket
Oct 25 '07 #3
xNephilimx
213 Expert 100+
Alright.
The functions to load or send data with XML in AS3 are quite similar to AS2. So there'll be no major issues. First I'll explain you the basics:

Of course, you must write the code in some frame in the main timeline.

To load any external fine in AS3 you no longer hace the loadVars, you have the URLLoader, and to use it, you need to import the class.

Suppose you have an XML like this one:
<news>
<article>
<title>Title</title>
<content><![CDATA[The article's content here]]></content>
</article>
</news>

Expand|Select|Wrap|Line Numbers
  1. //These are the classes you will need to import
  2. import flash.events.*;
  3. import flash.net.URLLoader;
  4. import flash.net.URLRequest;
  5. import flash.xml.*;
  6. import flash.errors.*;
  7.  
  8. var _xml:XML; //I made it global, so if you need to use it in various functions it will be available
  9.  
  10. //to load the XML create an instance of the URLLoader:
  11. var _loader:URLLoader = new URLLoader();
  12. var _req:URLRequest = new URLRequest('http://www.yourdomain.com/thefile.xml');
  13. _loader.addEventListener(Event.COMPLETE, onComplete);
  14. _loader.load(_req);
  15.  
  16. function onComplete(e:Event):void {
  17.     _xml = _loader.data;
  18.     //here you can start parsing your XML with the newly introduce E4X (ECMAScript For XML)
  19. }
  20.  
To send data to an external script, you can do it the same way, but first decalring the method for the request, like this:
_req.method = URLRequestMethod.POST; for example

and declaring the format for the loader to text, so you can send the XML as text:

_loader.DataFormat = URLLoaderDataFormat.TEXT;

Check this article I found, it explains this very well:
http://livedocs.adobe.com/flex/201/h...ons_173_2.html

Best regards,
The_Nephilim

AS3 would be fine at this point especially if it will be easier to deal with, but AS2 would not be a major issue either.

Yes, I have to send them a string populated by a few input fields. Once they get it I will get another string back from them with all of the rate information.

Thanks,
rrocket
Oct 25 '07 #4
rrocket
116 100+
Great, thanks a lot!
Oct 25 '07 #5
xNephilimx
213 Expert 100+
You're welcome!
If you have any other question, don't hesitate to post back.

Best regards,
The_Nephilim

Great, thanks a lot!
Oct 25 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: malborg | last post by:
I have simple form in PHP with two input types as text to input login name and password.PS: They use POST method. (index.php) The other script(logowanie.php) checks if login and password is...
1
by: Kitchen Bin | last post by:
Hi. I am trying to use Sockets to do multiple Send and Receives via HTTP (not simultaneously). A first pair of Send/Receives works fine and sure enough I receive HTML back, but the next...
4
by: saurabhaggarwal | last post by:
Hi Could anyone please tell me how can we capture send/receive event in MS Outlook. Suppose I want to pop up a message box when user hits send/receive button, how can we do that. Actually...
13
by: Manfred Braun | last post by:
Hi All, I am trying to understand the blocking method socket.Send(). The call blocks as expected, but does this mean, it returnes after the underlying TCP layer got a confirmation, that the send...
1
by: Laura T. | last post by:
Hi, I've this kind a program, using sockets to communicate with the clients. One of the clients can be a web browser (like IE). When using IE as a client, the transmission blocks completely, and...
0
by: Steve | last post by:
I am looking into UdpClient sample code from MSDN where one UdpClient object used for both send and receive operation. Please take a look at the link below...
6
by: Cameron Eckman | last post by:
I get various errors when I try to use email on the machine I have. XP professional. It works fine on another machine with NT 2000 server. Below is the code: 'BEGIN CODE Dim oMail As New...
11
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running...
2
by: yvan | last post by:
Hi, Here is my client/server scenario: Step1: Client connects to server and sends data sucessfully (using Socket.Send()). Step2: Server gracefully exists (calls Socket.Shutdown() and...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.