我需要执行Post请求。当它与终端中的Curl一起工作时,我很难让它在AngularJS中运行。
curl -H ‘Content-type: xml’ -XPOST -d@’xmlDoc.xml’ http://localhost:8080/geoserver/wps
我试过了:
$http({
method: 'POST',
url: 'http://localhost:8080/geoserver/wps/',
data: xmlDoc,
headers: {'Content-Type': 'application/xml'}
}).success(function (data, status, headers, config) {
[...]
}).error(function (data, status, headers, config) {
[...]
});
还有:
$http.post('http://localhost:8080/geoserver/wps', requestXML)
.success(function (data, status, headers, config) {
[...]
}).error(function (data, status, headers, config) {
[...]
});
但反应始终是:
<ows:Exception exceptionCode="NoApplicableCode">
<ows:ExceptionText>org.xmlpull.v1.XmlPullParserException: only whitespace content
allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1)
</ows:ExceptionText>
我是否必须将curl代码写入单独的PHP文件并从angular?
调用它