Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I have a problem that I seem unable to solve. Since I cannot find anything on it on the web I assume it's either incredibly stupid, or rather unique.

I have a WCF service that works well. It creates an XMLDocument and return doc.InnerXML. I debbuged its contents, this is 100% correct XML.

But.

If I call the service from a browser (or directly call the service from code) I get something extra that I did not expect, or can get rid off:

C#
<?xml version="1.0" encoding="UTF-8"?>
<string><tblPatientCollection><tblPatient FirstName="E.M.J."><PatientId>7</PatientId><decimal>1,2</decimal></tblPatient></tblPatientCollection></string>


Notice the
<string>
at the beginning and the closing string at the end? The doc itself does not contain that, as I can see when I debug the code.

Could it be my config? Something else?

XML
<system.serviceModel>
   <services>
     <service behaviorConfiguration="ServiceBehavior" name="iOSService.TheService">
       <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="iOSService.TheImplementation" />
     </service>
   </services>
   <behaviors>
     <serviceBehaviors>
       <behavior name="ServiceBehavior">
         <serviceMetadata httpGetEnabled="True" />
         <serviceDebug includeExceptionDetailInFaults="True"/>
       </behavior>
     </serviceBehaviors>
     <endpointBehaviors>
       <behavior name="web">
         <webHttp defaultOutgoingResponseFormat="Xml" defaultBodyStyle="Bare" helpEnabled="False" />
       </behavior>
     </endpointBehaviors>
   </behaviors>
   <serviceHostingEnvironment multipleSiteBindingsEnabled="True" />
 </system.serviceModel>


Help would be very much appreciated!

Thx, Michel.
Posted
Updated 11-Jun-13 10:08am
v7
Comments
[no name] 11-Jun-13 15:40pm    
No one able to help? I am apparantly not able to solve it, already spend nine hours on it...
Sergey Alexandrovich Kryukov 11-Jun-13 16:09pm    
It looks really weird and frustrating, but I cannot imagine any resolution without having more information. I understand that showing all of your code could be impossible, and just a short fragment would hardly show the cause of the problem. I think you should concentrate on isolation of the problem, trying to reproduce it on as small test project as possible. Make some suggestion on where the problem could be (perhaps only XML manipulation, without any services, to start with. Finally, you could end up with a really small project which reproduces the issue.
—SA
[no name] 11-Jun-13 16:14pm    
Thank you Sergey. I have isolated the XML generation. When I debug it in a web-project then doc.innerXML returns the proper XML. Only when the same code executes in the service it starts wrapping it in this string-element. The problem lies - in my opinion - in the generation of XML, but in providing the XML in a service as a string:

(string)getXML(string id)

That code works fine in a web-project, even in Windows Forms. Just not in a svc.
[no name] 11-Jun-13 16:35pm    
I might be a little bit closer the a solution, althought I don't have it yet. My inner html is returned is encoded HTML: < instead of a opening tag. Don't know yet where that comes from...

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