Цитата:
|
Столкнулся с аналогичным вопросом...
Написали СОАП-сервис. Суть которого тестовая - вернуть дату или время на сервере... В браузере он нормально отвечает на запрос http://mcaronov:57772/csp/user/ws.te...hod=wrt&type=1 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <wrtResponse xmlns="http://tempuri.org"> <wrtResult>13:26:31</wrtResult> </wrtResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> http://mcaronov:57772/csp/user/ws.te...hod=wrt&type=2 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <wrtResponse xmlns="http://tempuri.org"> <wrtResult>05/05/2015</wrtResult> </wrtResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Но при попытке обратиться к нему, используя JS, получаю в статусе "error"
<!DOCTYPE html>
<html>
<head>
<script src='http://code.jquery.com/jquery-latest.js'></script>
<!--
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
<link rel='stylesheet type=text/css href=tmp.css' />
-->
<style type='text/css'>
</style>
<script type='text/javascript'>
$(function(){
$('button').click(function(){
var typ=$(this).data('type');
$.ajax({
url: 'http://mcaronov:57772/csp/user/ws.test.cls',
type: "POST",
dataType: "xml",
contentType: "text/xml",
cache: false,
data: 'soap_method=wrt&type=2',
success: function(data){
alert(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
console.log(XMLHttpRequest);
alert(textStatus);
console.log(errorThrown);
}
});
});
});
</script>
</head>
<body>
<button data-type='1'>Посмотреть время</button>
<button data-type='2'>Посмотреть дату</button>
</body>
</html>
Как же правильно получить данные от СОАП-сервиса? |
| Часовой пояс GMT +3, время: 13:45. |