【发布时间】:2012-10-31 22:07:25
【问题描述】:
这个问题已经在许多帖子中以类似的方式提出,但我没有一个可行的解决方案。
ManagerDiscountService 中的服务端点如下所示:
[ServiceBehavior]
[ServiceContract(Namespace = "Cart")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ManagerDiscountService : CartService
[OperationContract]
// also tried [WebInvoke(RequestFormat=WebMessageFormat.Json)]
// also tried [WebInvoke(RequestFormat=WebMessageFormat.Json, Method="POST")]
public MyObject ToggleMode(string userId, string pwd, string domain)
web.config:
<service name="Cart.ManagerDiscountService">
<endpoint address="" behaviorConfiguration="Item.ItemAspNetAjaxBehavior"
binding="webHttpBinding" bindingConfiguration="wsSecureHttp"
contract="Cart.ManagerDiscountService" />
</service>
<!-- tried adding a similar wsHttp binding since the POST is not SSL, no luck -->
我正在尝试将 userId、pwd 和 domain 发布到此端点,但我看到的只有 500 个。 为什么这种发帖方法不起作用?当我在 Chrome 中调试时,error 始终是$.ajax 中的下一个执行:
params = { "userId": "user", "pwd": "password", "domain": "mydomain" };
$.ajax({
type: "POST",
url: "/Ajax/Cart/ManagerDiscountService.svc/ToggleMode",
dataType: "json",
data: JSON.stringify(params, null, null),
contentType: "application/json; charset=utf-8",
success: function (data) {
// ...
},
error: function() {
// ...
}
});
【问题讨论】:
标签: asp.net ajax json wcf web-services