SOA/WS/ebXML/ebXML

ebxml 레지스트리 구조 1

아름프로 2003. 4. 18. 16:09
아래 제 강의를 통해서 ebxmlrr을 설치하고 사용해 보신 분들은 개념적으로 나마
ebxml 레지스트리/리파지 토리가  무슨일을 하는지 느끼셨을 겁니다.

이제 좀더 하부구조를 살펴 보도록 하겠습니다.

ebxmlrr은  
http://localhost:8080/ebxmlrr/registry/soap  이 주소로 항상 메시지를 보내도록 만들어 졌습니다.

여기서 메시지를 기다리는 친구는
com.sun.ebxml.registry.interfaces.soap 밑의 RegistryJAXMServlet 란 객체입니다.


이 객체 안에는
public void init() throws ServletException {
        try {
            log.info("------------------------------------------ ");
            log.info("init ");
            log.info("------------------------------------------ ");
            XalanVersion.verifyVersion();
            //initialise XML Security library
            org.apache.xml.security.Init.init();
        } catch (Exception ex) {
            log.fatal("init failed", ex);
            throw new ServletException(ex);
        }
    }

위와 같은 초기 화 메쏘드가 존재하는데
탐캣을 시작하시면 위 메쏘드가 호출 되고 ebxmlrr이 서비스 대기 모두에 들어갑니다.

그리고 우리가 레지스트리 브라우져를 실행하고 접속을 요청하면
( 그때 사실 classication scheme 을 가져오라는 adhocquery를 요청하게 됩니다)
이 객체의 onMessage ( SOAPMessage msg)
부분이 호출됩니다.


    public SOAPMessage onMessage(SOAPMessage msg) {
        //System.err.println("onMessage called for RegistryJAXMServlet");
        
        log.info("onMessage()  ");
        SOAPMessage soapResponse = null;
        
        try {
            
    
           .... 생략

           // xml to Request Object
           //  

            Request request = new Request(headerSignature,
BindingUtility.getInstance().getRequestObject(requestRootElement, requestXML), idToRepositoryItemMap);
          //  log.info( requestXML);

            System.out.println( requestXML);            
            System.out.println( requestRootElement);            
           }
}

이번 강의 에서 설명할 부분은
위의 onMessage 메쏘드중 Request  객체를 생성하는 부분입니다.

개념을 설명 하면
레지스트리 브라우져가 ebxml rs 스펙에 준하는 요청을 xml 형태로 하게 됩니다.
이 메시지는 soap 형태로 ebxmlrr에 전달되는데
그 후에 soap message 에서   요청 문서를 꺼내 서 처리를 해야합니다.
그런데 요청은 AdhocQueryRequest, SubmitRequest, RemoveRequest ..
등 다양하기 때문에
아마 이런식으로 처리를 해야 할 것입니다.
도착한 xml 문서를 가지고 이것이 위의 요청중 어떤 요청인지 먼저 판별하고
만약 AdhocQueryRequest이면 이에 관한 요청 객체를 생성 처리,하고
SubmitRequest 이면 이에 관한 요청 객체를 생성해야 할 것입니다.
따라서 필요한 것은 xml 로 부터  조건에 따라 객체를 생성하는 것인데
이것은 castor 란 프레임 워크가 지원합니다.

이제 코드로 다시 돌아가서

    Request request = new Request(headerSignature,
BindingUtility.getInstance().getRequestObject(requestRootElement, requestXML), idToRepositoryItemMap);

에서 Request 객체를 살펴 보면 요청 객체를 생성 할때 BindingUtility를 사용합니다.

그래서 BindingUtility 의 getRequestObject 를 살펴 보면

                      
        public Object getRequestObject(String rootElement, String message) throws RegistryException {
                Object req = null;
                
                try {
if (rootElement.equals("AdhocQueryRequest")) {

req = AdhocQueryRequest.unmarshal(new StringReader(message));


}

ellse if (rootElement.equals("GetContentRequest")) {

req = GetContentRequest.unmarshal(new StringReader(message));


}
                        

    catch (org.exolab.castor.xml.MarshalException e) {
                throw new RegistryException(e);
                }
                catch (org.exolab.castor.xml.ValidationException e) {
                        throw new RegistryException(e);
                }
                
                return req;
}


위의 코드에서 보는 바와 같이

rootElement.equals("AdhocQueryRequest")  이면

req = AdhocQueryRequest.unmarshal(new StringReader(message));

요청 객체는 AdhocQueryRequest 가 되는 것입니다.
그런 이 요청 객체를 생성하는 방법은 xml 문서로 부터 직접 생성합니다.

AdhocQueryRequest 안을 들여야 보면

import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.exolab.castor.xml.Validator;
import org.xml.sax.DocumentHandler;

public class AdhocQueryRequest implements Serializable
{
    private ResponseOption _responseOption;
    private AdhocQueryRequestChoice _adhocQueryRequestChoice;


    public static AdhocQueryRequest unmarshal(Reader reader)
        throws MarshalException, ValidationException {
        return ((AdhocQueryRequest)
                (Unmarshaller.unmarshal
                 (((class$org$oasis$ebxml$registry$bindings$query$AdhocQueryRequest
                    == null)
                   ? (class$org$oasis$ebxml$registry$bindings$query$AdhocQueryRequest
                      = (class$
                         ("org.oasis.ebxml.registry.bindings.query.AdhocQueryRequest")))
                   : class$org$oasis$ebxml$registry$bindings$query$AdhocQueryRequest),
                  reader)));
    }
    
   }

보시다 시피

public static AdhocQueryRequest unmarshal(Reader reader)


xml을 통해 AdhocQueryRequest를 리턴 하는 메쏘드가 존재합니다.
물론 이 ummarshal은 캐스터 프레임 워크의 것입니다.


        




***** 아름다운프로님에 의해서 게시물 복사 + 카테고리변경되었습니다 (2003-12-18 16:51)