0
我被转移到肥皂Web服务ver 3.5
。发布请求正常工作.net 4.5v。不过,虽然数据发布到服务,我会收到错误:如何从angularjs发布到soap web服务?
在浏览器
Error: OPTIONS http://localhost/webserv/WebService1.asmx/HelloWorld
XMLHttpRequest cannot load http://localhost/webserv/WebService1.asmx/HelloWorld. Invalid HTTP status code 500
,当我看到的细节它显示这个
System.InvalidOperationException: Missing parameter: obj.
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
我的实现是:
$http({
method: 'POST',
url: 'http://localhost/webserv/WebService1.asmx/HelloWorld',
datatype: 'json',
data:JSON.stringify({obj:details})
contentType: "application/json; charset=utf-8"
}).success(function(data,status, headers, config){
if(status == '200'){
alert(data.d);
}
}).error(function(data,status, headers, config){});
并服务于
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(Details obj)
{
return JsonConvert.SerializeObject((new Helper()).GetDetails(obj.Id);
}
web配置中:
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
我怎么会是能够调用POST请求,并得到导致JSON格式?