하이브리드 앱을 개발 중입니다. 내 데이터를 가져 오려고 시도했을 때 xml 형식으로 데이터 URL이 있습니다. 문제 해결을 도와주세요.아약스를 사용하여 XML 데이터를 가져올 때 교차 원점 요청이 차단됨
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Access-Control-Allow-Origin" content="*">
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var allowCrossDomain = function(req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', 'http://localhost');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);
// Pass to next layer of middleware
next();
};
var webServiceURL = 'http://wetexmobapp.ourdemopage.com/webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll';
var soapMessage = '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><GetAllCategoryFamilies xmlns="http://tempuri.org/" /></soap12:Body></soap12:Envelope';
function CallService()
{
$.ajax({
url: webServiceURL,
type: "POST",
dataType: "xml",
data: soapMessage,
processData: false,
contentType: "text/xml; charset=\"utf-8\"",
success: OnSuccess,
error: OnError
});
return false;
}
function OnSuccess(data, status)
{
alert(data.d);
}
function OnError(request, status, error)
{
alert('error');
}
$(document).ready(function() {
jQuery.support.cors = true;
});
</script>
<form method="post" action="">
<div>
<input type="button" value="Call Web Service" onclick="CallService(); return false;" />
</div>
</form>
</body>
</html>
getFloorPlanAll
Click here for a complete list of operations.
getWebsite_FloorPlanAll
Test
To test the operation using the HTTP POST protocol, click the 'Invoke' button.
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
POST /webService/getFloorPlanAll.asmx HTTP/1.1
Host: wetexmobapp.ourdemopage.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://app.wetex.ae/getWebsite_FloorPlanAll"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getWebsite_FloorPlanAll xmlns="http://app.wetex.ae/" />
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getWebsite_FloorPlanAllResponse xmlns="http://app.wetex.ae/">
<getWebsite_FloorPlanAllResult>xml</getWebsite_FloorPlanAllResult>
</getWebsite_FloorPlanAllResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.
POST /webService/getFloorPlanAll.asmx HTTP/1.1
Host: wetexmobapp.ourdemopage.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<getWebsite_FloorPlanAll xmlns="http://app.wetex.ae/" />
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<getWebsite_FloorPlanAllResponse xmlns="http://app.wetex.ae/">
<getWebsite_FloorPlanAllResult>xml</getWebsite_FloorPlanAllResult>
</getWebsite_FloorPlanAllResponse>
</soap12:Body>
</soap12:Envelope>
HTTP GET
The following is a sample HTTP GET request and response. The placeholders shown need to be replaced with actual values.
GET /webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll? HTTP/1.1
Host: wetexmobapp.ourdemopage.com
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0"?>
xml
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.
POST /webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll HTTP/1.1
Host: wetexmobapp.ourdemopage.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0"?>
xml
이가 // @가되지 않습니다 sourceMappingURL의 프라그 마를를 나타 내기 위해 사용 오류 문
입니다
<DocumentElement><FloorPlan><Id>1</Id><FloorPlan_Url>http://wetexmobapp.ourdemopage.com/uploads/documents/floorPlan/WETEX-Floorplan-2016-07-13.pdf</FloorPlan_Url><PublishedDateTime>7/11/2016 12:00:00 AM</PublishedDateTime><CreatedDatetime>7/13/2016 5:34:00 AM</CreatedDatetime><Status>Active</Status></FloorPlan></DocumentElement>
내부 데이터를 호출. // 대신 # 사용 jquery.min.js : 1 : 0 HTML 문서의 문자 인코딩이 선언되지 않았습니다. 문서에 US-ASCII 범위 밖의 문자가 포함되어 있으면 문서가 일부 브라우저 구성에서 깨진 텍스트로 렌더링됩니다. 페이지의 문자 인코딩은 문서 또는 전송 프로토콜에서 선언해야합니다. text.html 교차 원점 요청이 차단됨 : 동일 원점 정책으로 원격 리소스를 읽는 것이 허용되지 않습니다 (http://wetexmobapp.ourdemopage.com/webService/getFloorPlanAll.asmx/getWebsite_FloorPlanAll). (이유 : CORS 헤더 'Access-Control-Allow-Origin'누락).
나는 Access Control-Allow-Origin 문제를 해결하기 위해 여러 단계를 시도했지만 여전히 동일한 문제를 보여줍니다.
이 'http : // wetexmobapp.ourdemopage.com /'도메인에서 또는 다른 것으로부터 ajax 호출을 요청하고 있습니까? –
예. 우리는 이미이 링크에서 xml 데이터를 가지고 있습니다.이 링크에서 데이터를 가져오고 싶습니다. –
여기에 표시되는 html 코드는 http : // wetexmobapp.ourdemopage.com /'에 있습니까? –