[Mono-list] WCF/JSON POST get error 415, expected content-type application/xml not application/json

Iain Mcleod mcleodia at gmail.com
Sat Apr 17 21:46:22 EDT 2010


Thanks for your response Robert.

Sorry, but that didn't quite fix my problem.  WebScriptEnablingBehavior also
worked - albeit with a slightly different json response format - when I
tried it in .NET, but I'm afraid I've tried every every possible combination
of WebHttpBehavior and WebScriptEnablingBehavior tonight and nothing has
worked for me in Mono.

WebScriptEnablingBehavior might have been a good workaround for what I still
believe is an issue with content type detection within WebHttpBehavior but
unfortunately, it brought up a new problem.
Brief explanation: I am also using an HttpListener to run a webserver to
serve my client side html/js.  (In otherwords, I serve my initial client
files from an HttpListener on one port and run my wcf services on another. 
My HttpListener also proxies for the wcf service requests to get around same
origin policy on the browser.)

However the really odd thing that I noticed is that when I use
WebScriptEnablingBehavior on my services ***even when running these on a
different port from the HttpListener webserver mentioned above*** it causes
the HttpListener (my webserver/json proxy server) to hang and fail to
process any requests at all.  No exceptions generated, just nothing getting
through at all on the call to BeginGetContext.  So my client cannot load its
files at all. That's really strange behaviour as I wouldn't have thought
that servers on a different port would have been able to interfere with each
other at all.
Again, this issue appears to be confined to Mono as it all works fine when I
run it in .NET.

(Sidenote: I had originally used a WebHttpBehavior to serve my client files
too, using a wcf service method with UriTemplate = "*" and return type
Stream.  However I discovered that mono appears - I believe - to be
serializing that Stream with datacontractserializer instead of writing back
the raw message contained withing the stream.  This is a separate issue, but
probably worth mentioning while I'm on the forums.)

Do you or anyone else have any other suggestions as to what I should do to
get json working?  
Getting rid of the HttpListener altogether and running everything through
wcf like I originally did would be my preferred choice, but I suspect the
Stream issue I mention above precludes that possibility.

If not, I'll have to fall back to POX or SOAP for my comms which would be
rather painful :(

Many thanks once again for your suggestion though.  It was definitely worth
a shot...

Regards
Iain

-- 
View this message in context: http://n4.nabble.com/WCF-JSON-POST-get-error-415-expected-content-type-application-xml-not-application-json-tp2013204p2014596.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list