tags:

views:

37

answers:

1

I've set up a basic http WCF Service and my application in IIS is configured to use Windows Authentication.

The bindings therefore have the following security settings:

<security mode="TransportCredentialOnly">
    <transport clientCredentialType="Windows" proxyCredentialType="None" />
    <message clientCredentialType="Certificate"/>
</security>

Each operation contract has the following attribute

[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]

and the service class has the following attribute to allow asp compability

[AspNetCompatibilityRequirements(RequirementsMode = 
                              AspNetCompatibilityRequirementsMode.Allowed)]

The Windows authentication is passed to the WCF service properly, since I can see/generate the WSDL. However, when I call an operation in my WCF service i get the following error:

[FaultException`1: There was an error generating the XML document.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,
                                                        IMessage retMsg) +4767763
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, 
                                                        Int32 type) +1725
   XXXX.Service() +0
   XXXX.Service() +329
   XXXX.Service() +747
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, 
                                                     Object t,EventArgs e) +25
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, 
                                    Boolean includeStagesAfterAsyncPoint) +3048

It's not the first time i see the error There was an error generating the XML document., I want to know what could be the reason for this? Does the Service send the data somewhat encrypted and the client doesn't understand it because it is miss-configured?

+1  A: 

Looks like the you are not handling an exception/Fault in your code, you may want to ensure your serialising the error correctly, using the following

http://blogs.msdn.com/b/pedram/archive/2008/01/25/wcf-error-handling-and-some-best-practices.aspx

I have also found a blog entry from Mike Taulty very good for enableing logging in WCF

http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2005/12/15/5662.aspx

Hope this helps.

Iain
I'll look into this in a bit, thank you very much!
Filip Ekberg
The error seem to be: `"The given assembly name or codebase, 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', was invalid."` even though the file is there. strage.
Filip Ekberg
it maybe that your web.config and your reference DLL may differin the <system.web> <compilation debug="false" strict="false" explicit="true"> <assemblies> <add assembly=" Section
Iain
I actually don't have an assemblies section in the web.config for the service.. hm
Filip Ekberg
last thought is that you maybe caching, a compiled version of the DLL, try deleting the files from the following locationC:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET FilesDo a Solution Clean and Rebuild.
Iain
Thanks a lot, you've saved me a lot of headace! :)
Filip Ekberg