Newbie - how do I post XML from c#?

This is a multi-part message in MIME format.

------=_NextPart_000_0061_01C5D3DE.C504E540
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I want to programatically create a small xml doc in memory, post it to =
another site then capture the resultant xml response into another xml =
doc for parsing.

I don;t want to save the file to disk, I want in all done in memory and =
automatically.

eg, this is what I have so far;

XmlDocument xmlDom =3D new XmlDocument();

xmlDom.AppendChild(xmlDom.CreateElement("", "EngineDocList", ""));

XmlElement xmlRoot =3D xmlDom.DocumentElement;

.......... rest of xml genration code.....

//now post the data and show the response

System.Net.WebClient webClient =3D new System.Net.WebClient();

webClient.Headers.Add("Content-Type","application/x-www-form-urlencoded")=
;

byte[] btPostData =3D =
System.Text.Encoding.UTF8.GetBytes(xmlDom.InnerText.ToString());

byte[] btResponse =3D webClient.UploadData("http://address", "POST", =
btPostData);

XmlDocument xmlResponse =3D new XmlDocument();

xmlResponse=3D(System.Text.Encoding.UTF8.GetString(btResponse));

.............



But it's just not working, if I try to parse the xml, or even just send =
it to a textbox I'm getting timeout errors from the host.  I know the =
address and data I'm sending is OK because I've tried manually sending =
it from a standard webform.



Can anyone help me!?



Thanks



Brett

------=_NextPart_000_0061_01C5D3DE.C504E540
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I want to programatically create a =
small xml doc in=20
memory, post it to another site then capture the resultant xml response =
into=20
another xml doc for parsing.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I don;t want to save the file to disk, =
I want in=20
all done in memory and automatically.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>eg, this is what I have so =
far;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<P><FONT face=3DArial size=3D2>XmlDocument xmlDom =3D new =
XmlDocument();</FONT></P>
<P><FONT face=3DArial =
size=3D2>xmlDom.AppendChild(xmlDom.CreateElement("",=20
"EngineDocList", ""));</FONT></P>
<P><FONT face=3DArial size=3D2>XmlElement xmlRoot =3D=20
xmlDom.DocumentElement;</FONT></P>
<P><FONT face=3DArial size=3D2>......... rest of xml genration =
code.....</FONT></P>
<P><FONT face=3DArial size=3D2>//now post the data and show the =
response</FONT></P>
<P><FONT face=3DArial size=3D2>System.Net.WebClient webClient =3D new=20
System.Net.WebClient();</FONT></P>
<P><FONT face=3DArial=20
size=3D2>webClient.Headers.Add("Content-Type","application/x-www-form-url=
encoded");</FONT></P>
<P><FONT face=3DArial size=3D2>byte[] btPostData =3D=20
System.Text.Encoding.UTF8.GetBytes(xmlDom.InnerText.ToString());</FONT></=
P>
<P><FONT face=3DArial size=3D2>byte[] btResponse =3D=20
webClient.UploadData("http://address", "POST", btPostData);</FONT></P>
<P><FONT face=3DArial size=3D2>XmlDocument xmlResponse =3D new=20
XmlDocument();</FONT></P>
<P><FONT face=3DArial=20
size=3D2>xmlResponse=3D(System.Text.Encoding.UTF8.GetString(btResponse));=
</FONT></P>
<P><FONT face=3DArial size=3D2>............</FONT></P>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<P><FONT face=3DArial size=3D2>But it's just not working, if I try to =
parse the xml,=20
or even just send it to a textbox I'm getting timeout errors from the=20
host.&nbsp; I know the address and data I'm sending is OK because I've =
tried=20
manually sending it from a standard webform.</FONT></P>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<P><FONT face=3DArial size=3D2>Can anyone help me!?</FONT></P>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<P><FONT face=3DArial size=3D2>Thanks</FONT></P>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<P><FONT face=3DArial size=3D2>Brett</FONT></P></DIV></BODY></HTML>

------=_NextPart_000_0061_01C5D3DE.C504E540--

0
10/18/2005 11:23:39 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
438 Views

Similar Articles

[PageSpeed] 42

> XmlDocument xmlResponse = new XmlDocument();
>
> xmlResponse=(System.Text.Encoding.UTF8.GetString(btResponse));
>

You try to cast string into XmlDocument, i think it isn't correct.

xmlResponse.LoadXml(System.Text.Encoding.UTF8.GetString(btResponse));

Brett Hargreaves wrote:

> Hi,
>
> I want to programatically create a small xml doc in memory, post it to another site then capture the resultant xml response into another xml doc for parsing.
>
> I don;t want to save the file to disk, I want in all done in memory and automatically.
>
> eg, this is what I have so far;
>
> XmlDocument xmlDom = new XmlDocument();
>
> xmlDom.AppendChild(xmlDom.CreateElement("", "EngineDocList", ""));
>
> XmlElement xmlRoot = xmlDom.DocumentElement;
>
> ......... rest of xml genration code.....
>
> //now post the data and show the response
>
> System.Net.WebClient webClient = new System.Net.WebClient();
>
> webClient.Headers.Add("Content-Type","application/x-www-form-urlencoded");
>
> byte[] btPostData = System.Text.Encoding.UTF8.GetBytes(xmlDom.InnerText.ToString());
>
> byte[] btResponse = webClient.UploadData("http://address", "POST", btPostData);
>
> XmlDocument xmlResponse = new XmlDocument();
>
> xmlResponse=(System.Text.Encoding.UTF8.GetString(btResponse));
>
> ............
>
>
>
> But it's just not working, if I try to parse the xml, or even just send it to a textbox I'm getting timeout errors from the host.  I know the address and data I'm sending is OK because I've tried manually sending it from a standard webform.
> 
> 
> 
> Can anyone help me!?
> 
> 
> 
> Thanks
> 
> 
> 
> Brett

0
10/18/2005 4:13:12 PM
Reply:

Similar Artilces:

Offline post-callouts?
Hello, We're using a post-callout to add some business logic to the MS CRM, but now we want that business logic available to the Outlook client when working offline as well. We've installed the COM+ component on a test client, and registered it with CRM, and it gets called at the appropriate time, but it doesn't work: the component blocks when trying to create a CRM object (e.g. BizUser). An alternative would be to access the local MSDE datastore directly, but we can't figure out how to do that (we always get "connection refused"). We're unable to find any docu...

General Ledger - General Posting Journal
On the General Posting Journal Printed Report (print JE's), how do I add a column on the printed report to show the Distribution Reference (next to the account description)? Example: Journal Transaction Transaction Audit Trail Entry Type Reference Code 2,083 Standard Adj Aug Interest GLTRX0000318 Account Description **DISTRIBUTION REFERENCE** Debit Credit 000-1000-000 Interest Exp Book interest to actual xx xx ...

Newbie
I have installed Exchange 2003 (new install) on a new install of Windows Server 2003. When I went to add info for the SMTP server (using Exchange Management System - EMS) I navigated to Servers - Exchange1 - Protocols - SMTP There's no default SMTP server listed in there. How can I get one in there? -Fran- Did you have IIS installed already? <Fran> wrote in message news:vmrpu1h04d06lpot07kbqu78lnsflpqcaa@4ax.com... >I have installed Exchange 2003 (new install) on a new install of > Windows Server 2003. > > When I went to add info for the SMTP server (using Exch...

SP2 Post-Installation Problem
I have just updated our exchange server 2003 to SP2 and have now lost the ability to send and receive any mail - either internally across the network, or externally. Any e-mails sent from outlook clients simply reamin in the outbox and refuse to move. All services seem to be running ok. Can anyone offer any help or pointers for which direction I need to look in ? Thanks I guess you already tried reboot? SkySurfer wrote: > I have just updated our exchange server 2003 to SP2 and have now lost the > ability to send and receive any mail - either internally across the network, > or ...

Payroll Posting Accounts #5
v9.0 / SQL2000 When you have the payroll posting accounts set up, how does GP know where to post transactions to, if only 2 of the 3 segments match? We have our accounts set up according to the following examples: ACCOUNTING > ACCOUNTING > SALARY ACCOUNTING > ALL > SALARY ALL > ACCOUNTING > ALL ALL > ALL > ALL Say if an employee had a transaction, and only the first 2 of the 3 segments match (ACCOUNTING > ACCOUNTING) Where would GP post the transaction amounts ? ...

SOAP xml
Fedex in the US is changing their method of dealing with their servers for submitting packages, tracking , etc. The old method was a formatted Xml file submitted via an HTTP Post. You then parsed the returned Xml that contained the information requested. Now they are phasing that out in favor of a web service using WSDL SOAP messages. I took one of their VB.Net samples and have sucessfully tracked packages and received Proof of Delivery Pdf files. However I have a problem when I deal with Fedex tech support when I have questions about some of their other services, for example Address ...

newbie question on multi-dimensional array
Hi all, I have a real lame question about multi-dimensional array operation. Suppose I have defined a two-dimensional array "Array(10,10)". If I want to use the Excel function "Average" to compute the average value of Column, say 10, of that 2D array, is there any way to realize it? I tried "Application.Average(Array(:,10))", but apparently the Excel doesn't like that. (You can see I am a Matlab guy, so please don't laugh at me:) ) Any comments are extremely welcome. -- sammus ------------------------------------------------------------------------...

LINQ to XML and Amazon Webservices
Hi, I'm having a hard time in using LINQ on XML returned from Amazon Webservices. I'm using the 2008 beta 2 on an XP machine. the code I'm using is: ========= Dim s As String s = "http://ecs.amazonaws.com/onca/xml?" & _ "Service=AWSECommerceService&" & _ "AWSAccessKeyId=1234&" & _ "AssociateTag=my-tag&" & _ "ResponseGroup=Small&" & _ "Operation=ItemSearch&" & _ ...

test post
Testing my ability to Post. ...

Chunking out data from a huge xml file (Ajax)
Hi I am faced with quite a challenge. I need to open a 70-100 meg file and be able to chunk it out using AJAX back to the client but that isn't my problem really. What I need to do is open the file and get pieces of it out without loading the entire thing into memory. The pieces themselves are random although of a fixed size. If I tried to read an entire file into a stirng and parse pieces out I use too much memory and if I use the xmlTextReader and the skip method my memory problems are solved but it creates a huge performance issue. If I don't have to I don't want to ...

About XML scheme
Hi ! What is XML scheme ? What is a use of that ? Give me some idea... Thanks & Regards Elankathir, B'lore, India. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! ElanKathir .S.N <elankathirctech@yahoo.co.in> writes: > What is XML scheme ? Is an XML based standard to describe the structure of an XML document (more powerful than DTD) > What is a use of that ? Try to start with a tutorial: http://www.w3schools.com/schema/default.asp -- Lawrence "Avevo Halo, poi e` arrivata la mia fidanza...

Newbie and eConnect
Hi All, i am trying to decide if eConnect (8.0) is the right tool for me, i was hoping someone could help. basically i am replacing existing code that i have developed in favor of eConnect. i have reviewed the documentation/help and noticed that i can insert transactions into the General Legder (GL) but NOT to the Checkbook tables (CM). at certain times i will need to be able insert records into the CM20100, CM20300, CM20400 tables. does eConnect, or related tool, support this? thanks, Kunkel Try to check Integration manager. It might have what you need. Terry "Kunkel" w...

XML Format
I am looking for documentation on the XML format required to import Vendors into Great Plains and to import Vendor invoices into Great Plains. Is this documented somewhere? I already have the format for Sales but can't find the format for these types of transactions and vendor information. Our requirements are very simple and we do not need the enhanced features of Integration manager. Jean, Using what to import with? The only "built in" tool to GP is the Import Utility which only takes a flat csv or tab file and not XML. So I'm pretty sure that isn't what ...

xml question?
what is the equivalent of this in C# ? foreach (XmlNode xmlConfigNode in xmlConfigDoc["configuration"].ChildNodes) Thansk Sorry I made a mistake here is what I want to convert to C# For Each Node In XmlDocument.Item("configuration").Item("appSettings") "Ray5531" <Ray5531@microsoft.com> wrote in message news:elPIiezOFHA.3408@TK2MSFTNGP14.phx.gbl... > what is the equivalent of this in C# ? > > foreach (XmlNode xmlConfigNode in > xmlConfigDoc["configuration"].ChildNodes) > > > > Thansk > > Hi Ray,...

XML XSL FO PDF
Can I use XML->XSL->FO->PDF in .NET? I have the XSL FO from XML, and now use client based FOP software. I have seen a few commercial packages for FO->PDF but they are costly (1000 dollars). news wrote: > Can I use XML->XSL->FO->PDF in .NET? Sure but only with some third-part library. .NET doesn't support XSL-FO natively. -- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com I am using FOP which I downloaded from somewhere (forgotten), can you recommend anything for the FO handling? I found the XSL a dream in .NET and hoped that .NET had something intrinsic ...

marshalling cascading C structures
[I managed to send this twice to microsoft.public.vb.general.discussion instead of sending it to this newsgroup... Sorry if you probably read it a third time here.] Folks, consider these cascading C structures: typedef struct AA_ { int aa1; } AA; typedef struct BB_ { int numAA; AA *AAs; } BB; typedef struct CC_ { int numBB; BB *BBs; } CC; which have been allocated dynamically. How can I marshal this in VB.net 2008? I tried this: <StructLayout(LayoutKind.Sequential)> _ Public Structure AA ...

Escape codes embedded in XML
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1 QID=\"55112\"><Tag2 AID=\"5511217\"></Tag2></Tag1><Tag1 QID=\"5512282\"><Tag2 AID=\"551228206\"></Tag2></Tag1><Tag1 QID=\"55114\"><Tag2 AID=\"5511406\"></Ta...

Newbie Remote Assistant and Desktop Questions
i Folks: Developing C++ on VS 2008 Pro, XP Pro, Win32. I have a client that recently upgraded from Vista to Windows 7 Ultimate, 32 bit, on his laptop. I recommended he get Ultimate so I could run Remote Desktop over the Internet. This is before I actually tried using Remote Desktop. After getting Remote Desktop up, I see that I really want, to help my client, is Remote Assistant. Both Remote Desktop and Remote Assistant are now running fine with two XP PCs on my LAN, using my Internet address, to connect. I've cobbled together port numbers requiring...

Hi ..I posted some more info .....
Hi I posted some more info for the conditional formating question. Any chance someone could look at it and help me out? Thanks.. Hi Andrew check your other post. Cheers JulieD "ANDREW_B" <ANDREWB@discussions.microsoft.com> wrote in message news:D449C20E-12F1-4609-B441-B0EDBD9F1B6D@microsoft.com... > Hi I posted some more info for the conditional formating question. Any > chance > someone could look at it and help me out? > > Thanks.. ...

How to rewrite Dynamic XPath jscript evaluate in c#
I have no problems running the following dynamic XPath evaluator form MSXSL: <msxsl:script implements-prefix="dyn" language="jscript"> evaluate(context, expression) { return context.nextNode().selectNodes(expression); } </msxsl:script> However, I need to run the equivalent from dot net as an XSLT extension object The following code fails with a {"Index was outside the bounds of the array." } class XSLTExtensionObjects { public IXMLDOMNodeList evaluate(IXMLDOMNamedNodeMap context, string expression) { return context.nextNode().selectNod...

Relationship between Contact and Opportunity is not shown on C. Si
Roles assigned to contacts in sales projects (opportunities) are not visible on the contacts side. Neither when the opportunity is open nor when it has been closed. Such, you are not able to see in which projects the contact was/is involved. This is clear break in the UI, where information should be accessible from all referred objects. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this ...

un posted trx warning on GL year end run
We have a situation here as follows: When tried to Year end close 2007 on GL after closing all relavant modules we received a warning message "A single-use batch or quick journal transaction has not been posted yet. Do you want to continue closing ?" We put our maximum effort to find any pending trx that of year 2007 but without success. On a test basis we override the above warning and ran the year end procedure. When finished we find out that 3 multi-currency transactions are effected on the retained earnings account (debited 3 trx and the same amount included as credit t...

Handling Cut (CTRL-C) in a CListCtrl dervied control
Hello, I have a CListCtrl derived control which presents some data. Now, I want to add handling of CTRL-C: When the user presses CTRL-C the text of the currently selected item should be copied to the clippboard. As far as I figured, accelerators are my best option? Am I right or is there an 'easy' neat whay like some OnCTRLCPressed messages? Best regards, Oliver >I have a CListCtrl derived control which presents some data. > >Now, I want to add handling of CTRL-C: >When the user presses CTRL-C the text of the currently selected >item should be co...

How do i post a 200-300 assignment as a word checkpoint
My instructor wants us to send a assignment in a 200-300 word checkpoint how do i post as a checkpoint should i just use microsoft words as the checkpoint? "cap5869" <cap5869@discussions.microsoft.com> wrote in message news:A6F749AE-E914-4A0E-B720-B9FD90E37C72@microsoft.com... > My instructor wants us to send a assignment in a 200-300 word checkpoint > how > do i post as a checkpoint should i just use microsoft words as the > checkpoint? Either you've misunderstood, or your instructor needs to clarify what a "checkpoint" is. No such thing in an...

How to create EXE having some XML files ?
Hello there I am designing one application that would create one exe and pack some resources in it(Like some XML files). Is there any way to do this ? If you are unable to understand it, please Let me know. I'd try to elaborate on it more. ...