ERP electricity supplier how to quickly access electronic courier birds face a single API?

  Express bird is a global logistics interface to service providers, logistics tracking for the electricity business ERP, electronic business platform, warehousing, customs clearance company, electronic face alone, Holiday logistics, logistics and finance, online orders, etc. under the service, to solve the electricity supplier logistics management module and financial modules. Now on to express the birds do basic electronic side single API description, and provides an electronic docking surface single interface.
I. Introduction Interface
    Express birds face a single electronic interface supports more than 30 commonly used in China face a four-way courier, SF, EMS, home delivery, Debon, excellent speed and other single print. Interface birds online e print by courier waybill, waybill number generated on the fly, without having recorded a single, improve delivery efficiency and improve delivery timeliness. Print speed increase 4-6 times, eliminating the need for a single recording session, cancel pumping single link, act as picking manifest enhance delivery timeliness.

Express birds face a single electronic application addresses Click
traditional single-side single VS electronic surface:

Current electronic surface by VS Express birds face a single electronic

 

 

 Two .JAVA docking mode

(1) electronic delivery side single interface is a single interface to the birds available to independent electricity supplier, warehouse management systems, logistics and supply chain logistics system platforms.
(2) to solve customer demand for online delivery, courier business network selection by sending a request to inform the courier company courier shipments.
(3) customer data forwarded to the courier birds through this interface by express courier birds to arrange pickup of on-site service.
(4) order number (OrderCode) can not be repeated submission, resubmit the system will return a specific error code.
(5) the interface to support message receiving mode HTTP POST, the request method of encoding format (utf-8): "application / x-www-form-urlencoded; charset = utf-8".
(6) Request Level System Parameters:

 

 NOTE: R- required (Required), O- optional (Optional), C- packets are optional under certain conditions (Conditional).

(7) Interface Address:
API test address: HTTP: //testapi.kdniao.cc: 8081 / API / EOrderService
API official address: http: //api.kdniao.cc/api/EOrderService

JAVA docking examples

Note: The keys need to express official website application birds

Import java.io.BufferedReader;
 Import java.io.IOException; 
 Import the java.io.InputStreamReader;
 Import java.io.OutputStreamWriter;
 Import java.io.UnsupportedEncodingException;
 Import java.net.HttpURLConnection The;
 Import the java.net.URL;
 Import java.net.URLEncoder;
 Import the java.util.HashMap;
 Import a java.util.Map;
 Import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
 Import the java.security.MessageDigest; 
 
/ * * 
 * 
 * express birds face a single electronic interfaces 
 * 
 * @ technology QQ: 4,009,633,321 
 * @ technology QQ group: 200 121 393
 * @See: Http://www.kdniao.com/MiandanAPI.aspx 
 * @copyright: Shenzhen City Express Gold Data Services Limited 
 * 
 * Key ID and go to the official website to apply: http://www.kdniao.com/ServiceApply.aspx 
 * / 
 
public  class KdGoldAPIDemo { 
    
    // electricity supplier ID 
    Private String EBusinessID = "courier birds go to the official website application http://www.kdniao.com/ServiceApply.aspx" ;    
     // electricity providers private key encryption, providing courier birds, note custody, do not leak 
    Private String AppKey = "courier birds go to the official website application http://www.kdniao.com/ServiceApply.aspx" ;    
     // request url, address a formal environment: http://api.kdniao.cc/api / Eorderservice 
    Private String reqURL = "http://testapi.kdniao.cc:8081/api/Eorderservice" ;    
    
 
    /**
                "' Receiver ': "+
     * Json方式 电子面单
     * @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 area ',' Address ':' Pearl Road No. 73 "}" + 
                "{" +
                " 'Company': 'GCCUI' , 'Name': 'Yann', 'Mobile': '15018442396', 'ProvinceName': ' Beijing', 'CityName': 'Beijing', 'ExpAreaName': 'Chaoyang' 'Address': 'Sanlitun street Yaxiu building'}, "+ 
                " 'Commodity': "+ 
                " [{ "+ 
                " 'GoodsName': 'shoe', 'Goodsquantity': 1, 'GoodsWeight': 1.0}], " + 
                " 'Weight': 1.0," + 
                " 'the Quantity':. 1," + 
                " 'Volume': 0.0," + 
                " 'Remark, the': 'Handle with care'," + 
                " 'IsReturnPrintTemplate':. 1}";
        
        Map<String, String> params = new HashMap<String, String>();
        params.put());"RequestData", urlEncoder(requestData, "UTF-8"
        params.put("EBusinessID", EBusinessID);
        params.put("RequestType", "1007");
        String dataSign=encrypt(requestData, AppKey, "UTF-8");
        params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
        params.put("DataType", "2");
        
        String result=sendPost(ReqURL, params);    
        
        //根据公司业务处理返回的信息......
        
        return result;
    @param
     *STR content       @param
     *
     * the MD5 encrypted/ **
    }
     *charset coding@throws Exception 
     */
    @SuppressWarnings("unused")
    private String 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(32);
        for (int i = 0; i < result.length; i++) {
            int val = result[i] & 0xff;
            if (val <= 0xf) {
                sb.append("0");
            }
            sb.append(Integer.toHexString(val));
        }
        return sb.toString().toLowerCase();
    }
    
    /**
     * base64编码
     * @param str 内容       
     * @param charset 编码方式
     * @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签名生成
     * @param content 内容   
     * @param keyValue Appkey  
     * @param charset 编码方式
     * @throws UnsupportedEncodingException ,Exception
     * @return DataSign签名
     */
    @SuppressWarnings ( "unused" )
     Private String the encrypt (String Content, the keyValue String, String charset) throws UnsupportedEncodingException, Exception 
    { 
        IF (! The keyValue = null ) 
        { 
            return Base64 (the MD5 (Content + the keyValue, charset), charset); 
        } 
        return Base64 (the MD5 (Content, charset), charset); 
    } 
    
     / ** 
     request * POST method sent to the specified the URL      
     * @param the URL transmission request URL     
     * @param the params request parameter set      
     * @return response result of the remote resource
     */
    @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();
            // 发送POST请求必须设置如下两行
            conn.setDoOutput(true);
            conn.setDoInput(true);
            // POST方法
            conn.setRequestMethod("POST");
            // 设置通用的请求属性
            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();
            Get the output stream corresponding to an object URLConnection//
            out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
            // 发送请求参数            
            if (params != null) {
                  StringBuilder param = new StringBuilder(); 
                  for (Map.Entry<String, String> entry : params.entrySet()) {
                      if(param.length()>0){
                          param.append("&");
                      }                  
                      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 ()); 
            } 
            // the flush buffered output stream 
            out.flush ();
             // define BufferedReader input stream to read the URL of the response 
            in = new new BufferedReader (
                     new new the InputStreamReader (Conn. the getInputStream (), "UTF-. 8" )); 
            String Line; 
            the while((Line = in.readLine ()) =! null ) { 
                result.append (Line); 
            } 
        } the catch (Exception E) {             
            e.printStackTrace (); 
        } 
        // use the finally block to close the output stream, the input stream 
        finally {
             the try {
                 IF (OUT =! null ) { 
                    the out.close (); 
                } 
                IF (in =! null ) { 
                    in.close (); 
                } 
            } 
            the catch (IOException EX) {  
                ex.printStackTrace ();
            } 
        }
        return result.toString();
    }
}

 



 

 

Guess you like

Origin www.cnblogs.com/kdn2019/p/11542152.html