如何编写Web服务 [英] How to write a web service

查看:70
本文介绍了如何编写Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要集成thetexting sms Api网关,我已经获得了带参数的服务网址

[ ^ ]



,它也发送短信,现在我想要一个服务,询问参数就像下面的参考

API URI:http://www.experttexting.com/exptapi/exptsms.asmx

和用户可以使用文本框设置值而不是使用查询字符串使用url值如何修改此服务链接,如上所述我是webservices的新手。



低于我的代码



我尝试过:



我的代码

I am going to integrate thetexting sms Api gateway , I have get the service url with parameters
[^]

and it send sms as well, Now i want to have a service which ask parameter just like that below reference
API URI: http://www.experttexting.com/exptapi/exptsms.asmx
and user would be able to set the values using textboxes instead of using url values using query string how to modify this service link which is mentioned above i am new to webservices.

below my code

What I have tried:

my code

<html>

<body>

<script>

    function onClick() {

        var apiKey = document.getElementById("api").value;
        var secret = document.getElementById("secret").value;
        var to = document.getElementById("to").value;
        var from = document.getElementById("from").value;
        var text = document.getElementById("text").value;

        var data = "api_secret=" +
                secret + // chane
                "&api_key=" +
                apiKey +  // change
              
                "&to=" +
                to + // change
                "&text=" +
                text + // change
                "&type=text";

        var xhr = new XMLHttpRequest();
        xhr.withCredentials = true;

        xhr.onreadystatechange = function () {
            if (this.readyState === 4 && this.status === 200) {
                alert("Message Sent");
                //                document.getElementById("api").value = "";
                //                document.getElementById("secret").value = "";
                document.getElementById("to").value = "";
                document.getElementById("from").value = "";
                document.getElementById("text").value = "";
            } else {
                //                alert("Message Failed");
                //                document.getElementById("api").value = "";
                //                document.getElementById("secret").value = "";
                document.getElementById("to").value = "";
                document.getElementById("from").value = "";
                document.getElementById("text").value = "";
            }
        };

   

        xhr.open("POST", "https://www.thetexting.com/rest/sms/json/message/send");
        xhr.setRequestHeader("cache-control", "no-cache");
        xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");

        xhr.send(data);
    }

</script>

<form method="get" action="http://www.goassadasogle.com">

    <table>
        <tr>
            <td>
                <label for="api">API key:</label>
            </td>
            <td>
                <input id="api" type="text" name="to"/>
            </td>


        <tr>

            <td>
                <label for="secret">Secret:</label>
            </td>

            <td>
                <input id="secret" type="text" name="to"/>

            </td>
        </tr>

        <tr>
            <td><label for="to">To:</label></td>
            <td><input id="to" type="text" name="to"/></td>
        </tr>
        <tr>
            <td><label for="from">From:</label></td>
            <td><input id="from" type="text" name="to"/> <br></td>
        </tr>
        <tr>
            <td><label for="text">text:</label></td>
            <td><textarea id="text" name="to" style="width: 300px; height: 200px"></textarea></td>
        </tr>

        </table>

    <input type="submit" value="click" onclick="onClick();"/>



</form>

</body>

</html>

推荐答案

您不是在写,甚至不需要Web服务应用程序。这只是一个普通的网站,ASP.NET或ASP.NET / MVC。



一旦从用户那里获得数据,就可以使用SMS API你链接到发送消息。显然,您所要做的就是像在测试中一样构建查询字符串,或者使用您正在使用的API的文档指定。
You're not writing, nor even need, a web service app. This is just a normal web site, either ASP.NET or ASP.NET/MVC.

Once you get the data from the user, you can use the SMS API you linked to to send the message. Apparently, all you have to do is build the query string like you did in your test or however the documentation on the API you're using specifies.


这篇关于如何编写Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆