the electronic surface is a kind of logistics service that print and output paper logistics form through thermal paper. The print speed is 4~6 times faster than the traditional needle printing speed by using the heat-sensing display text . Electronic form embedded in the form of the interface to their own systems, websites, you can operate on their own platform to print electronic form.
At present, electronic surface single interface types are: Express Company to provide their own interface, rookie electronic surface single interface, express bird electronic surface single interface. rookie electronic Surface single interface, express bird electronic Surface Single interface access method is similar, all support 15 Express query, in which rookie does not support shun Fung electronic surface print, express birds do not support daily, fast and other express electronic surface single printing. The following is an example of the Java access for the Express bird electronic Surface single interface, which is followed by an introduction to other interfaces in other languages.
Import java.io.bufferedreader;import java.io.ioexception; import java.io.inputstreamreader ;import java.io.outputstreamwriter;import java.io.unsupportedencodingexception;import java.net.httpurlconnection;import java.net.url;import java.net.urlencoder;import Java.util.hashmap;import java.util.map;import com.sun.org.apache.xerces.internal.impl.dv.util.base64 ;import java.security.messagedigest; /** * * Express Bird Electronic Surface Single interface * * @ technology QQ: 4009633321 * @ Technology QQ Group: 200121393 * @see: http://www.kdniao.com/ miandanapi.aspx * @copyright: shenzhen Fast Gold Data Technology Service Co., Ltd. * * id and key please apply to the official website:/http www.kdniao.com/serviceapply.aspx */ public class kdgoldapidemo {//e-commerce idprivate String ebusinessid= "Please apply to express Bird official website http://www.kdniao.com/ServiceApply.aspx";//e-commerce encryption private key, courier birds provided, pay attention to safekeeping, do not leak private string appkey= "Please go to the Express Bird website to apply for Http://www.kdniao.com/ServIceapply.aspx ";//Request url, Formal environment address: http://api.kdniao.cc/api/Eorderserviceprivate String ReqURL=" Http://testapi.kdniao.cc:8081/api/Eorderservice ";/** * json mode electronic face sheet * @throws Exception */public String Orderonlinebyjson () throws Exception{String requestData= "{' Ordercode ': ' 012657700387 ', ' + ' Shippercode ': ' EMS ', ' + "' PayType ': 1," + "' Exptype ': 1," + "' Cost ': 1.0," + "' Othercost ': 1.0," + ' Sender ': ' + "{" + ' company ': ' LV ', ' Name ': ' Taylor ', ' Mobile ': ' 15018442396 ', ' provincename ': ' Shanghai ', ' cityname ': ' Shanghai ', ' Expareaname ': ' Qingpu ', ' Address ': ' No. 73rd, Mingzhu Road ', ' + "' Receiver ':" + "{" + ' company ': ' Gccui ', ' Name ': ' Yann ', ' Mobile ': ' 15018442396 ', ' Provincename ': ' Beijing ', ' cityname ': ' Beijing ', ' expareaname ': ' Chaoyang District ', ' Address ': ' Three Sanlitun street yashow building ', ' + "' Commodity ':" + "[{" + "' goodsname ': ' Shoes ', ' goodsquantity ': 1, ' Goodsweight ': 1.0}]," + "' Weight ': 1.0, " + "' Quantity ': 1," + "' Volume ': 0.0," + "' Remark ': ' Handle with Care '," + "' Isreturnprinttemplate ': 1}"; map<string, string> params = new hashmap<String, string> ();p arams.put ("RequestData", urlencoder (requestdata, "UTF-8"));p Arams.put (" Ebusinessid ", ebusinessid);p arams.put (" RequestType ", " 1007 "); String datasign=encrypt (requestdata, appkey, "UTF-8");p arams.put ("Datasign", urlEncoder ( datasign, "UTF-8"));p arams.put ("DataType", "2"); String result=sendpost (requrl, params);//The information returned according to the company's business process ... return result;} /**&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;*&NBSP;MD5 encryption * @param str content * @param charset Encoding method * @throws exception */@SuppressWarnings ("unused") private &NBSP;STRING&NBSP;MD5 (String str, string charset) throws Exception { messagedigest md = messagedigest.getinstance ("MD5"); Md.update (Str.getbytes (CharSet)); byte[] result = md.digest (); stringbuffer Sb = new stringbuffer (+); for (int i = 0; i < result.length; i++) { int val = result[i] & 0xff; if (val <=&NBSP;0XF) { sb.append ("0"); } sb.append ( Integer.tohexstring (Val)); } return sb.tostring (). toLowerCase ();} /**&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;*&NBSP;BASE64 encoding * @param str content * @param charset Encoding method * @throWs unsupportedencodingexception */private string base64 ( String str, string charset) throws unsupportedencodingexception{string encoded = base64.encode (Str.getbytes (CharSet)); return encoded; }@ Suppresswarnings ("unused") Private string urlencoder (String str, string charset) Throws unsupportedencodingexception{string result = urlencoder.encode (Str, charset); Return result;} /** * sign Generation * @param content Content * @param keyValue Appkey * @param charset encoding * @throws unsupportedencodingexception ,exception * @return datasign Signature */@SuppressWarnings ("unused") private String encrypt (String content, string keyvalue, string charset) throws UnsupportedEncodingException, Exception{if (keyvalue != null) {return base64 (MD5 (Content + keyvalue, charset), charset);} Return base64 (MD5 (Content, charset), charset);} /** * request to specify URL send a POST method * @param url Send Request URL * @param params parameter collection for requests * @return Remote resource response results */@SuppressWarnings ("unused") private String sendpost (String url, map<string, string> params) { OutputStreamWriter out = null; bufferedreader in = null; stringbuilder result = new stringbuilder (); try { url realurl = new url (URL); httpurlconnection conn = (HttpURLConnection) Realurl.openconnection (); // The Send POST request must have the following two lines set conn.setdooutput (True) ; conn.setdoinput (True); // post Methods conn.Setrequestmethod ("POST"); // Set the common Request property conn.setrequestproperty (" Accept ", " */* "); Conn.setrequestproperty ("Connection", "keep-alive"); conn.setrequestproperty ("User-agent", "mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; SV1); conn.setrequestproperty (" Content-type ", " application/x-www-form-urlencoded "); conn.connect (); // receivedTake the output stream corresponding to the URLConnection object out = New outputstreamwriter (Conn.getoutputstream (), "UTF-8"); // Send Request Parameters if (params != NULL) { StringBuilder param = New stringbuilder (); for (Map.Entry <string, string> entry : params.entryset ()) { if (Param.length () >0) { param.append ("&"); } &Nbsp; param.append (Entry.getKey ()); param.append ("="); param.append (Entry.getvalue ()); system.out.println (Entry.getKey () + ":" + Entry.getvalue ()); } system.out.println ("param:" +param.tostring ()); out.write (Param.tostring ()); } // Flush output Stream Buffer out.flush (); // define BufferedReader input stream to read the URL response in = new bufferedreader ( new inputstreamreader ( Conn.getinputstream (), "UTF-8")); string line; while (line = in.readline ()) != null) { result.append (line); } } catch (Exception e) { e.printstacktrace (); } //using the finally block to close the output stream, input stream finally{ try{ if (out!=null) { out.close (); } if (in!=null) { in.close (); } &nbsP; } catch (Ioexception ex) { Ex.printstacktrace (); } } return Result.tostring (); }}
This article from the "11788217" blog, reproduced please contact the author!
Electronic Surface Single API interface _java invocation Example