Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML exception reading message body in .NET 4.5 #16

Open
NorthNick opened this issue Oct 24, 2012 · 3 comments
Open

XML exception reading message body in .NET 4.5 #16

NorthNick opened this issue Oct 24, 2012 · 3 comments

Comments

@NorthNick
Copy link

One of our servers was recently upgraded to .NET 4.5 and my .NET 4.0 WcfRestContrib app broke when processing a POST request with a simple text body. The error coming out is:

Error.Message=System.Xml.XmlException%3a+%27Text%27+is+an+invalid+XmlNodeType.
%0d%0a+++at+System.Xml.XmlReader.ReadEndElement()
%0d%0a+++at+WcfRestContrib.ServiceModel.Dispatcher.WebDispatchFormatter.Deserialize(Message+message%2c+WebFormatterFactory+formatterFactory%2c+Object%5b%5d%26+parameters%2c+RequestMessagePartDescription%5b%5d+requestParameters%2c+String+contentType)+in+d%3a%5cTeamCity%5cBuildAgent%5cwork%5cdac2ac50c21c000f%5csrc%5cWcfRestContrib%5cServiceModel%5cDispatcher%5cWebDispatchFormatter.cs%3aline+149
%0d%0a+++at+WcfRestContrib.ServiceModel.Dispatcher.WebDispatchFormatter.DeserializeRequest(Message+message%2c+Object%5b%5d+parameters)+in+d%3a%5cTeamCity%5cBuildAgent%5cwork%5cdac2ac50c21c000f%5csrc%5cWcfRestContrib%5cServiceModel%5cDispatcher%5cWebDispatchFormatter.cs%3aline+73%
0d%0a+++at+System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc%26+rpc)
%0d%0a+++at+System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc%26+rpc)
%0d%0a+++at+System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc%26+rpc)
%0d%0a+++at+System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc%26+rpc)
%0d%0a+++at+System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean+isOperationContextSet)&Error.Status=500

The error is in BInaryBodyReader.cs, at line 15 and the date it's trying to deserialise is a byte stream corresponding to the request body which, for what it's worth, is:

source=TweetDeck&screen%5Fname=d%5Froberts&text=Testing%20Zeitgeist

At this point I'm a bit stuck on how to proceed as I've been unable to find this sort of thing mentioned in any of the .NET 4.5 breaking changes. Any ideas or solutions would be very welcome. Many thanks,

Nick North

PS I am using the WcfRestContrib 1.7.10.0 NuGet package.

PPS I have just realised something else that may be important. I have my own reader for application/x-www-form-encoded data (which this request has as its content type), which is declared with the attributes on the service below. It looks as though my reader is not being invoked.

// Set this as the default MIME type because WCFRestContrib tries to match the entire Content-Type, which includes the boundary string for multipart/form-data
// so cannot be matched, as that is random. We happen to know that anything that is not application/x-www-form-urlencoded is multipart/form-data, so the trick
// works. 
[WebDispatchFormatterConfiguration("multipart/form-data")]
[WebDispatchFormatterMimeType(typeof(FormEncodedFormatter), "application/x-www-form-urlencoded")]
@mikeobrien
Copy link
Owner

I'm not really sure on that, we haven't upgraded yet.

We're actually in the process of migrating off of WCF right now so I'm not
going to be involved much with this project anymore.

@NorthNick
Copy link
Author

I'm sorry to hear you won't be invovled in the project anymore. I'll go and
see if the problem is easy to fix, or if I should bite the bullet and move
to the ASP.NET Web API. i will probably do the latter.

Many thanks for all your work on WcfRestContrib. My REST service would have
been impossible without it, so it has been incrdibly useful to me.

Nick North

On 24 October 2012 15:44, mikeobrien [email protected] wrote:

I'm not really sure on that, we haven't upgraded yet.

We're actually in the process of migrating off of WCF right now so I'm not
going to be involved much with this project anymore.


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-9742010.

@mikeobrien
Copy link
Owner

Yeah, I'm tired of dealing with WCF, especially since there are so many
other better frameworks out there for doing REST. I bet you'll get a lot
more mileage out of the web api.

Glad it helped you out! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants