2023-05-26

[Oracle]SOAP WebService 新竹物流標籤規格串接

新竹物流標籤規格串接
DECLARE
  http_resp utl_http.resp;
  http_req utl_http.req;
  json_msg VARCHAR2(2000);
  l_text VARCHAR2(2000);
BEGIN

  http_req := utl_http.begin_request('http://is1fax.hct.com.tw/Webedi_Erstno_NEW2/WS_addrCompare1.asmx', 'POST');
  utl_http.set_body_charset(http_req, 'UTF-8');
  utl_http.set_header(http_req, 'Content-Type', 'application/soap+xml');

  json_msg := 
'

  
    
      
      [
    {
        "USER": "TEST2",
        "NO": "A0000001",
        "ADDR": "新北市板橋區中山路一段161號",
        "ESDATE": "20210715",
        "TEL": "",
        "TEL2": "",
        "EPRDCL": "001",
        "EMARK": "",
        "ESCSNO": "00000000000",
        "EJAMT": "1",
        "EQAMT": "5",
        "EQAMTTYPE": "1",
        "ELAMTTYPE": "1"
    }
]
      
      
      
    
  
';

  utl_http.set_header(http_req, 'CONTENT-Length', LENGTHB(json_msg)); --中文要用LENGTHB
  utl_http.write_text(http_req, dbms_lob.substr(json_msg, dbms_lob.getLength(json_msg), 1));

  http_resp := utl_http.get_response(http_req);

  IF (http_resp.status_code = 400) AND (http_resp.status_code = 499) THEN
     dbms_output.put_line(http_resp.status_code);
  ELSE
     dbms_output.put_line(http_resp.status_code);
  END IF;

  UTL_HTTP.read_text(http_resp, l_text, 32766);
  dbms_output.put_line(l_text);
  utl_http.end_response(http_resp);

END;

沒有留言:

張貼留言