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

  • Home
  • SEARCH
  • 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 8436315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:08:51+00:00 2026-06-10T07:08:51+00:00

My RESTful WCF service accepts XML request bodies from clients, most clients are PHP

  • 0

My RESTful WCF service accepts XML request bodies from clients, most clients are PHP applications.

The PHP applications encode their requests with htmlentities(), which is placed within the element tags. For example, a request to add a new user-account might look like this:

$body = "<user>
    <userName>" . htmlentities( $userName ) . "</userName>
</user>"

The system works fine, there have been zero errors with it, until today.

I looked through the logs and saw this request had failed:

<user>
    <userName>&egrave;eesu</userName>
</user>

with the following exceptions:

InvalidOperationException: “There is an error in XML document (4, 12).”
XmlException: “Character reference not valid. Line 4, position 12.”

(where line 4, position 12, refers to the <userName> element’s InnerText (i.e. the string &egrave;eesu;).

&egrave; is a valid HTML entity, but I understand that XML only defines a minimum set of character references (&amp;, &lt;, etc), and that XML expects all other characters to be in their document encoding representation instead, and so will reject things like &egrave;.

Can someone confirm this is the case? And if so, how can I get PHP to only encode XML-specific entities instead of HTML entities?

  • 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-10T07:08:53+00:00Added an answer on June 10, 2026 at 7:08 am

    I use htmlspecialchars( $userName, ENT_XML1 ) instead, which only converts a minimum of characters to entities without unnecessarily encoding them.

    @Jordan’s str_replace function does the same thing, however when you benchmark it it’s slower because htmlspecialchars is a native function.

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

Sidebar

Related Questions

My PHP project works by grabbing data from a WCF REStful web service with
I am trying to call a WCF RESTful service from jQuery. I am using
One test webserver, with the following applications service.ganymedes.com:8008 - WCF RESTful service, basically the
I have a RESTful WCF web service that processes huge XML files that are
I am trying to make a post request to my restful WCF service. The
I have a requirement to access the HttpContext.Current from with-in a RESTful WCF service.
I'm trying to contact a RESTful WCF POST web service from an android client
I am developing a RESTful WCF service which I then want to consume from
Hi I am trying to play video from my restful wcf service on mobile
I need to be able to pass XML to a RESTFul WCF service as

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.