を受け入れされていない私は、WCF 4 RESTサービスと通信するには、以下のjQueryの\ JavaScriptコードを使用しています。は、WCFと通信するためのjQueryのポストを取得しようとするが、JSONデータは
<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>
私はそれは私がユーザーデータを渡さない場合に、サービスが正しく偽の値を返すことである理由を確立しようとしています:
$.post(serviceUrl , loginSuccess);
私はユーザーデータを渡す行うときとは対照的に、その時点でPOST 400(Bad Request)エラーが発生します。
$.post(serviceUrl , userInfo, loginSuccess);
私はそれがJSONオブジェクト、のUserInfoは、内蔵されたり解釈されているどのように関係していると確信している、と私はバイオリン弾き2投稿できるか、それが役立つ場合WireSharkのは、ダンプします。ただ、私は本当にサービスのWCF側の変更へのアクセス権を持っていないので、うまくいけば、私はこの仕事をするために私の側で行うことができる何かがある...
を教えてください。
ありがとうございます!
編集私は少しより多くの情報を得ました
...どうやら、問題は、サーバーが次のエラーで応答していることである。
The server encountered an error processing the request. The exception message is 'The incoming message >has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', >'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the >documentation of WebContentTypeMapper for more details.'. See server logs for more details. The >exception stack trace is:
at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
は、だから私は、私が把握する必要があり考えていますオブジェクトをJQuery.post()メソッドを介してJSONオブジェクトとしてワイヤに渡す方法を説明します。
詳しい情報---再び...
OK ...何のapp.configファイルまたはweb.configファイルには、などがありません。
私はここまで、私は契約やコード、何を得ることができます。
[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)
{
//stuff...
}
}
[DataContract]
public class UserInformation
{
[DataMember(IsRequired = true)]
public string UserName;
[DataMember(IsRequired = true)]
public string Password;
[DataMember(IsRequired = true)]
public bool IsNotEncrypted;
}
public interface IUserInformation
{
UserInformation UserInformation { get; set; }
}
あなたのWCFサービスの設定を投稿してください。 –
残念ながら、私はそれにアクセスできません... – Joe