Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8733165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:35:38+00:00 2026-06-13T09:35:38+00:00

I have a WCF RESTful service that is supposed to return a name and

  • 0

I have a WCF RESTful service that is supposed to return a name and surname of a customer as a XML response, the service is defined as indicated below

[OperationContract]
    [WebInvoke(Method = "POST",
        RequestFormat = WebMessageFormat.Xml,
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "/GetNameAndSurname")]
    string GetNameAndSurname();

The problem I’m experiencing is that the XML response that is returned was not in normal XML as expected, for example

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
 &lt;Customer;&#xD;
  &lt;Name&gt;Andre&lt;/Name&gt;&#xD;
  &lt;SurnameName&gt;Lombaard&lt;/SurnameName&gt;&#xD;
 &gt;
</string>

I’m not sure if it is the service returning the response this way or if it is the way I’m reading the data, just for informational purposes I included the code I use to read the response below,

var request = HttpWebRequest.Create(url);
request.Method = "POST";
request.Timeout = 2 * 60 * 1000;
byte[] byteArray = Encoding.UTF8.GetBytes(xml);
request.ContentType = "text/xml";
request.ContentLength = byteArray.Length;
var dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
var response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream, Encoding.UTF8);
dataStream.Flush();
var results = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();

How do I get normal XML without having to perform various replacements on the characters received in the response.

At the moment I replace the characters with the code below. This is not ideal

results = results.Replace("</string>", String.Empty);
results = results.Replace("&lt;", "<");
results = results.Replace("&gt;&#xD;", ">");
results = results.Replace("&gt;", ">");
results = Regex.Replace(results, "<string .*?\\>", String.Empty);                
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:35:40+00:00Added an answer on June 13, 2026 at 9:35 am

    The service is doing exactly what it says it’s doing – it’s returning an XML-serialized string. I’m guessing the service code does some serialization of the Customer object into a string before returning that. If you want the return type to be the Customer, have the service method return a Customer object instead of a string, and you should be good. It will be smart enough to serialize your Customer into the appropriate XML string.

    For testing your data out, you can use something like Fiddler to watch the raw HTTP request and response, so you can be sure exactly what’s being requested and responded – but my guess is that it is coming back exactly as you’re showing.

    Definitely don’t do that last thing with the string replaces. If you ever do need to do this, then look into XML decoding, possibly with one of the solutions found here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RESTful WCF service that can return XML, JSON, or JSONP, depending
I have a RESTful WCF web service that processes huge XML files that are
I have a very simple (new to this) RESTful WCF service that uses a
I have WCF endpoint exposed as defined bellow, <service name=MyApp.Server.Endpoint.Orange behaviorConfiguration=MyTio.Server.Endpoint.OrangeBehavior> <endpoint address= binding=basicHttpBinding
I have a WCF restful service that I'm trying to upload an image to.
I have a wcf restful service with a operation contract that contains two values
I have an old WCF 3.5 RESTful service that was at: http://www.mydomain.com/rest/Service.svc I have
I have a RESTful service that I am developing in WCF . I am
I have a RESTful WCF service that exposes a method that takes in an
I've been trying to do a simple restful wcf service that will return JSON.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.