从经典ASP中消耗ASMX Web服务的问题

时间:2019-02-23 18:37:12

标签: javascript .net web-services asmx

当我尝试使用经典asp的asmx Web服务(来自asp.net网站)时,出现以下错误。          “ /”应用程序中的服务器错误。

找不到资源。

    [![IIS Server Error][1]][1]

下面是我的ServiceRequest.asp页面代码,该代码位于我的经典ASP网站下

<script type="text/javascript">
  function callService() {
            url = GetUrl("/WebService1.asmx/CallService")
            var xhr1 = new XMLHttpRequest();
            xhr1.open("POST", url);
            xhr1.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
            xhr1.onreadystatechange = function () {
                if (xhr1.readyState == XMLHttpRequest.DONE && xhr1.status === 200) {
                    //var outputData = JSON.parse(JSON.parse(xhr1.responseText).d);
                    var outputData = JSON.parse(xhr1.responseText).d;

                    alert(outputData);
                    //Here the response object needs to be read
                } else if (xhr1.readyState == XMLHttpRequest.DONE && xhr1.status != 200) {

                    //In case of SAP call failure, alert the user
                    alert("Vendor creation failed");
                }
            };

            xhr1.send(JSON.stringify({
                sVndNum: "",
                sVndName: "",
                sCoCode: "",
                sVndCity: "",
                sVndPstlCd: "",
                sVndState: "",
                sVndCntry: ""
            }));
        }

        function GetUrl(url) {
            return window.location.origin + url;
        }
    </script>


Both the classic asp application and Asp.net website which has my webservice are hosted in IIS. When I tried to access service method from classic page i am getting the below error response at service side.

“ /”应用程序中的服务器错误。

   [ParseError][2]    


      [1]: https://i.stack.imgur.com/XIKR4.png
      [2]: https://i.stack.imgur.com/4YQtj.png

0 个答案:

没有答案