태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

티스토리 툴바



nusoap을 사용한 soap으로 데이터 받아서 저장하기 예제 입니다.
네이년, 구글 등에서 이것저것 긁어모아 테스트 용으로 작성했습니다..
bash 쉘에서, php를 사용하여 만든 실행파일(쉘) 입니다.

nusoap이나 php 등에 대해서는 저도 잘 모르니..

아래 예제는 테스트 용이라.. 좀더 효율적(?... 워낙 간단해서. ㅋ)으로 만들거나 유용하게 만들 수도 있겠지만~ 기본적인 구조를 보고 참조하기엔 좋으리라 보옵니다..


#!/home/test/php -q
<?php
/*
 *    라이브러리 호출
 */
require_once('lib/nusoap.php');

// 받아온 내용을 파일로 쓰기..
function writeFile($response, $type, $result_dir){
        $file = fopen($result_dir."temp".$type.".txt", "w");
        //fwrite($file, iconv("UTF-8", "CP949", $response));
        fwrite($file, $response);
        fclose($file);

        //encoding 변환
        echo "iconv -c -f UTF-8 -t CP949 -o ".$result_dir."vk".$type.".txt ".$result_dir."temp".$type.".txt";
        system("iconv -c -f UTF-8 -t CP949 -o ".$result_dir."vk".$type.".txt ".$result_dir."temp".$type.".txt");

        //원본 파일 삭제
        system("rm -f ".$result_dir."temp*.txt");
}

$type = $argv[1];
$result_dir = $argv[2];

$client = new nusoap_client("http://test.co.kr/webservice/DocLitEchoService.ws?wsdl", true );
$client->xml_encoding = "UTF-8";
$client->soap_defencoding = "UTF-8";
$client->decode_utf8 = false;

/**
*     에러 처리.
**/
$err = $client->getError();
if ($err) {
        echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
        echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
        exit();
}
/**
$params = array(
    'in0'       => '15',
    'in1'       => '20090101',
    'in2'       => '20090115'
);
**/
$params = array(
    'in0'       => $type
);

$result = $client->call('echoString', $params, '', '', false, true);

// 요청 보기..
//echo '<h2>Request</h2>';
//echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';

if ($client->fault) {
        echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; print_r($result); echo '</pre>';
} else {
        $err = $client->getError();
        if ($err) {
                echo '<h2>Error</h2><pre>' . $err . '</pre>';
                echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
        } else {
                //echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
                //header("Content-Type: text/html; charset=UTF-8");
                //echo '<pre>' . $client->response . '</pre>';

                writeFile($result[echoStringReturn], $type, $result_dir);
                //echo $result[echoString_doubleReturn];
        }
}

?>


TAG , , ,

댓글을 달아 주세요

1  ... 60 61 62 63 64 65 66 67 68  ... 269 

글 보관함

카운터

Total : 196,909 / Today : 51 / Yesterday : 63
get rsstistory!