2013-07-29 4 views
0

자바 스크립트에서 webservice를 게시하려고합니다. 저는 this 테스트 웹 서비스를 사용하여 게시합니다. 내가 불을 지르고에서 보면하지만 다음과 같은 예외를 얻을 :자바 스크립트에서 웹 서비스 게시

XML parsing error: syntax error Location: moz-nullprincipal:{9e8dc1d9-98d5-48f5-9106-5a19cb9ca7aa} Column: 1, Row: 1: 

Reload the page to get source for: http://www.w3schools.com/webservices/tempconv... 
^ 

내 코드는 다음과 같습니다

var xmlhttp = new XMLHttpRequest(); 
     xmlhttp.open('POST', 'http://www.w3schools.com/webservices/tempconvert.asmx', true); 

     // build SOAP request 
     var sr = 
      '<soapenv:Envelope' + 
       'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + 
       'xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" ' + 
       'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' + 
       'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' + 
       '<soapenv:Body>' + 
        '<CelsiusToFahrenheit xmlns="http://tempuri.org/">' + 
        '<Celsius>44</Celsius>' + 
        '</CelsiusToFahrenheit>'+ 
       '</soapenv:Body>' + 
      '</soapenv:Envelope>'; 

     xmlhttp.onreadystatechange = function() { 
      if (xmlhttp.readyState == 4) { 
       if (xmlhttp.status == 200) { 

        alert('done use firebug to see response'); 
       } 
      } 
     } 
     // Send the POST request 
     xmlhttp.setRequestHeader('Content-Type', 'text/xml'); 
     xmlhttp.send(sr); 
     // send request 
     // ... 

당신에게 어떤 생각이있으세요?

답변

0

문제점을 발견했습니다.

나는 soapenv 근처에 공간을 주었다. 이제는 다음과 같습니다.

'<soapenv:Envelope' + ' ' + 
       'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + 
       'xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" ' + 
       'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' + 
       'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' + 
       '<soapenv:Body>' + 
        '<CelsiusToFahrenheit xmlns="http://tempuri.org/">' + 
        '<Celsius>44</Celsius>' + 
        '</CelsiusToFahrenheit>'+ 
       '</soapenv:Body>' + 
      '</soapenv:Envelope>'; 
관련 문제