Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
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 
GeneralWebservices Pin
sevag.m31-Aug-09 20:27
sevag.m31-Aug-09 20:27 
Question[Message Deleted] Pin
Swetha Srinivasan31-Aug-09 18:34
Swetha Srinivasan31-Aug-09 18:34 
AnswerRe: Progress Bar in c# Pin
Christian Graus31-Aug-09 18:43
protectorChristian Graus31-Aug-09 18:43 
GeneralRe: Progress Bar in c# Pin
Swetha Srinivasan31-Aug-09 18:45
Swetha Srinivasan31-Aug-09 18:45 
GeneralRe: Progress Bar in c# Pin
Mycroft Holmes31-Aug-09 19:34
professionalMycroft Holmes31-Aug-09 19:34 
GeneralRe: Progress Bar in c# Pin
Swetha Srinivasan31-Aug-09 20:05
Swetha Srinivasan31-Aug-09 20:05 
General[Message Deleted] Pin
Swetha Srinivasan31-Aug-09 20:17
Swetha Srinivasan31-Aug-09 20:17 
GeneralRe: Progress Bar in c# Pin
Christian Graus31-Aug-09 20:37
protectorChristian Graus31-Aug-09 20:37 
Questionhow to disable close button of windows form Pin
Vivek Vijayan31-Aug-09 18:22
Vivek Vijayan31-Aug-09 18:22 
AnswerRe: how to disable close button of windows form Pin
stancrm31-Aug-09 18:42
stancrm31-Aug-09 18:42 
GeneralRe: how to disable close button of windows form Pin
OriginalGriff31-Aug-09 21:48
mveOriginalGriff31-Aug-09 21:48 
AnswerRe: how to disable close button of windows form Pin
wjp_auhtm31-Aug-09 23:28
wjp_auhtm31-Aug-09 23:28 
AnswerRe: how to disable close button of windows form Pin
PIEBALDconsult4-Sep-09 5:34
mvePIEBALDconsult4-Sep-09 5:34 
QuestionConsole.WriteLine(); VS Console.Out.WriteLine(); Pin
Mohammad Dayyan31-Aug-09 16:53
Mohammad Dayyan31-Aug-09 16:53 

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.