Returning SoapFault as Envelope

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi All,

I have two web services, where first application receives a request and
sends the request to the second web service. Based on the response
received from second application, the first application, responds to
the client.

It works fine for the normal cases. But when i wanted to check the
error messages, it the client application receives Error 404. But when
the same error is returned from the second application using "return "
statement, the client receives it as "The remote server returned an
error: (500) Internal Server Error."

Both the first app and client use similar codes, but why the second
application receives it with Error code 500?

Here is the code,

try
{

string strg = envelope.InnerXml;

req.Method = "POST";

req.KeepAlive = true;
req.ContentType = "text/xml";
byte[] bytes =
System.Text.Encoding.UTF8.GetBytes(strg);
req.ContentLength = bytes.Length;
req.Headers.Add("SOAPAction: mySoapAction");

System.IO.Stream st = req.GetRequestStream();
st.Write(bytes, 0, bytes.Length);
st.Close();

HttpWebResponse res =
(HttpWebResponse)req.GetResponse();

System.IO.Stream st1 = res.GetResponseStream();
System.IO.StreamReader sr = new
System.IO.StreamReader(st1, System.Text.Encoding.UTF8);
string txt = sr.ReadToEnd();
SoapEnvelope response = new SoapEnvelope();
response.LoadXml(txt);
//this.txtSOAPResponse.Text = txt;
res.Close();
Console.WriteLine(response.Envelope.OuterXml);
return true;
}
catch (WebException exp)
{
Console.WriteLine(exp.Message);
Console.WriteLine(exp.StackTrace);
return false;
}
catch (Exception exp)
{
Console.WriteLine(exp.Message);
Console.WriteLine(exp.StackTrace);
return false;
}


Any help?

.



Relevant Pages

  • Re: Exchange Web Services Problem
    ... It is a simple sample from the book "Inside Microsoft Exchange Server 2007 Web Services". ... StringBuilder request = new StringBuilder; ... string userName, ... HttpWebResponse response; ...
    (microsoft.public.exchange.development)
  • Re: Need to share data asynchronously between ASP.NET and Legacy S
    ... Otherise I would use the client side async web sevice stuff to some ... > would get the results of a specific request based on the request ... >> callbacks to communicate back to clients. ... >> very nicely and is fully based on Web Services and is transport agnostic. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: New to Java - Guidance Required
    ... All of these do essentially the same thing, communicate a request from the client to a service asking it to do something for you. ... I'm currently working on a project where I need a client to be able to send a request and get a response. ... In yet another instance I needed to have a continuous two way dialogue between an applet and the server from which it came - in this particular case I had to use sockets. ...
    (comp.lang.java)
  • Re: Best web server interface to D3
    ... I knew I would catch a flame from my request:) ... I have a client who has happily been ... D3, anything can connect into the middle-tier like web services, etc. ... This was written as a client rather than as a server because of often ...
    (comp.databases.pick)
  • Re: simple mock web service
    ... not able to find the end of the request - and I don't have any control over what the request might be. ... What it is is that there are many client components, each wrapped in a JUnit test; but the real web services are live, and contain data which anyone can alter. ... The urls to the web services are soft, and so as the tests run during the build, the clients are pointed at the mock web services. ...
    (comp.lang.java.help)