[webMethods] Apache HTTPClient 라이브러리를 활용한 webMethods TN receive 호출 샘플소스
EAI/webMethods 2013. 8. 5. 14:46가장 간단하게 아파치그룹의 HTTPClient (참고 URL : http://hc.apache.org/)을 라이브러리를 활용하여
첨부의 샘플소스와 같이 간단하게 XML 데이터를 송신하는 샘플 소스 생성이 가능함
package Network; package Network; import java.io.*; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.InputStreamRequestEntity; import org.apache.commons.httpclient.methods.PostMethod; public class PostXML { public static void main(String[] args) throws Exception { String strURL = null; // 수신지 URL 셋팅 strURL = "https://xxx.xxx.xxx.xxx:5400/invoke/wm.tn/receive"; // Prepare HTTP post PostMethod post = new PostMethod(strURL); StringBuffer sbOut = new StringBuffer(); /*-- Sample XML --*/ // sbOut.append(""); sbOut.append(""); sbOut.append(" "); // 전송 Data 셋팅 InputStream inputStream = new ByteArrayInputStream(sbOut.toString().getBytes()); post.setRequestEntity(new InputStreamRequestEntity(inputStream)); // 전송시 권한 체크시 사용ID / PW String authInfo = "userid" + ":" + "password"; String encoding = new sun.misc.BASE64Encoder().encode(authInfo.getBytes()); post.setRequestHeader("Authorization", "Basic " + encoding); // HTTP Content-Type 셋팅 post.setRequestHeader("Content-Type", "text/xml;charset=KSC5601"); // Get HTTP client HttpClient httpclient = new HttpClient(); // Execute request try { int result = httpclient.executeMethod(post); // Display status code System.out.println("Response status code: " + result); // Display response System.out.println("Response body: "); System.out.println(post.getResponseBodyAsString()); } finally { // Release current connection to the connection pool // once you are done post.releaseConnection(); } } }"); sbOut.append(" "); sbOut.append("20090616111724000550_PKEHQ "); // Interface Unique ID sbOut.append("TestSender ");// Customer System DUNS ID sbOut.append("TestReceiver "); // Pantos Logistics DUNS ID sbOut.append("CXML_LGE_NW_TEST "); // Interface Document Type ID sbOut.append("20090616111724 "); // Interface occur time sbOut.append(""); sbOut.append(" "); sbOut.append(" "); sbOut.append(""); sbOut.append(" "); sbOut.append("Y12 "); sbOut.append("A-01-A | "); sbOut.append("sku "); sbOut.append("24 "); sbOut.append("testid "); sbOut.append("
'EAI > webMethods' 카테고리의 다른 글
[webMethods] 간단한 Tip들... (0) | 2013.08.20 |
---|---|
[webMethods] SAP Adapter Listener 연결오류 관련 (1) | 2013.08.05 |
[webMethods] [사례] SAP PI와의 인터페이스(웹서비스) (0) | 2013.08.02 |
[webMethods] Java서비스에서 server LOG에 Write할때 (0) | 2013.08.01 |
[webMethods] stats Log 각 필드 의미 (0) | 2013.08.01 |