Я потратил много часов на чтение форм по всему миру. Кажется, что ничего не работает. У меня есть простая служба WCF с поддержкой ajax. Я могу вызвать метод Read, и он работает, поиск является проблемой.WCF метод не принимается POST
Вот мой web.config
:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="CompanyNotificationService.NotificationManager.MessagesAspNetAjaxBehavior">
<webHttp defaultOutgoingResponseFormat="Json"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="CompanyNotificationService.NotificationManager.Messages">
<endpoint address="" behaviorConfiguration="CompanyNotificationService.NotificationManager.MessagesAspNetAjaxBehavior"
binding="webHttpBinding" contract="CompanyNotificationService.NotificationManager.Messages" bindingConfiguration="defaultRestJson" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="defaultRestJson" crossDomainScriptAccessEnabled="false">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
И моя служба
[ServiceContract(Namespace = "NotificationManager.Messages")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true)]
public class Messages
{
[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
public List<Message> Read()
{
Notifications notifications = Notifications.Get();
return notifications.Messages;
}
[OperationContract, WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public void Create(Message models)
{
var i = 1; //I break here, just to inspect everything...not finished
}
[DataContract]
public class Message : IMessage
{
[DataMember]
public string ID { get; set; }
[DataMember]
public string Text { get; set; }
[DataMember]
public DateTime StartDate { get; set; }
[DataMember]
public DateTime ResumeDate { get; set; }
[DataMember]
public string CreatedUser { get; set; }
}
И стельку Информация
POST http://localhost:64394/NotificationManager/Messages.svc/Create HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/json
X-Requested-With: XMLHttpRequest
Referer: http://localhost:64394/NotificationManager/Manage.aspx
Accept-Language: en-US
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:64394
Content-Length: 1130
DNT: 1
Connection: Keep-Alive
Pragma: no-cache
Cookie: __AntiXsrfToken=82ba422caa20485690cc905fe6a4b022
HTTP/1.1 400 Bad Request
И, наконец, исключение
Сервер обнаружил ошибку при обработке запроса.
Сообщение об исключении: «Форматирование выдало исключение при попытке десериализации сообщения: Ошибка десериализации тела сообщения запроса для операции« Создать ». Обнаружен неожиданный символ 'm'. '. Подробнее см. Журналы сервера.стека исключений трассировки:
в System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest (сообщение Message, Object [] параметры) .....
о, я почти GOT json from fiddler
models=[{"ID":"1","Text":"here is my message","StartDate":"2013-12-07T06:54:34.396Z","ResumeDate":"2013-12-07T06:54:34.396Z","CreatedUser":"charbaugh"}]
Любая помощь будет замечательной! Я никогда не писал здесь, и я всегда могу быстро найти ответы, но это меня разрушило!