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);

    }

  • 相关阅读:
    google浏览器高清壁纸保存
    vmworkstation安装unbuntu server 网络配置:NAT模式
    python量化交易相关资料
    Oracle VM VirtualBox启动后莫名奇妙的报错
    oracle RAC 跨网段客户端访问 报ORA-12170
    odoo开发 相关知识点
    C#.ToString()格式大全
    flex简单参考实例
    NPOI读写Excel
    C# Stream 和 byte[] 之间的转换(文件流的应用)
  • 原文地址:https://www.cnblogs.com/myshowtime/p/6281691.html
Copyright © 2011-2022 走看看