어제와 똑같이 살면서 다른 미래를 기대하지 말자

[Zend Framework] Soap 사용하기 본문

IT관심분야/PHP

[Zend Framework] Soap 사용하기

플랜액터 2011. 9. 19. 14:12
사이트나 어플리케이션 연동 시 XML을 많이 사용을 하고 있습니다. SOAP와 WSDL을 이용한 SOAP 통신을 알고는 있었지만 개발 기간과 귀차니즘으로 테스트를 하지 않았는데 확인을 해보니 간단하네요..^^
WSDL 모드는 테스트 해보니 잘 안되서 pass 했는데 혹시 아시는 분 안계시나요~ ㅠㅠ
Zend Framework 유져가 한국에도 좀 많았음 좋겠네요..

※ php-soap 모듈 확인을 하셔야 됩니다. (yum install php-soap)

1. Zend_Soap_Server & Zend_Soap_Client 사용 (WSDL 미사용)

class MyClass {

    public function method1()
    {
        return 'method1';
    }
   
    public function method2()
    {
        return 'method2';
    }
}

class InterlockController extends Controller_Action
{

    public function init()
    {
        //parent::init();
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
    }

    public function serverAction()
    {
        $server = new Zend_Soap_Server(null, array(
            // non-wsdl 이용 시 uri는 필수로 설정되어야 합니다.
            'uri' => 'http://example.com/interlock/server'
        ));
        $server->setClass('MyClass');
         $server->setObject(new MyClass());
        $server->handle();
    }
   
    public function customerAction()
    {
        $client = new Zend_Soap_Client(NULL, array(
             // non-wsdl 이용 시 uri와 location은 필수로 설정되어야 합니다.
            'location' => 'http://example.com/interlock/server',
            'uri' => 'http://example.com/interlock/server'
        ));
        echo $client->method1();
    }
}


※ 참조
http://www.ibm.com/developerworks/kr/library/x-zsoap/index.html
Comments