【发布时间】:2017-03-28 13:35:24
【问题描述】:
我需要调用一个 Web 服务并将 xml 和身份验证数据传递给它。到目前为止,这是我想出的:
var xml ="<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>"
+ "<soapenv:Header/>"
+ "<soapenv:Body>"
+ "..."
+ "</soapenv:Body></soapenv:Envelope>";
var config = {
method: "POST",
url: 'http://....wsdl',
data: xml
};
$http(config).
then(function (data, status, xhr) {
$scope.MyID = data;
}, function errorCallback(xhr) {
//print error to console.
console.log(xhr.responseText);
});
我需要弄清楚如何传递用户名和密码。而且上面也给了我一个错误:
XMLHttpRequest 无法加载 http://....wsdl。对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。 Origin 'http://localhost:' 因此不允许访问。
奇怪的是,当我以同样的方式从 .NET 调用服务时,access-control-allow-origin 没有问题
【问题讨论】: