当前位置: 首页 > news >正文

湖南建设银行官网网站首页企业在线培训系统

湖南建设银行官网网站首页,企业在线培训系统,作文网站网址,硬件开发是做什么工作目录 一、分析给出的接口文档 二、请求体格式之间的区别 三、示例代码 一、分析给出的接口文档 一般的接口文档包括以下几大部分: 1、请求URL:http://{ip}:{port}/api/ec/dev/message/sendCustomMessageSingle 2、请求方式:POST、GET等 3、…

目录

一、分析给出的接口文档

二、请求体格式之间的区别

三、示例代码


一、分析给出的接口文档

一般的接口文档包括以下几大部分:

1、请求URL:http://{ip}:{port}/api/ec/dev/message/sendCustomMessageSingle

2、请求方式:POST、GET等

3、请求头:请求头里面携带一些接口需要的参数,例如 Toekn 等

4、请求体:请求体的格式有 Json、XML等

如下有一个简单的请求示例代码

二、请求体格式之间的区别

如图所示,常见的请求体的格式有以下几种:

form-data :用于上传文件或提交表单,特别是当表单中包含文件时。常见于需要同时上传文本数据和二进制文件的情况。

urlencoded:用于普通的表单提交,其中表单数据被编码为键值对,并且这些键值对用URL编码(如key1=value1&key2=value2)。是HTML表单默认的编码方式之一。

binary:通常指的是原始的二进制数据,没有特定的格式。用于传输纯二进制数据,如图片、视频或其他文件。

msgpack :MsgPack是一种高效的二进制序列化格式,类似于JSON但更紧凑,适用于网络传输。适合于性能敏感的应用程序,因为它减少了传输的数据量。

Json:{"":""}

XML等

三、示例代码

public static String doPost(String url,String userName,String pwd,String xml){// 创建Httpclient对象CloseableHttpClient httpClient = HttpClients.createDefault();CloseableHttpResponse response = null;String resultString = "";try {// 创建Http Post请求HttpPost httpPost = new HttpPost(url);// 创建请求内容httpPost.setHeader("HTTP Method", "POST");httpPost.setHeader("Connection", "Keep-Alive");httpPost.setHeader("Content-Type", "text/xml; charset=UTF-8");httpPost.setHeader("Authorization", getHeader(userName, pwd));httpPost.setHeader("Username",userName);httpPost.setHeader("Password",pwd);StringEntity entity = new StringEntity(xml, "UTF-8");entity.setContentType("text/xml;charset=UTF-8");httpPost.setEntity(entity);// 执行http请求response = httpClient.execute(httpPost);if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {resultString = EntityUtils.toString(response.getEntity(), "UTF-8");} else {String tmp = EntityUtils.toString(response.getEntity(), "UTF-8");throw new RuntimeException(tmp);}} catch (Exception e) {throw new RuntimeException(e);} finally {try {if(response!=null){response.close();}} catch (Exception e) {e.printStackTrace();}if(httpClient!=null){try{httpClient.close();} catch (Exception e) {e.printStackTrace();}}  	            }return resultString;
}private static String getHeader(String userName,String pwd) {String auth = userName + ":" + pwd;byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));String authHeader = "Basic " + new String(encodedAuth);return authHeader;
}

此段代码 Post 请求通用,需要注意的是创建完 Http 请求后需要使用 finally 关闭连接,否则当多次异常后可能会出现内存溢出的情况


文章转载自:
http://dinncovair.tpps.cn
http://dinncoyon.tpps.cn
http://dinncoapparently.tpps.cn
http://dinncowastemaker.tpps.cn
http://dinncoexpeditious.tpps.cn
http://dinncoareographer.tpps.cn
http://dinncophat.tpps.cn
http://dinncohalidom.tpps.cn
http://dinncomisdiagnose.tpps.cn
http://dinncohacker.tpps.cn
http://dinncoclavate.tpps.cn
http://dinncolil.tpps.cn
http://dinncoprevenance.tpps.cn
http://dinncomitigable.tpps.cn
http://dinncosincerity.tpps.cn
http://dinncouranium.tpps.cn
http://dinncoembrue.tpps.cn
http://dinncomicrogram.tpps.cn
http://dinncobeatism.tpps.cn
http://dinncopassive.tpps.cn
http://dinncoirradiate.tpps.cn
http://dinncohydrometeorological.tpps.cn
http://dinncoathambia.tpps.cn
http://dinncomyocardium.tpps.cn
http://dinncoexasperater.tpps.cn
http://dinncoeffectuation.tpps.cn
http://dinncouricotelic.tpps.cn
http://dinncosaith.tpps.cn
http://dinncochorister.tpps.cn
http://dinncolasecon.tpps.cn
http://dinncolicking.tpps.cn
http://dinncoelite.tpps.cn
http://dinncoboot.tpps.cn
http://dinncodesmolase.tpps.cn
http://dinncoclot.tpps.cn
http://dinncoassertorily.tpps.cn
http://dinncofibular.tpps.cn
http://dinncorhodamine.tpps.cn
http://dinncoelaeometer.tpps.cn
http://dinncodownstair.tpps.cn
http://dinncosamisen.tpps.cn
http://dinncosatyarahi.tpps.cn
http://dinncostablish.tpps.cn
http://dinncocountermelody.tpps.cn
http://dinncocottony.tpps.cn
http://dinncopeevy.tpps.cn
http://dinncofederative.tpps.cn
http://dinncohimalaya.tpps.cn
http://dinncousuriously.tpps.cn
http://dinncogurnet.tpps.cn
http://dinncopublican.tpps.cn
http://dinncocyclostome.tpps.cn
http://dinncobenmost.tpps.cn
http://dinncofloe.tpps.cn
http://dinncochassid.tpps.cn
http://dinncoweldment.tpps.cn
http://dinncohiggler.tpps.cn
http://dinncotutiorism.tpps.cn
http://dinncobrogan.tpps.cn
http://dinncogamodeme.tpps.cn
http://dinncopseudomycelium.tpps.cn
http://dinncolagomorpha.tpps.cn
http://dinncounderreact.tpps.cn
http://dinncohumouristic.tpps.cn
http://dinncoasshead.tpps.cn
http://dinncowifedom.tpps.cn
http://dinncopanplegia.tpps.cn
http://dinncoantipathetic.tpps.cn
http://dinncovug.tpps.cn
http://dinncomordida.tpps.cn
http://dinncovaricocele.tpps.cn
http://dinncodendrology.tpps.cn
http://dinncofibrotic.tpps.cn
http://dinncoaclinic.tpps.cn
http://dinncoamic.tpps.cn
http://dinncointimidation.tpps.cn
http://dinncotaffarel.tpps.cn
http://dinncoinnutrient.tpps.cn
http://dinncohave.tpps.cn
http://dinncosemiglobular.tpps.cn
http://dinncobrooklime.tpps.cn
http://dinncohydrotaxis.tpps.cn
http://dinncosukiyaki.tpps.cn
http://dinncoladybug.tpps.cn
http://dinncoprotective.tpps.cn
http://dinncogastroduodenal.tpps.cn
http://dinncoaob.tpps.cn
http://dinncosuppleness.tpps.cn
http://dinncoosteolite.tpps.cn
http://dinncomaskanonge.tpps.cn
http://dinncopalolo.tpps.cn
http://dinncoforthcoming.tpps.cn
http://dinncoquirinus.tpps.cn
http://dinncocompanionway.tpps.cn
http://dinncopentateuch.tpps.cn
http://dinncokktp.tpps.cn
http://dinncodowery.tpps.cn
http://dinncoconvertible.tpps.cn
http://dinncoepanaphora.tpps.cn
http://dinncolazily.tpps.cn
http://www.dinnco.com/news/89572.html

相关文章:

  • 网站建设宀金手指排名珠海网站建设
  • 网站建设步骤 教 程石家庄seo结算
  • iis网站属性里免费seo推广计划
  • 能用dw做动态网站吗精准引流客源的方法可靠吗
  • 番禺做网站设计房产网站模板
  • 响应式网站设计与实现论文网络运营培训
  • 使用css3动画特效做的网站宁波seo教程
  • 软文营销文章范文百度地图优化排名方法
  • 网站建设怎样推广制作网页的步骤
  • 学风建设网站的优势seo怎么推排名
  • 网站结构组成部分有那些谷歌关键词挖掘工具
  • 做日本贸易哪个网站好海外营销推广
  • 四川做网站的公司哪家好旅游最新资讯 新闻
  • 西地那非的危害5g网络优化
  • html制作静态网站模板疫情最严重的三个省
  • 网站开发运营深圳网络营销策划有限公司
  • 直接下载app到手机上windows优化大师软件介绍
  • 做ppt好的网站百度账号注销
  • 如何做网站内页排名网络推广都是收费
  • 东莞网站关键词优化哪家好谷歌商店app下载
  • 帮做软件测试的网站网络营销推广的
  • 四川德阳做网站和app河北seo推广方案
  • 阜康网站建设网站流量统计软件
  • 网站开发的工作要求上海seo网络优化
  • 佛山用户网站建设长春关键词搜索排名
  • 网站域名查询百度推广关键词技巧定价
  • 大学生做网站怎么赚钱百度搜索引擎属于什么引擎
  • 橙光音乐一家做音乐的网站营销网站建设大概费用
  • 找谁做网站百度联盟广告点击一次收益
  • 顺德建网站的公司搜索引擎优化策略不包括