zoukankan      html  css  js  c++  java
  • 利用JAVAScript调用WebService

    <%@ WebService Language="C#" Class="WebService" %>
    
    using System;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Web.Script.Services;
    
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ScriptService]
    public class WebService  : System.Web.Services.WebService {
    
        [WebMethod]
        public string Add(Int Num1 ,Int Num2) {
            return Num1+Num2;
        }
        
    }
    

      调用

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" >
            <Services>
            <asp:ServiceReference Path="WebService.asmx" />
            </Services>
            </asp:ScriptManager>
            <input type="button" value="Add" onclick="Add();" />
            <script type="text/javascript">
            function Add()
            {
                return WebService.Add(1,2);
            }
            
        
            </script>
            <div>
            </div>
        </form>
    </body>
    </html>
    

      

  • 相关阅读:
    变量和数据类型
    Manager 多进程之间的数据共享
    多进程之间的数据传输 Pipe
    多进程
    消费者 生产者
    queue 队列优先级
    Python 最难的问题
    threading 多线程
    线程进程概述
    倒计时器 小玩意
  • 原文地址:https://www.cnblogs.com/wangguowen27/p/Js_webServer.html
Copyright © 2011-2022 走看看