Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For testing I have an app that is sending a request to a WCF service like this
C#
Uri uri = host.StartsWith("http:")
                          ? new Uri(host)
                          : new UriBuilder("http://", host, 80, "servername").Uri;


            var request = WebRequest.Create(uri);
            request.ContentType = "application/soap+xml; charset=utf-8";
            request.Method = "POST";
            using (var stream = request.GetRequestStream())
            {
                stream.Write(Encoding.UTF8.GetBytes(xml), 0, xml.Length);
            }
#if true
            try
            {
                using (var response = request.GetResponse() as HttpWebResponse)
                using (var responseStream = response.GetResponseStream())
                using (var sr = new StreamReader(responseStream))
                {
                    return sr.ReadToEnd();
                }

            }
            catch (Exception ex)
            {
                return String.Format("<exception>{0}<stacktrace>{1}</stacktrace></exception>", ex.Message, ex.StackTrace);
            }


how can I take the response this function returns and deserialize it into an object ?
Posted

1 solution

I'd suggest either [in order of preference]:

a) Generating a proxy from the MEX
b) Including the Data and Service Contract interfaces in from the WCF service in the client.

Otherwise you are in for a world of usually needless pain. Is there any reason why you cannot do (a) or (b)?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900