Click here to Skip to main content
15,905,776 members
Home / Discussions / C#
   

C#

 
AnswerRe: Query execution problen in C# program Pin
dan!sh 31-Aug-09 22:33
professional dan!sh 31-Aug-09 22:33 
AnswerRe: Query execution problen in C# program Pin
Tamimi - Code31-Aug-09 22:39
Tamimi - Code31-Aug-09 22:39 
AnswerRe: Query execution problen in C# program Pin
Jacobb Michael31-Aug-09 23:17
Jacobb Michael31-Aug-09 23:17 
AnswerRe: Query execution problen in C# program Pin
seoamitk1-Sep-09 23:37
seoamitk1-Sep-09 23:37 
QuestionHow to connect to remote sql server 2000 in Windows Services created in C# Pin
Rajesh Koriya31-Aug-09 21:56
Rajesh Koriya31-Aug-09 21:56 
AnswerRe: How to connect to remote sql server 2000 in Windows Services created in C# Pin
Tamer Oz31-Aug-09 22:31
Tamer Oz31-Aug-09 22:31 
AnswerRe: How to connect to remote sql server 2000 in Windows Services created in C# Pin
mbhosle31-Aug-09 23:08
mbhosle31-Aug-09 23:08 
QuestionStart a Service after install it ? Pin
Mohammad Dayyan31-Aug-09 21:36
Mohammad Dayyan31-Aug-09 21:36 
AnswerRe: Start a Service after install it ? Pin
Tamer Oz31-Aug-09 22:41
Tamer Oz31-Aug-09 22:41 
GeneralRe: Start a Service after install it ? Pin
Mohammad Dayyan1-Sep-09 0:46
Mohammad Dayyan1-Sep-09 0:46 
QuestionHow to stop code generator in designer in this case Pin
vql31-Aug-09 21:28
vql31-Aug-09 21:28 
QuestionHow to show a form from windows service? Pin
Tridip Bhattacharjee31-Aug-09 21:28
professionalTridip Bhattacharjee31-Aug-09 21:28 
AnswerRe: How to show a form from windows service? Pin
Vimalsoft(Pty) Ltd31-Aug-09 21:31
professionalVimalsoft(Pty) Ltd31-Aug-09 21:31 
AnswerRe: How to show a form from windows service? Pin
Hristo-Bojilov31-Aug-09 22:04
Hristo-Bojilov31-Aug-09 22:04 
AnswerRe: How to show a form from windows service? Pin
Tamer Oz31-Aug-09 22:05
Tamer Oz31-Aug-09 22:05 
QuestionCheck Box Click Event Pin
Saiyed Alam31-Aug-09 20:20
Saiyed Alam31-Aug-09 20:20 
AnswerRe: Check Box Click Event Pin
dan!sh 31-Aug-09 22:31
professional dan!sh 31-Aug-09 22:31 
Questioncreating word document using c# Pin
Swetha Srinivasan31-Aug-09 20:16
Swetha Srinivasan31-Aug-09 20:16 
AnswerRe: creating word document using c# Pin
Christian Graus31-Aug-09 20:36
protectorChristian Graus31-Aug-09 20:36 
GeneralRe: creating word document using c# Pin
Swetha Srinivasan31-Aug-09 23:20
Swetha Srinivasan31-Aug-09 23:20 
AnswerRe: creating word document using c# Pin
stancrm31-Aug-09 20:38
stancrm31-Aug-09 20:38 
QuestionWCF - HTTP Post The remote server returned an error: (400) Bad Request Pin
senthilkamal31-Aug-09 19:52
senthilkamal31-Aug-09 19:52 
I am getting the below error
WCF - HTTP Post The remote server returned an error: (400) Bad Request

client & sever code below
--------------------------------------------
ServiceContract]
[WebInvoke(UriTemplate = "", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")]
Stream SavePerson(Stream input);


-----------------------------

public Stream SavePerson(Stream input)
{


StreamReader streamReader = new StreamReader(input);
string rawString = streamReader.ReadToEnd();
streamReader.Dispose();

// try to store it in xml file
// I want to store the input stream to xml file

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(rawString);

xmlDoc.Save("D:\\a.xml");

//

Encoding encoding = Encoding.GetEncoding("ISO-8859-1");
WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
byte[] returnBytes = encoding.GetBytes(rawString);
return new MemoryStream(returnBytes);
}




-------------------------

Client Post


string postData = GetXmlString("d:\\test\\dirdownload.xml"); // user function

WebRequest request = WebRequest.Create("http://abc.xyv.com/mytest/myservice.svc");

// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.

byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Response.Write (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Response.Write(responseFromServer);
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();

---------------------------------------------------------

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(rawString);

xmlDoc.Save("D:\\a.xml");

how to save the request input stream to xml file ?

Please advise
AnswerRe: WCF - HTTP Post The remote server returned an error: (400) Bad Request Pin
Vimalsoft(Pty) Ltd31-Aug-09 21:32
professionalVimalsoft(Pty) Ltd31-Aug-09 21:32 
QuestionWebservices error Pin
sevag.m31-Aug-09 19:26
sevag.m31-Aug-09 19:26 
AnswerRe: Urgent need help :) Webservices Pin
Mycroft Holmes31-Aug-09 19:31
professionalMycroft Holmes31-Aug-09 19:31 

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.