서비스를 실행하는 서버가 있습니다. 서비스가 준비 될 때 알 수 있도록 ping 요청을 일부 간격으로 실행하고 싶습니다. 내가 SoapUI가 서비스 및로드 전화를 사용할 때jQuery AJAX를 통한 SOAP 요청
function doAjax() {
//load request document
$.ajax({
cache: false,
crossDomain: true,
async: true,
dataType: 'xml',
type: 'POST',
data: null,
url: "./ping.dat",
error: function(xhr, sta, err){ alert(err); },
success: function(ret, sta, xhr){
//ping service
$.ajax({
cache: false,
crossDomain: true,
async: false,
processData: false,
contentType: "text/xml; charset=\"UTF-8\"",
dataType: 'xml',
data: processXML(xhr.responseText),
type: 'POST',
url: "[private]",
error: function(xhr, sta, err){
alert(err);
},
success: function(ret, sta, xhr){
$('#response').text($.trim(ret));
},
complete: function(xhr, sta){
alert('complete');
},
});
}
});
}
function processXML(text){
var ret = null;
if ((typeof(ret) !== 'undefined')&&(text !== null)&&(text.length !== 0))
ret = $.trim(text.replace(/[\n\t]+/g, ''));
return ret;
}
:합니다 (setInterval()
함수에 포함됩니다)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dvt="[private]">
<soapenv:Header />
<soapenv:Body>
<dvt:Ping/>
</soapenv:Body>
</soapenv:Envelope>
그리고 다음과 같은 자바 스크립트 기능 :
는 다음 ping.dat
파일을 얻었다 핑 요청, 그것은 작동합니다.
I는 JS 기능, 브라우저 보고서를 사용하는 경우 :
OPTIONS [비공개 200 (OK) JQuery와-1.10.2.js을 : 8706
XMLHttpRequest를로드 할 수 없음 [비공개]. 'Access-Control-Allow-Origin'헤더가 요청 된 리소스에 없습니다. 따라서 'http : / / localhost : 8080'은 액세스 할 수 없습니다.