HTTP GET方式提交例子

http://分配IP:7180/service.asmx/LlbCzStr?Id=机构代码&Name=帐户名&Psw=密码&Phone=充值号码&YD=移动流量包套餐名称&DX=电信流量包套餐名称&LT=联通流量包套餐名称
 

Phone:多个手机号码须要使用半角分号“;”分隔


例子:机构代码:300,帐户名称:fjs 帐户密码:123456,对移动和联通手机充值100M流量套餐 使用Get方式调用接口如下

http://分配IP:7180/service.asmx/LlbCzStr?Id=300&Name=fjs&Psw=123456&Phone=13724005383;13025152222&YD=100M&DX=&LT=100M

http://分配IP:7180/service.asmx/LlbCzStr?Id=300&Name=fjs&Psw=123456&Phone=13724005383&YD=100M&DX=&LT=
http://分配IP:7180/service.asmx/LlbCzStr?Id=300&Name=fjs&Psw=123456&Phone=13025152222&YD=&DX=&LT=100M

例子中IP 请替换实际接口访问IP地址或者访问域名

 

HTTP接口的Get方式可以在IE浏览器地址栏里输入像以上调用字符数据直接测试调用接口的。

请注意,HTTP接口get方式提交数据量大小有限制的,具体限制请参考IE浏览器访问页面允许后面附加参数的数据长度,Post方式是没有相关限制的,如每次提交数据量比较大请使用Post方式。

 

 

 
JAVA开发语言调用示例:

import java.io.BufferedReader;
import java.io.InputStreamReader;   

    URL url = null;
    url = new URL("http://分配IP:7180/service.asmx/LlbCzStr?Id=300&Name=fjs&Psw=123456&Phone=13724005383;13025152222&YD=100M&DX=&LT=100M");
    BufferedReader in = null;
    String inputLine = "";
    try {
        in = new BufferedReader(new InputStreamReader(url.openStream()));
        inputLine = in.readLine();
        System.out.println(inputLine+"*************");
        } catch (Exception e) {
        System.out.println("网络异常,调用流量充值接口失败!");
        inputLine=-313131;
        }
        System.out.println("调用接口返回值: "+inputLine);
 

 

C# 开发语言调用示例

        using System.Net;
        using System.Web;

 private void button1_Click(object sender, EventArgs e)
{
    string vUrl;
    string vPara;
    vUrl = @"http://分配IP:7180/service.asmx/LlbCzStr";
    vPara = "Id=300&Name=fjs&Psw=123456&Phone=13724005383;13025152222&YD=100M&DX=&LT=100M";
    vStr = GetHtmlPost(vUrl, vPara);
    MessageBox.Show(vStr);
}

public string GetHtmlPost(string URL, string pVal)
{
    try
    {
        byte[] postData = null;
        postData = System.Text.Encoding.UTF8.GetBytes(pVal);
        System.Net.HttpWebRequest request =(HttpWebRequest) System.Net.WebRequest.Create(URL);
        request.Method = "POST";
        request.ContentType = "application/x-www-form-urlencoded";
        request.Timeout = 500000;
        request.ContentLength = postData.Length;
        System.IO.Stream requestStream = request.GetRequestStream();
        requestStream.Write(postData, 0, postData.Length);
        requestStream.Close();
        System.Net.HttpWebResponse response =(HttpWebResponse) request.GetResponse();
        System.IO.Stream responseStream = response.GetResponseStream();
        System.IO.StreamReader reader = new System.IO.StreamReader(responseStream, System.Text.Encoding.UTF8);
        string srcString = reader.ReadToEnd();
        response.Close();
        responseStream.Close();
        requestStream = null;
        response = null;
        request = null;

        return srcString.Trim();
    }
    catch
    {
        return "-313131";
    }

}

 

 

PHP开发语言调用示例:

$gateway = "http://分配IP:7180/service.asmx/LlbCzStr?Id=300&Name=fjs&Psw=123456&Phone=13724005383;13025152222;13312345678&YD=100M&DX=100M&LT=100M";
$result = file_get_contents($gateway);
echo "发送返回: ".$result;
 

 

 

ASP开发语言调用示例:

    Dim http,url,vRef,vLen,vPost,vStr
    url = "http://分配IP:7180/service.asmx/LlbCzStr"
    vPost= "Id=300&Name=fjs&Psw=123456&Phone=13724005383;13025152222;13312345678&YD=100M&DX=100M&LT=100M"
    vLen = Len(vPost)
    Set http = CreateObject("MSXML2.XMLHTTP")
    If http Is Nothing Then
        Set http = CreateObject("Microsoft.XMLHTTP")
        If http Is Nothing Then
            Set http = CreateObject("MSXML2.ServerXMLHTTP")
        End If
    End If
    http.Open "POST", url, False
    http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    http.setRequestHeader "Content-Length", vLen
    http.send CStr(vPost)
    vStr = Trim(http.responseText)
    response.write(vStr)