一、什么是企业三要素?
企业三要素即传入的企业名称、法人名称、社会统一信用代码或注册号,校验此三项是否一致。
二、具体怎么样通过C#实现接口调用?
下面我们以阿里云的为例,通过C#语言实现接口调用:
首先,注册阿里云账号,其次,找到对应接口链接,再次,选择免费试用,最后,调试成功后再选取套餐包。
//using System.IO;
//using System.Text;
//using System.Net;
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;
private const String host = "https://kzcpthree.market.alicloudapi.com";
private const String path = "/company_three/check";
private const String method = "POST";
private const String appcode = "你自己的AppCode";
static void Main(string[] args)
{
String querys = "";
String bodys = "creditCode=creditCode&companyName=companyName&legalPerson=legalPerson";
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);
//根据API的要求,定义相对应的Content-Type
httpRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
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;
}
正确返回示例如下:
{
"msg": "成功",
"success": true,
"code": 200,
"data": {
"result": 2, //1一致,2不一致
"orderNo": "202412012048184836138",
"companyName": true, //true 正确, false 错误
"legalPerson": false,
"creditNo": true
}
}