도움을 주셔서 감사합니다. 많은 사람들이 이런 종류의 문제가 있다는 것을 알고 있습니다.하지만 해결 방법이 많이 있습니다.오류 SOAP with jQuery
내가 원하는 것은이 간단한 html5 파일에서 보내고받는 것이므로 phonegap을 WebApp로 "번역"할 수 있습니다.
문제는 "No 'Access-Control-Allow-Origin'헤더가 요청 된 리소스에 존재합니다."
은 내가 SOAP 서비스가 그 구조는 다음과 같이 작동합니다
<?xml version='1.0' encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”>
<SOAP-ENV:Body>
<m:Query xmlns:m=”http://www.incits.org/RTLS/">
<QueryName>RTLS_Blinks</QueryName>
<FilterBy>
<RTLSBlinkTime><![CDATA[>2010-12-01T00:00:00Z]]></ RTLSBlinkTime>
<OR/>
<BatteryLow>=true</BatteryLow>
<Blinking>=true</Blinking>
</FilterBy>
<Fields> TagID Location BatteryLow </Fields>
<SortBy>
<Field>TagID</Field>
<Order>asc</Order>
</SortBy>
</m:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
을하고 응답이 같은 여야
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hago pruebas del SOAP de Balmart</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(function() {
$("#btEnviar").click(function() { llamarWebService(); return false;});
});
var soapMessage;
function llamarWebService() {
soapMessage = "<?xml version='1.0'" + ' encoding="utf-8"?>';
soapMessage += '<SOAP-ENV:Envelope ';
soapMessage+= 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
soapMessage += 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ';
soapMessage += 'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">';
soapMessage += "<SOAP-ENV:Body>";
//[Add your xml here]
soapMessage+= '<m:Query xmlns:m="http://www.incits.org/RTLS/">';
soapMessage+= '<QueryName>RTLS_BLinks</QueryName>';
soapMessage+='<FilterBy/>';
soapMessage+='<Fields/>';
soapMessage+='<SortBy><Field>TagID</Field><Order>asc</Order></SortBy>';
soapMessage+= '</m:Query">';
// [End]
soapMessage += "</SOAP-ENV:Body>";
soapMessage += "</SOAP-ENV:Envelope>";
$("#info").html("Request:" + soapMessage).append("<br />");
var laUrl='http://test.balmart.es:8080';
jQuery.support.cors = true;
$.ajax({
url: laUrl,
type: "POST",
dataType: "xml",
crossDomain:true,
data: soapMessage,
success: exitoWebService,
error: errorWebService,
contentType: "text/xml; charset=\"utf-8\""
});
}
function exitoWebService(data, textStatus, jqXHR) {
$("#info").append("Éxito: " + data);
}
function errorWebService(jqXHR, textStatus, error) {
$("#info").append("Error: " + textStatus + " - " + error);
}
</script>
</head>
<body>
<h2 for="texto">Hola Caracola¡¡¡</h2>
<button id="btEnviar">Enviar</button>
<p>
El mensaje enviado es el siguiente:
<br/>
<small id="mensaje"></small>
</p>
<div id="info"></div>
</body>
</html>
:
<SOAP-ENV:Envelope xmlns:SOAP-ENV= ”http://schemas.xmlsoap.org/soap/envelope/”>
<SOAP-ENV:Body>
<m:QueryResponse xmlns:m=”http://www.incits.org/RTLS/">
<QueryResult>
<NumItems>1</NumItems>
<TagBlinks>
<TagBlink>
<TagID>0004A32BEF24</TagID>
<Location>
<X>157</X>
<Y>359</Y>
<Z>2</Z>
</Location>
<States>
<BatteryLow>=true</BatteryLow>
</States>
</TagBlink>
</TagBlinks>
</QueryResult>
내 코드는 다음입니다
그래서 문제를 해결하고 데이터를 수신하려면 어떻게해야합니까? soap 응답은 xml이고 JSON이 아님을 기억하십시오.
그리고 저는 위험한 "접근 허용"* '... "을 포함한 사이트를 취약하게 만들고 싶지 않습니다. 도와주세요. 감사합니다.