1
HTML5 앱에서 SOAP 웹 서비스를 호출하려고하면 "지원되지 않는 미디어 유형"오류가 발생합니다.네트워크 오류 415 받기 - 지원되지 않는 미디어 유형
다음은 자바 스크립트 코드입니다.
function login()
{
var soapMessage = '<?xml version="1.0" encoding="UTF-8"?>'+
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:blu="http://www.bluedoortech.com/">'+
'<soapenv:Header/>'+
'<soapenv:Body>'+
'<blu:Connect>'+
'<blu:userID>' + $("#txtUserName").val() + '</blu:userID>'+
'<blu:pwd>' + $("#txtPassword").val() + '</blu:pwd>'+
'</blu:Connect>'+
'</soapenv:Body>'+
'</soapenv:Envelope>';
$.ajax({
url : 'Wealth.asmx' ,
data: soapMessage,
type: "POST",
dataType: "xml",
cache : false,
processData: false
}).success(function(xmlDoc,textStatus) {
alert($(xmlDoc).text());
});
}[1]
여기에는 오류 화면도 첨부되어 있습니다.
테스트 목적으로이 PHP 웹 서비스를 호출하기 위해 PHP 파일을 만들었습니다. 그것은 웹 서비스에 연결할 때 매우 잘 작동합니다. 다음은 PHP 코드입니다.
header("Content-type: text/xml");
$soap_request = file_get_contents('php://input');
$xml = simplexml_load_string($soap_request);
$userIDTag = $xml->xpath('//blu:userID');
$userID = $userIDTag[0][0];
$passwordIDTag = $xml->xpath('//blu:pwd');
$password = $passwordIDTag[0][0];
$client = new SoapClient("Wealth.asmx?WSDL", array('trace' => true));
$objLogin = $client->Connect(array('userID'=>$userID,'pwd'=>$password));
echo $client->__getLastResponse();
문제 식별에 대한 도움을주십시오.
'contentType : "text/xml"을 ajax 호출에 추가하는 방법은 어떻습니까? –
Joachim Isaksson이 맞습니다. "xml"데이터를 그대로 선언하지 않고 보냅니다. Google에서 '지원되지 않는 미디어 유형': http://www.checkupdown.com/status/E415.html, http://stackoverflow.com/questions/11492325 ... – LeGEC
답변 해 주셔서 감사합니다. 나는 그들을 사용하여 확인합니다. –