zoukankan      html  css  js  c++  java
  • WOSign API


    [HttpGet]
    public ActionResult WoSign()
    {

    // System.IO.FileStream fs = System.IO.File.OpenRead(System.Web.HttpContext.Current.Server.MapPath("~/Content/pp1.png"));//传文件的路径即可
    // System.IO.BinaryReader br = new BinaryReader(fs);
    // byte[] bt = br.ReadBytes(Convert.ToInt32(fs.Length));
    // string base64String1 = Convert.ToBase64String(bt);
    // br.Close();
    // fs.Close();

    var company= Convert.ToBase64String(System.IO.File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath("~/Content/pp1.png")));
    var user = Convert.ToBase64String(System.IO.File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath("~/Content/pp2.png")));

    var obj = new
    {
    tokenid = "0995d18b-6cf9-453247d-8a31-478c7e020828",
    actiontype = "CreateSignOrder",
    tempid = "956eb3a2-3ea3-4749-a33e-65767519eab4",
    subject = "借款服务协议",
    password = "",
    filebase = "",
    fileformat = "",
    orderNumber = "324233243243225443632344234",
    signerlist = new object[]

    {
    new {signType=1,orgName="融信城(上海)电子商务有限公司",orgNo="9134310109342191070G",stampbase="",pic="111",otherpic="22"},
    new {signType = 2, userName = "李帅", userNo = "41282419963401083571",stampbase=user, pic = "41282413499601083571", otherpic = "345"}
    }
    };

    var str = JsonConvert.SerializeObject(obj);
    var result = PostMoths("https://docapitest.wosign.com/", str);

    //var obj = new
    //{
    // tokenid = "0995d18b-6cf9-457d-8a31-478c7e020828",
    // actiontype = "PushSignedDoc",
    // status = 1,
    // errorcode = 0,
    // extendData = new
    // {
    // signid = "75829991-8076-4bb5-a0fb-55c5282f47ec",
    // orderNumber = "44035241526352145"
    // }

    //};

    //var str = JsonConvert.SerializeObject(obj);
    //var result = PostMoths("https://docapitest.wosign.com/", str);

    return Content(result);


    }

    [HttpPost]
    public void WoSignPushSignedDoc()
    {
    Stream postData = Request.InputStream;
    StreamReader sRead = new StreamReader(postData);
    string postContent = sRead.ReadToEnd();
    sRead.Close();

    FileStream fs = new FileStream(System.Web.HttpContext.Current.Server.MapPath("~/Content/cc.txt"), FileMode.Create);

    byte[] data = System.Text.Encoding.Default.GetBytes(postContent);

    fs.Write(data, 0, data.Length);

    fs.Flush();
    fs.Close();

    }

    public static string PostMoths(string url, string param)
    {
    string strURL = url;
    System.Net.HttpWebRequest request;
    request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
    X509Certificate cer = X509Certificate.CreateFromCertFile(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/RXCWoSign.cer"));
    request.ClientCertificates.Add(cer);
    request.Method = "POST";
    request.ContentType = "application/json;charset=UTF-8";
    string paraUrlCoded = param;
    byte[] payload;
    payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
    request.ContentLength = payload.Length;
    Stream writer = request.GetRequestStream();
    writer.Write(payload, 0, payload.Length);
    writer.Close();
    System.Net.HttpWebResponse response;
    response = (System.Net.HttpWebResponse)request.GetResponse();
    System.IO.Stream s;
    s = response.GetResponseStream();
    string StrDate = "";
    string strValue = "";
    StreamReader Reader = new StreamReader(s, Encoding.UTF8);
    while ((StrDate = Reader.ReadLine()) != null)
    {
    strValue += StrDate + " ";
    }
    return strValue;
    }

    public void test()
    {
    string base64BinaryStr = "";

    byte[] sPDFDecoded = Convert.FromBase64String(base64BinaryStr);

    BinaryWriter writer = new BinaryWriter(System.IO.File.Open(@"F:5.pdf", FileMode.CreateNew));
    writer.Write(sPDFDecoded);
    string s = Encoding.UTF8.GetString(sPDFDecoded);

    }

  • 相关阅读:
    Leetcode 35. 搜索插入位置 二分查找
    《算法竞赛进阶指南》 第一章 Acwing 91. 最短Hamilton路径
    《算法竞赛进阶指南》 第一章 Acwing 90. 64位整数乘法
    《算法竞赛进阶指南》 第一章 Acwing 89. a^b 位运算 更新bitset版本
    挑战程序设计竞赛 2章习题 Aizu
    挑战程序设计竞赛 2章习题 poj 2718 Smallest Difference dfs
    Leetcode 33. 搜索旋转排序数组 二分
    Leetcode 30. 串联所有单词的子串
    LeetCode 22. 括号生成 DFS
    Leetcode 16. 最接近的三数之和 及后继几题
  • 原文地址:https://www.cnblogs.com/myshowtime/p/6281691.html
Copyright © 2011-2022 走看看