473,657 Members | 2,598 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 4261
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.XMLHTTPC lass, 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
20740
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 But the problem occures when i want to send a data with & sign (i.e: Firm=F&B). I try to solve this problem with using boundary, but i failed. Any idea!?
1
5360
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 Send/Receive pair (even if identically the same as the first pair) returns no data. eg. The following simplified code will receive some bytes: s.Send(ByteGet, ByteGet.Length, SocketFlags.None); bytes = s.Receive(RecvBytes, RecvBytes.Length, 0); //...
6
3254
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 my customers are not really happy with having the IIS installed, not being used except to send e-mail this is becoming a problem. I have also tried using a little program from code project for sending e-mail which works great on older servers...
4
7541
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 SP2, and IIS's SMTP and WWW servers are installed. Here is the error trace: System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an...
10
3938
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 () = Encoding.ASCII.GetBytes(inputtext.ToString) networkStream.Write(sendBytes, 0, sendBytes.Length) Since there is no char value for hex 00 (NUL) it's not possible to use a
3
4550
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 windows application it worked fine, however I need to use a service as I don't want to rely on a user being logged in. The errors I get are: Index #:System.Web.HttpException: Could not access 'CDO.Message' object. --->...
8
17053
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 default, because I didn't do this in the program), but there is no actual formatting (italics, color, etc.) in the message body, which is passed to from VB.NET to Outlook as an unformatted text String. I want to start applying formatting to the...
5
2450
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 not allow "Send To Mail Recipient" (as opposed to "send as attachment") for tables. Needless to say, every other MS application (Word, Excel, etc) let's me send anything I want as a message body. Outlook lets me import anything as a message...
3
8172
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 query string with an alert() right before the request.send(queryString). An examination of the cgi enviroment and tcpdump does not show QUERY_STRING being set. Is there some I uncrossed or T on dotted?
2
17472
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 the bare minimum: System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("<my mail server IP>", 25); smtp.Send("<one of my email addresses>", "<another of my email addresses>", "Hello", "World");
0
8425
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8522
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5647
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2745
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 we have to send another system
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.