Click here to Skip to main content
15,887,585 members
Home / Discussions / C#
   

C#

 
GeneralRe: programming ideas Pin
PIEBALDconsult28-Mar-13 10:14
mvePIEBALDconsult28-Mar-13 10:14 
AnswerRe: programming ideas Pin
Alan Balkany1-Apr-13 5:08
Alan Balkany1-Apr-13 5:08 
QuestionBoost parralel messaging performance (TPL / Async) Pin
KillerX12328-Mar-13 2:29
KillerX12328-Mar-13 2:29 
QuestionMy issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Tridip Bhattacharjee28-Mar-13 0:31
professionalTridip Bhattacharjee28-Mar-13 0:31 
AnswerRe: My issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Thomas Duwe28-Mar-13 5:26
Thomas Duwe28-Mar-13 5:26 
GeneralRe: My issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Tridip Bhattacharjee30-Mar-13 5:35
professionalTridip Bhattacharjee30-Mar-13 5:35 
GeneralRe: My issue is regarding handling multiple backgroud worker and multiple progressbar Pin
Thomas Duwe1-Apr-13 5:37
Thomas Duwe1-Apr-13 5:37 
QuestionHttpWebRequest and strange networking errors Pin
cjb11028-Mar-13 0:10
cjb11028-Mar-13 0:10 
I've got the following code that did seem to be working successfully: (It's sending a SOAP envelope to a Java web service and receiving a response) EndPoint is just a string property containing the URL and path to the WebService, Response is a HttpWebResponse property, that other classes use to process the response SOAP.

C#
//create the request
HttpWebRequest req = (HttpWebRequest) WebRequest.CreateDefault(new Uri(EndPoint));
//and request header info
req.ContentType = "text/xml; charset=utf-8";
req.Method = "POST";
req.Accept = "text/xml";
req.KeepAlive = false;
req.Timeout = Timeout;
req.Proxy = WebRequest.GetSystemWebProxy();

req.Headers.Add("SOAPAction", EndPoint);

//write the SOAP Message to the request
using (StreamWriter stm = new StreamWriter(req.GetRequestStream(), Encoding.UTF8))
{
    stm.Write(soapRequest.ToString(SaveOptions.DisableFormatting)); //remove the formatting from the passed XML.
    stm.Flush();
}

Response = null;
try
{
    //get the response
    Response = ((HttpWebResponse) req.GetResponse());
    //read the raw response into ResponseString
    using (StreamReader reader = new StreamReader(Response.GetResponseStream(), Encoding.UTF8))
        ResponseString = reader.ReadToEnd();
}
catch (WebException we)
{
    throw new ApplicationException("A web exception occurred in calling Transact OUG!\r\n" + we.Message, we);
}
catch (Exception e)
{
    throw new ApplicationException("A general exception occurred when calling Transact OUG!\r\n" + e.Message, e);
}
finally
{
    if (Response != null)
        Response.Close();

    req = null;
}


Now I'm not sure what's really changed but I'm getting really odd errors like 'An operation was attempted on something that is not a socket', now I think this might be threading related. As I'm seeing the very first time it returns a timeout, its only the second attempts that I get the odder errors.

As I said this code was working fine when it was called via a single Window WPF app, I've since changed the app to be two hosted UserControls. These don't interact and both have separate ViewModels, but they do both call this method at some point (not simultaneously though).

So my question is have I made some silly mistakes in the above code? Is there anything I should be aware of?
QuestionHow to enlarge the recording voice Pin
Star.jon27-Mar-13 22:46
Star.jon27-Mar-13 22:46 
AnswerRe: How to enlarge the recording voice Pin
Bernhard Hiller27-Mar-13 23:01
Bernhard Hiller27-Mar-13 23:01 
GeneralRe: How to enlarge the recording voice Pin
Star.jon27-Mar-13 23:05
Star.jon27-Mar-13 23:05 
GeneralRe: How to enlarge the recording voice Pin
Dave Kreskowiak28-Mar-13 2:00
mveDave Kreskowiak28-Mar-13 2:00 
Questionerror in crystal reports Pin
User349027-Mar-13 13:36
User349027-Mar-13 13:36 
AnswerRe: error in crystal reports Pin
Abhinav S27-Mar-13 17:58
Abhinav S27-Mar-13 17:58 
AnswerRe: error in crystal reports Pin
V.27-Mar-13 22:21
professionalV.27-Mar-13 22:21 
GeneralRe: error in crystal reports Pin
User349028-Mar-13 7:49
User349028-Mar-13 7:49 
GeneralRe: error in crystal reports Pin
V.28-Mar-13 8:19
professionalV.28-Mar-13 8:19 
QuestionHow to Async download multiple files using webclient simultaneously? Pin
Tridip Bhattacharjee27-Mar-13 8:01
professionalTridip Bhattacharjee27-Mar-13 8:01 
QuestionScreenshots -> Video file Pin
ADASD33333227-Mar-13 4:06
ADASD33333227-Mar-13 4:06 
AnswerRe: Screenshots -> Video file Pin
Abhinav S29-Mar-13 4:00
Abhinav S29-Mar-13 4:00 
QuestionSaving Screensaver in C# Pin
greylakota27-Mar-13 3:34
greylakota27-Mar-13 3:34 
QuestionRe: Saving Screensaver in C# Pin
Richard MacCutchan27-Mar-13 3:56
mveRichard MacCutchan27-Mar-13 3:56 
AnswerRe: Saving Screensaver in C# Pin
Dave Kreskowiak27-Mar-13 4:05
mveDave Kreskowiak27-Mar-13 4:05 
GeneralRe: Saving Screensaver in C# Pin
Richard MacCutchan27-Mar-13 5:04
mveRichard MacCutchan27-Mar-13 5:04 
QuestionC# progress failed! Pin
ccahe27-Mar-13 2:37
ccahe27-Mar-13 2:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.