1.1. 설정 방법
- $PFM_HOME/context/proframeWeb/WEB-INF/web.xml
-
... ...
<servlet>
<servlet-name>streamFLDHandler</servlet-name>
<servlet-class>proframe.core.ippr.http.ProFrameHttpStreamIppr</servlet-class>
<init-param>
<param-name>messageType</param-name>
<param-value>FLD</param-value>
</init-param>
<load-on-startup>-1</load-on-startup>
</servlet>
... ...
<servlet-mapping>
<servlet-name>streamFLDHandler</servlet-name>
<url-pattern>/FLDSERVICES/*</url-pattern>
</servlet-mapping>
... ...
1.2.1 메시지 생성
- 호출할 SO 에서 사용하는 DTO에 Fixed Length Message 를 생성한다.
- Fixed Length 형식으로 보내줄 전문을 생성한다. Fixed Length 이므로 ProFrameHeader, SystemHeader, 서비스에서 사용한 DTO 에 대한 길이를 정확하게 작성해야 한다.
- 예> D:/FLD.txt
-
TestPrj TesterSOSO2 testEmp 1 7788
-
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class TestProFrameFLDStream {
public static void main(String[] args) {
TestProFrameFLDStream tester = new TestProFrameFLDStream();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
File inFile = new File("D:/FLD.txt");
try {
FileInputStream fis = new FileInputStream(inFile);
byte[] inBuffer = new byte[2048];
int readLen = 0;
do {
readLen = fis.read(inBuffer);
bout.write(inBuffer, 0, readLen);
}
while(readLen == 2048);
bout.flush();
}
catch(FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
byte[] inXML = bout.toByteArray();
System.out.println("\n\n\n\n\n");
System.out.println("###################### IN #######################");
System.out.println(new String(inXML));
byte[] outXML = tester.testXMLStream(inXML);
System.out.println("\n\n\n\n\n");
System.out.println("###################### OUT #######################");
System.out.println(new String(outXML));
}
public byte[] testXMLStream(byte[] inXML) {
DataOutputStream dout = null;
DataInputStream din = null;
ByteArrayOutputStream bout = null;
HttpURLConnection con = null;
int resCodes = 0;
try
{
URL url = new URL("http://192.168.20.182:19876/proframeWeb/FLDSERVICES/");
con = (HttpURLConnection)url.openConnection();
con.setDoOutput(true);
dout = new DataOutputStream(con.getOutputStream());
dout.write(inXML);
dout.flush();
resCodes = con.getResponseCode();
if(resCodes == HttpURLConnection.HTTP_OK)
{
din = new DataInputStream(con.getInputStream());
bout = new ByteArrayOutputStream();
byte[] outBuffer = new byte[2048];
int readLen = 0;
do {
bout.write(outBuffer, 0, readLen);
readLen = din.read(outBuffer);
}
while(readLen > 0);
bout.flush();
}
else {
throw new IOException(Integer.toString(resCodes));
}
}
catch(MalformedURLException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
finally {
try {
if(dout != null) dout.close();
if(din != null) din.close();
if(con != null) con.disconnect();
} catch(IOException e) {
e.printStackTrace();
}
}
return bout.toByteArray();
}
}
2. XML 전문 설정 및 사용방법
2.1 설정방법
- $PFM_HOME/context/pfmdevsvr/WEB-INF/lib/PfmDevSvr.xml
- WAS의 라이브러리 패스를 이용하는 경우
- 사용 중인 서버가 JEUS lib 로 잡혀 있음.
- ../jeus5/lib/application/PfmDevSvr.xml
- PfmDevSvr.xml 의 configField id="CLASSPATH" 항목에 "$PFM_HOME/lib/common/stax-api-1.0.1.jar" 추가
-
<configField id="CLASSPATH" value="/home/proframe/proframe/lib/engine/proframe.jar:/home/proframe/proframe/lib/common/log4j-1.2.14.jar:/home/proframe/proframe/lib/common/freemarker.jar:/home/proframe/proframe/lib/common/stax-api-1.0.1.jar:/home/proframe/proframe/lib/common/wstx-asl-3.1.1.jar:/home/proframe/proframe/lib/common/wstx-lgpl-3.1.1.jar:/home/proframe/proframe/lib/common/jaxb-api.jar:/home/proframe/proframe/lib/common/jaxb-impl.jar:/home/proframe/proframe/lib/common/jaxb-libs.jar:/home/proframe/proframe/lib/common/jaxb-xjc.jar:/home/proframe/proframe/lib/common/jaxp-api.jar:/home/proframe/proframe/lib/common/jax-qname.jar:/home/proframe/proframe/lib/common/relaxngDatatype.jar:/home/proframe/proframe/lib/common/xsdlib.jar:/home/proframe/proframe/lib/devsvr/smd_fm_gen.jar:/home/proframe/proframe/lib/devsvr/jsr173_api-1.0.0.jar:/home/proframe/proframe/lib/devsvr/mapper-rt.jar:/home/proframe/proframe/lib/devsvr/pfm_jaxb_model.jar:/home/proframe/proframe/lib/devsvr/xbean-2.1.0.jar:/home/proframe/proframe/lib/devsvr/mapper-cg.jar:/home/proframe/proframe/lib/devsvr/meta-schemas.jar:/home/proframe/proframe/lib/devsvr/smd-c-codegen.jar:/home/proframe/proframe/pfm/classes/PFM_IO:/home/proframe/proframe/pfm/classes/PFM_DBIO:/home/proframe/proframe/pfm/classes/PFM_RULE:/home/proframe/proframe/pfm/classes/PFM_MODULES" type="String" xmlns=""/>
- $PFM_HOME/context/proframeWe.bxml/web.xml
-
<servlet>
<servlet-name>streamXMLHandler</servlet-name>
<servlet-class>proframe.core.ippr.http.ProFrameHttpStreamIppr</servlet-class>
<init-param>
<param-name>messageType</param-name>
<param-value>XML</param-value>
</init-param>
<load-on-startup>-1</load-on-startup>
</servlet>
... ...
<servlet-mapping>
<servlet-name>streamXMLHandler</servlet-name>
<url-pattern>/XMLSERVICES/*</url-pattern>
</servlet-mapping>
... ...
- 호출할 SO 에서 사용하는 DTO에 Fixed Length Message 를 생성한다.
-
<?xml version="1.0" encoding="EUC-KR"?>
<message>
<proframeHeader>
<pfmAppName>tester</pfmAppName>
<pfmSvcName>Test001So</pfmSvcName>
<pfmFnName>insertXml</pfmFnName>
<pfmFnCd/>
<pfmGlobalNo/>
<pfmChnlType/>
<pfmEnvrFlag/>
<pfmTrFlag/>
<pfmTrDate/>
<pfmTrTime/>
<pfmClntIp/>
<pfmResponseType/>
<pfmResponseCode/>
<pfmResponseLogcd/>
<pfmResponseTitle/>
<pfmResponseBasc/>
<pfmResponseDtal/>
<pfmUserId/>
<pfmFiller/>
<pfmLangCode/>
</proframeHeader>
<systemHeader>
<pfmTermnNo/>
<pfmTermnPstn/>
<pfmUserHdqt/>
<pfmUserBrch/>
<pfmUserBuspl/>
<pfmUserAgncy/>
<filler/>
</systemHeader>
< PreEmpPersistListDto>
<empno>6666</empno>
<ename></ename>
<job></job>
<mgr></mgr>
<sal></sal>
<comm></comm>
<deptno>10</deptno>
</ PreEmpPersistListDto>
</message>
- 예제 소스 ( TestProFrameXMLStream.java )
-
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class TestProFrameXMLStream {
public static void main(String[] args) {
TestProFrameXMLStream tester = new TestProFrameXMLStream();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
File inFile = new File("D:/XML.xml");
try {
FileInputStream fis = new FileInputStream(inFile);
byte[] inBuffer = new byte[2048];
int readLen = 0;
do {
readLen = fis.read(inBuffer);
bout.write(inBuffer, 0, readLen);
}
while(readLen == 2048);
bout.flush();
}
catch(FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
byte[] inXML = bout.toByteArray();
System.out.println("\n\n\n\n\n");
System.out.println("###################### IN #######################");
System.out.println(new String(inXML));
byte[] outXML = tester.testXMLStream(inXML);
System.out.println("\n\n\n\n\n");
System.out.println("###################### OUT #######################");
System.out.println(new String(outXML));
}
public byte[] testXMLStream(byte[] inXML) {
DataOutputStream dout = null;
DataInputStream din = null;
ByteArrayOutputStream bout = null;
HttpURLConnection con = null;
int resCodes = 0;
try
{
URL url = new URL("http://192.168.11.174:9876/proframeWeb/XMLSERVICES/");
con = (HttpURLConnection)url.openConnection();
con.setDoOutput(true);
dout = new DataOutputStream(con.getOutputStream());
dout.write(inXML);
dout.flush();
resCodes = con.getResponseCode();
if(resCodes == HttpURLConnection.HTTP_OK)
{
din = new DataInputStream(con.getInputStream());
bout = new ByteArrayOutputStream();
byte[] outBuffer = new byte[2048];
int readLen = 0;
do {
bout.write(outBuffer, 0, readLen);
readLen = din.read(outBuffer);
}
while(readLen > 0);
bout.flush();
}
else {
throw new IOException(Integer.toString(resCodes));
}
}
catch(MalformedURLException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
finally {
try {
if(dout != null) dout.close();
if(din != null) din.close();
if(con != null) con.disconnect();
} catch(IOException e) {
e.printStackTrace();
}
}
return bout.toByteArray();
}
}
3. Delimiter 전문 설정 및 사용방법
3.1 설정 방법
- $PFM_HOME/context/proframeWeb/WEB-INF/web.xml
-
... ...
<servlet>
<servlet-name>streamDELIMITERHandler</servlet-name>
<servlet-class>proframe.core.ippr.http.ProFrameHttpStreamIppr</servlet-class>
<init-param>
<param-name>messageType</param-name>
<param-value>DELIMITER</param-value>
</init-param>
<load-on-startup>-1</load-on-startup>
</servlet>
... ...
<servlet-mapping>
<servlet-name>streamDELIMITERHandler</servlet-name>
<url-pattern>/DELIMITERSERVICES/*</url-pattern>
</servlet-mapping>
... ...
- Delimiter 형식으로 보내줄 전문을 생성한다. ( D:/DELIMITER.txt )
-
TestPrj,TesterSOSO2,testEmp,,,,,,,,,,,,,,,,,|,,,,,,,,|7788,,,,,,,,
- ProFrameHeader 부분과 SystemHeader 는 proframe.xml의 다음 설정에 의해 Delimieter 문자가 정해진다.
-
... ...
<web-frame>
<record-cache>false</record-cache>
<datasource>proframeCache</datasource>
<fldmessage-suffix>MsgFld</fldmessage-suffix>
<part-delimiter>|</part-delimiter>
<data-delimiter>,</data-delimiter>
</web-frame>
... ...
- 예제 소스
-
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class TestProFrameDELIMITERStream {
public static void main(String[] args) {
TestProFrameDELIMITERStream tester = new TestProFrameDELIMITERStream();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
File inFile = new File("D:/DELIMITER.txt");
try {
FileInputStream fis = new FileInputStream(inFile);
byte[] inBuffer = new byte[2048];
int readLen = 0;
do {
readLen = fis.read(inBuffer);
bout.write(inBuffer, 0, readLen);
}
while(readLen == 2048);
bout.flush();
}
catch(FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
byte[] inXML = bout.toByteArray();
System.out.println("\n\n\n\n\n");
System.out.println("###################### IN #######################");
System.out.println(new String(inXML));
byte[] outXML = tester.testXMLStream(inXML);
System.out.println("\n\n\n\n\n");
System.out.println("###################### OUT #######################");
System.out.println(new String(outXML));
}
public byte[] testXMLStream(byte[] inXML) {
DataOutputStream dout = null;
DataInputStream din = null;
ByteArrayOutputStream bout = null;
HttpURLConnection con = null;
int resCodes = 0;
try
{
URL url = new URL("http://192.168.20.182:19876/proframeWeb/DELIMITERSERVICES/");
con = (HttpURLConnection)url.openConnection();
con.setDoOutput(true);
dout = new DataOutputStream(con.getOutputStream());
dout.write(inXML);
dout.flush();
resCodes = con.getResponseCode();
if(resCodes == HttpURLConnection.HTTP_OK)
{
din = new DataInputStream(con.getInputStream());
bout = new ByteArrayOutputStream();
byte[] outBuffer = new byte[2048];
int readLen = 0;
do {
bout.write(outBuffer, 0, readLen);
readLen = din.read(outBuffer);
}
while(readLen > 0);
bout.flush();
}
else {
throw new IOException(Integer.toString(resCodes));
}
}
catch(MalformedURLException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
finally {
try {
if(dout != null) dout.close();
if(din != null) din.close();
if(con != null) con.disconnect();
} catch(IOException e) {
e.printStackTrace();
}
}
return bout.toByteArray();
}
}
'Say! 머니곰 > IT' 카테고리의 다른 글
[FreeMarker] FreeMarker Manual (1) | 2010.06.21 |
---|---|
[Eclipse Project] Common Navigator Framework (0) | 2010.06.20 |
Transaction (0) | 2010.06.15 |
vi 명령어 정리 (1) | 2010.06.15 |
[GEF] 초심자를 위한 자료 목록 (0) | 2010.06.15 |