yaverm
@yaverm

Как правильно отправить данные по SOAP?

Подскажите пожалуйста где моя ошибка при отправке данных по SOAP ? При отправке я получаю эти ошибку


Refused to set unsafe header "Host"
Refused to set unsafe header "Content-Length"
Access to XMLHttpRequest at 'https://apiurl.com' from origin 'https://mysite.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.


var soapApiUrl = 'https://apiurl.com' + ref_code + '?o=' + job_portal;

		var xmlhttp = new XMLHttpRequest();
		xmlhttp.open('POST', soapApiUrl, true);

		var payload  = '<?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>' +
			'<JobApplication xmlns="http://url.site">' +
				'<item>' +
					'<RefCode>' + personal_data.refCode + '</RefCode>' +
					'<SalutationGender>' + personal_data.gender +'</SalutationGender>' +
					'<FirstName>' + personal_data.name +'</FirstName>' +
					'<LastName>' + personal_data.lastname +'</LastName>' +
					'<EmailAddress>' + personal_data.email +'</EmailAddress>' +
					'<Phone>' + personal_data.phone + '</Phone>' +
					'<ApplicantComments>' + personal_data.commet +'</ApplicantComments>' +
				'</item>' +
			'</JobApplication>' +
		'</soap:Body>' +
		'</soap:Envelope>';


		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState == 4) {
				if (xmlhttp.status == 200) {
					console.log(xmlhttp.responseText);
                   } else {
                   	 console.log('error');
                   }
                }
            }

            xmlhttp.setRequestHeader('POST', '/services/website.asmx HTTP/1.1');
            xmlhttp.setRequestHeader('Host', 'url');
            xmlhttp.setRequestHeader('Content-Type', 'text/xml');
            xmlhttp.setRequestHeader('Content-Length', 'length');
            xmlhttp.setRequestHeader('Access-Control-Request-Origin', 'https://mysite.com');
            xmlhttp.setRequestHeader('SOAPAction', 'http://url.site/JobApplication');
            xmlhttp.send(payload);
  • Вопрос задан
  • 170 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы