Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>thanks for taking the time out to answer this. The service works fine, if a client creates a reference to my WCF Service and makes a method call, the appropriate response is sent.</p> <p>I forgot to add, that my client is sends a HTTP Post Request to my WCF Service. The appropriate response is then created and returned to the Client.</p> <p>I can read the HTTP Request, however when i try and access the HTTP response, i get error -<strong><em>"The remote server returned an error: (400) Bad Request"</em></strong></p> <p>The error happens when the code reaches this line:</p> <pre><code> // Get the response. HttpWebResponse response = request.GetResponse() as HttpWebResponse; </code></pre> <p>See code below:</p> <pre><code> private void CreateMessage() { // Create a request using a URL that can receive a post. WebRequest request = WebRequest.Create("http://www.XXXX.com/Feeds"); string postData = "&lt;airport&gt;Heathrow&lt;/airport&gt;"; </code></pre> <p>// user function request.Method = "POST";</p> <pre><code> byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/soap+xml; charset=utf-8"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); // Get the response. HttpWebResponse response = request.GetResponse() as HttpWebResponse; // Display the status. HttpContext.Current.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. HttpContext.Current.Response.Write(responseFromServer); // Clean up the streams. reader.Close(); dataStream.Close(); response.Close(); } </code></pre> <p>regards</p> <p>Kojo</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload