473,503 Members | 9,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send XML string through HTTP

rrocket
116 New Member
I need to send xml data to a specified server and return the results. I have it covered in classic asp, but need to upgrade to .net 2.0 (C#). If anyone has a link to a tutorial or insight I would appreciate it.

This is what I have so far, but I cannot get it to work...

Expand|Select|Wrap|Line Numbers
  1. string postData = this.tbSend.Text;
  2.         string uriString = "http://website.com";
  3.         String strXML;
  4.  
  5.         XMLHTTPClass xmlHTTP = new XMLHTTPClass();
  6.  
  7.         xmlHTTP.open("POST", uriString, false, null, null);
  8.         xmlHTTP.send(postData);
  9.  
  10.         while (xmlHTTP.readyState != 4)
  11.         {
  12.         }
  13.  
  14.         strXML = (string)xmlHTTP.responseText;
  15.         this.tbGet.Text = strXML; 
What namespace does xmlHTTPClass use? I have been checking the web for a while, but cannot come up with anything.
Oct 22 '07 #1
8 4254
rrocket
116 New Member
Does anyone have a clue on how to do this? Just to clarify further.... Values from a form will populate a XML string that is sent to DHL... Once they get the information they will also return rates to me.

Is this the right forum for this type of question or should I put it in the XML forum too?
Oct 23 '07 #2
kenobewan
4,871 Recognized Expert Specialist
This post may help:
How to receive/send XML file through HTTP Post?
Oct 23 '07 #3
Plater
7,872 Recognized Expert Expert
It's MSXML2.XMLHTTPClass, but that's not .NET.

I think you could accomplish this with XMLDocument.


I found this that seems to comapre .NET vs MSXML2
http://forums.microsoft.com/MSDN/Sho...15773&SiteId=1
Oct 23 '07 #4
radcaesar
759 Recognized Expert Contributor
Use Remoting/WebService

Create the instance of that remote class in your code.

Using that proxy, call that method and pass your xml string.

:)
Oct 23 '07 #5
rrocket
116 New Member
This might help to explain what I am trying to do a bit better. This is a portion that I did with Classic ASP.

Expand|Select|Wrap|Line Numbers
  1. Sub RateWrite
  2.     counter = 1    
  3.     Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
  4.     'xmlhttp.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
  5.     xmlhttp.open "POST" ,"http://eCommerce.airborne.com/ApiLandingTest.asp",False
  6.     xmlhttp.setRequestHeader "Content-Type", "text/xml"    
  7.     'xmlhttp.open "POST" ,"https://www.zgraph.net",False
  8.     xmltext ="<?xml version=""1.0"" encoding=""UTF-8""?>"&_
  9.     "<eCommerce action=""Request"" version=""1.1"">"&_
  10.         "<Requestor>"&_
  11.             "<ID>DHLID</ID>"&_
  12.             "<Password>DHLPass</Password>"&_
  13.         "</Requestor>"
  14.     For x = 0 to 5
  15.         xmltext = xmltext &_
  16.         "<Shipment action=""RateEstimate"" version=""1.0"">"&_
  17.             "<ShippingCredentials>"&_
  18.                 "<ShippingKey>123456</ShippingKey>"&_
  19.                 "<AccountNbr>123456</AccountNbr>"&_
  20.             "</ShippingCredentials>"&_
  21.             "<ShipmentDetail>"&_
  22.                 "<ShipDate>"&datePart("yyyy",cDater)&"-"
  23.                 If datepart("m",cDater) < 10 Then
  24.                     xmltext = xmltext & "0"&datePart("m",cDater)
  25.                 Else
  26.                     xmltext = xmltext & datePart("m",cDater)
  27.                 End If
  28.                 xmltext = xmltext & "-"
  29.                 If datepart("d",cDater) < 10 Then
  30.                     xmltext = xmltext & "0"&datePart("d",cDater)
  31.                 Else
  32.                     xmltext = xmltext & datePart("d",cDater)
  33.                 End If
  34.                 xmltext = xmltext & "</ShipDate>"&_
  35.                 "<Service>"&_
  36.                     "<Code>"&arrMethod(x,0,0)&"</Code>"&_
  37.                 "</Service>"&_
  38.                 "<ShipmentType>"&_
  39.                     "<Code>"&cType&"</Code>"&_
  40.                 "</ShipmentType>"
  41.                 if cType = "P" and cInsureAmt > 5000 then
  42.                     xmltext = xmltext & _
  43.                     "<Weight>"&cWeight&"</Weight>" & _
  44.                     "<ContentDesc>"&cShipDesc&"</ContentDesc>" & _
  45.                     "<Dimensions>"&_
  46.                         "<Length>"&cLength&"</Length>"&_
  47.                         "<Width>"&cWidth&"</Width>"&_
  48.                         "<Height>"&cHeight&"</Height>"&_
  49.                     "</Dimensions>"
  50.                 elseif cType="P" then
  51.                     xmltext = xmltext & _
  52.                     "<Weight>"&cWeight&"</Weight>" & _
  53.                     "<Dimensions>"&_
  54.                         "<Length>"&cLength&"</Length>"&_
  55.                         "<Width>"&cWidth&"</Width>"&_
  56.                         "<Height>"&cHeight&"</Height>"&_
  57.                     "</Dimensions>"
  58.                 End If
  59.                 'Additional Protection
  60.                 If StripCommas(cInsureAmt) > 100 Then
  61.                 xmltext = xmltext & "<AdditionalProtection>"&_
  62.                 "<Code>"&"AP"&"</Code>"&_
  63.                 "<Value>"&StripCommas(cInsureAmt)&"</Value>"&_
  64.                 "</AdditionalProtection>"
  65.                 End if
  66.                 'End Additional Protection
  67.                 If trim(arrMethod(x,0,1)) <> "" Then
  68.                     xmltext = xmltext & _
  69.                     "<SpecialServices>" & _
  70.                         "<SpecialService>" & _
  71.                             "<Code>"&arrMethod(x,0,1)&"</Code>" & _
  72.                         "</SpecialService>" & _
  73.                     "</SpecialServices>"                        
  74.                 End If
  75.             xmltext = xmltext & _
  76.             "</ShipmentDetail>" & _
  77.             "<Billing>"&_
  78.                 "<Party>"&_
  79.                     "<Code>S</Code>"&_
  80.                 "</Party>"&_
  81.             "</Billing>"&_
  82.             "<Sender>"&_
  83.                 "<SentBy>" & "The Freight Rate Company" & "</SentBy>"&_
  84.                 "<Address>"&_
  85.                     "<CompanyName>The Freight Rate Company</CompanyName>"&_
  86.                     "<Street>123 Main Street</Street>"&_
  87.                     "<City>" & "City" & "</City>"&_
  88.                     "<State>"&cStateFrom&"</State>"&_
  89.                     "<Country>US</Country>"&_
  90.                     "<PostalCode>"&cZipFrom&"</PostalCode>"&_
  91.                 "</Address>"&_
  92.             "</Sender>"&_
  93.             "<Receiver>"&_
  94.                 "<Address>"&_
  95.                     "<CompanyName>The Freight Rate Company</CompanyName>"&_
  96.                     "<Street>123 Main Street</Street>"&_
  97.                     "<City>" & "City" & "</City>"&_
  98.                     "<State>"&cStateTo&"</State>"&_
  99.                     "<Country>US</Country>"&_
  100.                     "<PostalCode>"&cZipTo&"</PostalCode>"&_
  101.                 "</Address>"&_
  102.             "</Receiver>"&_
  103.             "<TransactionTrace>"&_
  104.                 "<SpecialType>"&arrMethod(x,0,1)&"</SpecialType>"&_
  105.             "</TransactionTrace>"&_
  106.         "</Shipment>"
  107.     Next
  108.     Set x = nothing
  109.     xmltext = xmltext & "</eCommerce>"
  110.  
Oct 23 '07 #6
radcaesar
759 Recognized Expert Contributor
Sorry buddy, I had misunderstood

Here is the code which will do that in .NET

http://codebetter.com/blogs/darrell.norton/archive/2003/07/17/468.aspx
Oct 23 '07 #7
Plater
7,872 Recognized Expert Expert
Yeah that's what I thought, the link I left was a conversion for it too.
Oct 23 '07 #8
rrocket
116 New Member
Thanks guys... That was the info I needed. Not to say that I will not have more questions later, but for now I am at least able to keep on plugging. :)
Oct 23 '07 #9

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

Similar topics

2
20734
by: Fatih BOY | last post by:
Hi, I want to send a report from a windows application to a web page like 'report.asp' Currently i can send it via post method with a context like local=En&Username=fatih&UserId=45&Firm=none...
1
5354
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...
6
3248
by: John J. Hughes II | last post by:
I have a service that needs to send e-mail alerts. I have been attempting to use the System.Net.Mail function from .NET but this seems to require the IIS be installed and running. Since some of...
4
7528
by: Aren Cambre | last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's BodyFormat = MailFormat.Html? I've searched all over the place and cannot find a solution anywhere. I am running this on Windows XP...
10
3912
by: Sven Huijbrechts | last post by:
Hello, I need to send a couple of "NUL"s -> HEX value "00" on a networkstream.. This is the code we currently use to send string: Dim sendBytes As () =...
3
4536
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
8
17035
by: John Brock | last post by:
I am currently using a VB.NET program to send out e-mails with plain text bodies (plus one attachment). The emails are being received as Rich Text messages (probably just my personal Outlook...
5
2446
by: Sean | last post by:
Hi... I want to use the macro/sendobject (or any other procedure) to send the contents of a table (very small, ~5 rows/columns) as an Outlook message body, not as an attachment. Access 2000 will...
3
8162
by: keith.schincke | last post by:
I know I must be missing something basic. I am developing of Firefox 1.5 and am trying to to send a basic QUERY_STRING to a test CGI that will print the data back to the brower: I can print my...
2
17452
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.