473,399 Members | 3,038 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,399 software developers and data experts.

Unexpected error using WebRequest

Hello,

I try to post an HTTP message containing an XML document, and I get the
following exception :

System.Net.WebException: The underlying connection was closed: An unexpected
error occurred on a send. ---System.IO.IOException: Unable to write data to
the transport connection: Uma solicitação de envio ou recepção de dados não
foi permitida porque o socket não está ligado e (durante o envio num socket
de datagrama utilizando uma chamada sendto) não foi fornecido um endereço.
---System.Net.Sockets.SocketException: Uma solicitação de envio ou recepção
de dados não foi permitida porque o socket não está ligado e (durante o envio
num socket de datagrama utilizando uma chamada sendto) não foi fornecido um
endereço
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset,
Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset,
Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream()
at Lafon.Easy.Process.DemandesAuSite.ExecuteDemandeSi te() in
C:\VSSBASSENS\Easy\Version 2.x\Visual
Studio\Lafon\Easy\Process\genereFich.cs:line 9618

It looks as if the underlying socket was closed prematurely. The problem
occurs on a WINDOWS XP SP2 (Portuguese), but the same code works fine on
other computers with the same operating system.

Framework is version 2.0 SP1. The code is executed from within an ASP.NET
web application running on IIS.

The code is :

string _xmlDemande = "<?xml version=\"1.0\"
encoding=\"iso-8859-\"?><demServ><dem login=\"" + _sLogin + "\" pass=\"" +
_sPass + "\" fich=\"" + _sNomFich + "\" typeRepKo=\"" + sTypeRep + "\"
/></demServ>";

byte[] dataToPost = new ASCIIEncoding().GetBytes(_xmlDemande);

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://" +
_sAdIp + ":" + _sPortHttp + "/demande.xml");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = dataToPost.Length;
Stream myStream = myRequest.GetRequestStream();
myStream.Write(dataToPost, 0, dataToPost.Length);
myStream.Close();
WebResponse myResponse = myRequest.GetResponse();
Stream responseStream = myResponse.GetResponseStream();
ReponseSite rep = new ReponseSite();
XmlSerializer serializer = new XmlSerializer(typeof(ReponseSite));
rep = (ReponseSite)serializer.Deserialize(responseStream );
responseStream.Close();
myResponse.Close();
myStream.Close();

Does somebody have any explanation ?

--
Olivier GIL
LAFON SA
Jun 27 '08 #1
0 1611

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

Similar topics

1
by: Angel | last post by:
I'm trying to connect to a fixed IP address (eg. http://10.60.903.50/TempFile) in order to retrieve one accii line of text in TempFile. I try to read the information with this code: string...
0
by: David Mediavilla | last post by:
I am writing a client for an HTTPS web service using WSE 1.0 but I always get an error like "The underlying connection was closed: An unexpected error occurred on a send." Sometimes the error...
1
by: matt | last post by:
hello, i am using a .NET 1.1 winform to perform webrequests via the System.Net.WebClient class (not a webservice, actually). It uploads values via a POST command & a URL, then receives the html...
0
by: TCook | last post by:
Hello, I am trying to programmatically post (i.e. login, redirect & programmatically submit data) to a website not a webservice. I am receiving the error that is shown in the subject line of...
0
by: pinky | last post by:
Hi all I am having one web service where in at a time of calling one webmethod through client application i am continuously getting following error :- The underlying connection was...
3
by: Rahul Anand | last post by:
As per our requirements we have a web service which internally connects (Simple HTTP Post Request) to a remote server to initiate some work. We are calling the web service method asynchronously...
2
by: Andrew Hunot | last post by:
I have VB code in VS2003 which creates a HttpWebRequest and performs a POST operation to a remote URL (an https site), which runs fine and receives a valid response. However exactly the same...
1
by: Mrozik | last post by:
Hi! I have a problem - after deploying application in client environment, on some client machines occured error. Environment: App server: ASP.NET WebService/Win 2003/ secured SSL (.NET 2.0)...
0
by: =?Utf-8?B?c2dPcmNoaWQ=?= | last post by:
I am creating a Windows forms application which uses WebRequest to download RSS feed. The application generates the following error. "The underlying connection was closed: An unexpected error...
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
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
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,...
0
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...
0
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
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...
0
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,...
0
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...

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.