내 서버에서 웹 서비스를 실행하고 있지만 수정할 코드가 없으며 구성 파일 만 변경할 수 있습니다.
JQuery / JavaScript에서이 웹 서비스를 호출해야합니다.
이것이 내가 지금까지 시도한 것입니다.
<script>
$(document).ready(function () {
debugger;
jQuery.support.cors = true;
$.ajax({
type: "GET",
contenttype: "application/json; charset=utf-8",
data: "{null}",
url: "http://example.com:1032/service1.asmx/HelloWorld",
dataTyp: "json",
success: function (res) {
debugger;
$("#Text1").val(res.text);
},
error: function (err) {
debugger;
alert(err);
}
});
});
</script>
그러나 성공하지 못하면 오류 블록에 들어갑니다. 나는 또한 http://example.com:1032/service1.asmx/HelloWorld
다른 컴퓨터의 브라우저 에서이 URL을 시도했지만The test form is only available for requests from the local machine.
관련 질문을했지만 웹 서비스 변경이 필요합니다.
웹 서비스에 대한 코드 변경없이 서비스를 호출 할 수 있나요?
편집 : jquery에서 오류가 발생했습니다.
err = Object {readyState: 4, responseText: "<html>
↵ <head>
↵ <title>Runtime Error</…le>
↵
↵ <br>
↵
↵ </body>
↵</html>
↵", status: 500, statusText: "Internal Server Error"}
편집 : 추가하기 위해 다른 컴퓨터에서 실행중인 C # ASP.Net 사이트에서이 서비스 메서드를 호출 할 수 있습니다.
와우, 내 구성에 이것을 추가하면 저에게 효과적이었습니다.
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
이제 위의 방법으로 원격 컴퓨터에서 브라우저 및 jquery에서 서비스를 호출 할 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다