473,666 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending data to another server

Hi friends..
am having one problem while reading an xml file and sending the
contents by HTTP POST to another server..but i am facing the error like
->Cannot send a content-body with this verb-type.<?xml version="1.0"
encoding="utf-8"?>

am mentioning the code below..

WebRequest webreq;
WebResponse webres;
webreq =
WebRequest.Crea te("http://localhost/test/Testupload/testxml.xml");

webres = webreq.GetRespo nse();
StreamReader sReader = new
StreamReader(we bres.GetRespons eStream());
string strData = sReader.ReadToE nd();
webres.Close();

//Post data
string querystring = strData.ToStrin g();
webreq.ContentT ype = "multipart/form-data";
webreq.Method = "POST";
Stream strNewStream = webreq.GetReque stStream();
byte[] temp_byteArray;
temp_byteArray =(new
UnicodeEncoding ()).GetBytes(qu erystring);
strNewStream.Wr ite(temp_byteAr ray, 0,
temp_byteArray. Length);
strNewStream.Cl ose();
HttpContext.Cur rent.Response.W rite(querystrin g);

Kindly help me in solving the problem..In case am wrong in the above
code then plz mention the correct way to solve the problem as soon as
possible..
Regards
Priyabrata

Dec 14 '06 #1
1 1959
Hi, Pintu,
Try using the content type=text/xml
Thanks,
Nis
pintu wrote:
Hi friends..
am having one problem while reading an xml file and sending the
contents by HTTP POST to another server..but i am facing the error like
->Cannot send a content-body with this verb-type.<?xml version="1.0"
encoding="utf-8"?>

am mentioning the code below..

WebRequest webreq;
WebResponse webres;
webreq =
WebRequest.Crea te("http://localhost/test/Testupload/testxml.xml");

webres = webreq.GetRespo nse();
StreamReader sReader = new
StreamReader(we bres.GetRespons eStream());
string strData = sReader.ReadToE nd();
webres.Close();

//Post data
string querystring = strData.ToStrin g();
webreq.ContentT ype = "multipart/form-data";
webreq.Method = "POST";
Stream strNewStream = webreq.GetReque stStream();
byte[] temp_byteArray;
temp_byteArray =(new
UnicodeEncoding ()).GetBytes(qu erystring);
strNewStream.Wr ite(temp_byteAr ray, 0,
temp_byteArray. Length);
strNewStream.Cl ose();
HttpContext.Cur rent.Response.W rite(querystrin g);

Kindly help me in solving the problem..In case am wrong in the above
code then plz mention the correct way to solve the problem as soon as
possible..
Regards
Priyabrata
Dec 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14519
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the headers). I can see this because I'm running Ethereal and watching the packets. I'm defining the packets as shown below: $text_msg = "Hello, world\r\n"; $binary_msg = chr(0x01).chr(0x02).chr(0x03).chr(0x00).chr(0xA0); $binary_msg_size = 5;
0
1750
by: Walt | last post by:
I'm running SQL Server 2000 SP2 transactional replication. Periodically replication fails due to primary key errors. On investigation I find that the offending transaction is attempting to insert a duplicate of a recently replicated row (identical data including the rowtimestamp, which is automatically generated in the publishing database). My conclusion is that the distributor is sending the same transaction twice. There is usually a...
4
8197
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with TcpClient, NetworkStream and StreamWriter classes. but with low level socket it doesn't work (When using the Socket class Send method).
5
3022
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I need to send data from my server via the post method to the payment server. The payment server does not run asp.net. I dont know what they run. The payment server then returns to my server with the
3
3611
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is smtpMail.Send("from@here.com", to@there.com, "Message subject", "Message Body") I'm sending it to my own email address on a different server using a dummy
4
5401
by: Abubakar | last post by:
Hi, I am writing a server in C# and client in C++ (pure, not managed). The communication goes on through sockets. In C# I am using NetworkStream to send text data (by converting it to byte array) to the c++ client. In c++ client I have "recv" (winsock) function through which I receive everything. Now there is a need to pass a "struct" of C# through the "write" function of network stream. I want to know how this can be done. Also I would...
7
1451
by: John Bailo | last post by:
I wrote a c# web service that sends an XmlDocument as a return type. When I run it on a w2k iis machine, it takes 35s to 45s to send the data to a client (I wrote a smart client c# app to consume it, but I also tested with a browser). Question: is there any way for me to speed up the performance of my web server? Oddly, when I run it on my dev machine, an XP workstation, it only takes
0
297
by: pintu | last post by:
Hi..I posted my message earlier but it was not properly described..so am posting again. I am working in an application in which i hav to send the contents of an xml file(from my local machine) to another server(www.ups.com) as http-request.As response i will get another xml file from that server. So what i did is i had 1.collected the data by using webrequest and webresponse class's methods (like webreq.create,webreq.getresponse and...
0
1884
by: danishce | last post by:
Hello All: I am developing a client/server application using vb.net winsock programming. I am sending data to Server and at the same time receive the incoming data from the server. My application have 3 Windows Forms. 1-FrmInquiry 2-FrmSale 3-FrmBalance When i send and receive data from FrmInquiry to server it works fine but My problem is when i go to any other form(ex FrmSale) from FrmInquiry and send data from it to server, it gives...
31
12677
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it is working for normal email servers, but NOT with gmail server, I am very puzzled still!!) Codes(item c below) It keeps complaining and logs and codes are below. a) apache access logs --------------------------------- 127.0.0.1 - - "GET...
0
8356
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,...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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
8639
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
7386
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...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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
4198
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...

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.