1

people I'm trying to consume a web service with javascript code this is the web service: http://192.168.0.43/DWService/DW_WebService.asmx It has some methods and one of them returns a encoded string when user send the parameters.

I'm using ScriptManager

<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <%--  web service reference --%>
            <asp:ServiceReference Path="http://192.168.0.43/DWService/DW_WebService.asmx" />
        </Services>
    </asp:ScriptManager>

Invoke:

<tr>
                <td>
                    <asp:Button ID="btnVwr" runat="server" Text="Visor" OnClientClick="return Submit();" />
                </td>
                <td>
                    <asp:Button ID="btnDwn" runat="server" Text="Descargar"  />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:TextBox ID="txtlinkVisor" runat="server" TextMode="MultiLine" Rows="5" Width="482px"></asp:TextBox>
                </td>
            </tr>
        </table>

My script:

<script type="text/javascript">
            function Submit() {
                var condicion = $get("<%=txtDocID.ClientID %>").value;
                var url = $get("<%=txtUrl.ClientID %>").value;
                var fc = $get("<%=txtFCid.ClientID %>").value;
                var dwuser = $get("<%=txtUsr.ClientID %>").value;
                var dwpass = $get("<%=txtPas.ClientID %>").value;
                URLDocVw(condicion, url, fc, dwuser, dwpass);
                return false;
            };
            function OnSuccess(response) {
                alert(response);
            };
            function OnError(r) {
                alert(response);
            };
        </script>

Server returns: "0x800a1391 - JavaScript runtime error: 'URLDocVw' is undefined" URLDocVw is the name of the method I've tested in diferent ways on path of the scriptManager, but I can't resolve it. Please, is the first time that I'm doing this. I hope anyone can help me.

thanks in advance.

angel_neo
  • 333
  • 2
  • 5
  • 22
  • what errors you get? and you can use fetch instead – Alexan Jul 11 '18 at 17:52
  • Possible duplicate of [asmx web service, json, javascript/jquery?](https://stackoverflow.com/questions/3445859/asmx-web-service-json-javascript-jquery) – Peter B Jul 11 '18 at 18:00

1 Answers1

1

You can use ES6 instead:

$(function() {
  $("[id*=btnVwr]").click(function() {
    var url = $.trim($("[id*=txtUrl]").val());
    var fc = $.trim($("[id*=txtFCid]").val());
    var usr = $.trim($("[id*=txtUsr]").val());
    var pas = $.trim($("[id*=txtPas]").val());
    var con = $.trim($("[id*=txtDocID]").val());
    fetch('http://192.168.0.43/DWService/DW_WebService.asmx?WSDL/URLDocVw', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({url, fc, con, pas , usr})
  })
      .then(raw => raw.json())
      .then(data =>console.log(data))
      .catch(error => console.error(error))
  });
});
Nicolas M. Pardo
  • 753
  • 1
  • 6
  • 16