I use the following jQuery \ JavaScript code to communicate with WCF 4 REST service.
<script> var serviceUrl = "http://services.xiine.com/Xiine/Live/AccountService/rest/json/Login"; var userInfo = { "IsNotEncrypted":true, "Password":null, "UserName":null }; var loginSuccess = function(data, textStatus, jqXHR){ console.log("yay"); }; var loginError = function(){ console.log("oh no"); }; $.post(serviceUrl , userInfo, loginSuccess); $.post(serviceUrl , loginSuccess); </script>
I am trying to establish why the service will correctly return a false value when I do not transfer user data:
$.post(serviceUrl , loginSuccess);
Unlike when I pass user data, at that moment it causes a POST 400 error (failed request).
$.post(serviceUrl , userInfo, loginSuccess);
I am sure this is due to the way the JSON object, userInfo, is constructed or interpreted, and I can post Fiddler 2 or WireShark dumps if that helps. Just let me know ...
I do not have access to change the WCF service, so I hope there is something I can do on my part to make this work.
Thanks!
Edit
I got a little more information ... Apparently, the problem is that the server is responding with the following error:
The server encountered an error processing the request. Exception message: Incoming message has an unexpected Raw message format. The expected message formats for the operation are "Xml", "Json". This may be due to the fact that WebContentTypeMapper was not configured to bind. See the documentation> WebContentTypeMapper for more details. '. See Server Logs for more information. Exception stack trace:
in System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest (Message message, Object [] parameters) in System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest (Message message, Object [] parameters) in System.ServiceModel.DispatcherFormatter. Parameters DeserializeRequest (Message message, Object []) in System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs (MessageRpc & rpc) in System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin (MessageRpc & rpc) in System.ServiceMatchPermodeMatchPerviceMatchPerviceMatchPerviceMatchPerviceMatchPerviceMatchPerviceMatchPerviceMatchPerMentPerMentPerMentPerPerviceMatchPerviceMePermPerMentPerMentPervicePervice (MessageRpc & rpc) in System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41 (MessageRpc & rpc) in System.ServiceModel.Dispatcher.MessageRpc.Process (Boolean isOperationContextSet)
So, I think I need to figure out how to make the object go through the wire as a JSON object using the JQuery.post () method.
Further information --- Again ...
ok ... No app.config or web.config as such.
Here's what I can get before contracts and code, and what not.
[ServiceContract] public interface IAccount { [OperationContract] bool Login(UserInformation user); } [ServiceBehavior(IncludeExceptionDetailInFaults = true)] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class AccountService : IAccount { public bool Login(UserInformation user) {