您是否正受到短信签名报备的困扰?互亿无线解决方案让您最快15分钟内恢复信息传递,马上 注册体验
所有文档
车辆出行
文档中心 > 车辆出行 > 企业道路运输经营许可证核验

企业道路运输经营许可证核验

C#对接提交查询接口DEMO示例

本文为您提供了C#语言版本的提交查询接口对接DEMO示例


using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

private const String host = "https://api.ihuyi.com";
private const String path = "/veh/enttranslic/Submit.json";
private const String method = "POST";

static void Main(string[] args)
{
    String querys = "account=xxxxxxxx&password=xxxxxxxxx&ent_name=上海xx车辆公司®_no=12345678&date=20200101&time=1623643787&";
    String bodys = "";
    String url = host + path;
    HttpWebRequest httpRequest = null;
    HttpWebResponse httpResponse = null;

    if (0 < querys.Length){
        url = url + "?" + querys;
    }

    if (host.Contains("https://")){
        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
        httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
    }else{
        httpRequest = (HttpWebRequest)WebRequest.Create(url);
    }
    httpRequest.Method = method;
    httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);
    if (0 < bodys.Length){
        byte[] data = Encoding.UTF8.GetBytes(bodys);
        using (Stream stream = httpRequest.GetRequestStream())
        {
            stream.Write(data, 0, data.Length);
        }
    }
    try{
        httpResponse = (HttpWebResponse)httpRequest.GetResponse();
    }catch (WebException ex){
        httpResponse = (HttpWebResponse)ex.Response;
    }

    Console.WriteLine(httpResponse.StatusCode);
    Console.WriteLine(httpResponse.Method);
    Console.WriteLine(httpResponse.Headers);
    Stream st = httpResponse.GetResponseStream();
    StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
    Console.WriteLine(reader.ReadToEnd());
    Console.WriteLine("\n");

}

public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
    return true;
}

5分钟快速自助开通免费体验账户

在线咨询
电话咨询

服务热线:

4008 808 898

服务热线(工作时间):

4008 808 898

业务咨询(非工作时间):

售后咨询(非工作时间):