summaryrefslogtreecommitdiff
path: root/app/api/(S-ERP)
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-04-28 02:13:30 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-04-28 02:13:30 +0000
commitef4c533ebacc2cdc97e518f30e9a9350004fcdfb (patch)
tree345251a3ed0f4429716fa5edaa31024d8f4cb560 /app/api/(S-ERP)
parent9ceed79cf32c896f8a998399bf1b296506b2cd4a (diff)
~20250428 작업사항
Diffstat (limited to 'app/api/(S-ERP)')
-rw-r--r--app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_BIDDING_PROJECT/route.ts70
1 files changed, 70 insertions, 0 deletions
diff --git a/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_BIDDING_PROJECT/route.ts b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_BIDDING_PROJECT/route.ts
new file mode 100644
index 00000000..e942cbc5
--- /dev/null
+++ b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_BIDDING_PROJECT/route.ts
@@ -0,0 +1,70 @@
+// /app/api/soap/route.js
+import { NextRequest, NextResponse } from 'next/server';
+import { headers } from 'next/headers';
+
+export async function POST(request: NextRequest) {
+ try {
+ // SOAP 요청 본문 가져오기
+ const body = await request.text();
+ const headersList = headers();
+
+ // 요청 로깅
+ console.log('SOAP Request:', body);
+ console.log('Headers:', headersList);
+
+ // 요청 처리 로직
+ // SAP에서 보낸 데이터를 파싱하고 DB에 저장
+ const data = parseSoapMessage(body);
+ await saveToDatabase(data);
+
+ // SOAP 응답 생성
+ const soapResponse = `<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:receiveDataResponse xmlns:ns1="http://60.101.108.100/soap">
+ <result>success</result>
+ </ns1:receiveDataResponse>
+ </soap:Body>
+</soap:Envelope>`;
+
+ return new NextResponse(soapResponse, {
+ headers: {
+ 'Content-Type': 'application/xml',
+ },
+ });
+ } catch (error) {
+ console.error('SOAP Error:', error);
+
+ // 에러 응답
+ const errorResponse = `<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <soap:Fault>
+ <faultcode>soap:Server</faultcode>
+ <faultstring>${error.message}</faultstring>
+ </soap:Fault>
+ </soap:Body>
+</soap:Envelope>`;
+
+ return new NextResponse(errorResponse, {
+ status: 500,
+ headers: {
+ 'Content-Type': 'application/xml',
+ },
+ });
+ }
+}
+
+// SOAP 메시지 파싱 함수
+function parseSoapMessage(soapMessage) {
+ // XML 파싱 로직 구현
+ // 라이브러리 사용 예: fast-xml-parser, xml2js 등
+ // 실제 구현은 SAP 메시지 형식에 따라 달라짐
+ return { /* 파싱된 데이터 */ };
+}
+
+// DB 저장 함수
+async function saveToDatabase(data) {
+ // 데이터베이스 저장 로직
+ // Prisma, Mongoose 등 사용
+} \ No newline at end of file