2010-12-28 2 views
0

axis2를 사용하여 wsdl2java로 java 클라이언트를 생성했습니다. 내 클라이언트 프로그램이 성공적으로 webservice에 연결할 수 있습니다. 비누 메시지를 읽으려는 나가는 비누 요청을 기록하고 싶습니다.축 2 비누 로깅

Axis2에서 비누 메시지를 어떻게 기록 할 수 있습니까?

+0

사람이, 축 스텁을 사용하여 클라이언트 측에서 요청 - 응답 SOAP를 기록하는 방법에 대한 아이디어를 가지고 자세한 내용은 http://axis.apache.org/axis2/java/core/docs/modules.html을 확인? – Jayesh

답변

1

Axis2 데이터 바인딩을 사용하는 경우 웹 서비스의 자동 생성 클래스는 모두 ADBBean의 하위 클래스가됩니다. 다음과 같은 것을 사용하여 ADBBean을 문자열로 변환 한 다음 문자열을 기록 할 수 있습니다.

public static String 
writeADBBean(ADBBean aBean) throws XMLStreamException { 
    if (null == aBean) 
     return "null"; 
    OMElement omElement; 
    try 
    { 
     // The preferred way of serializing objects generated by Axis2's 
     // WSDL2JAVA involves methods that are named the same on every 
     // class but that aren't inherited from any base class. So, use 
     // reflection to find them. 
     QName qname; 
     try { 
      Field qnameField = aBean.getClass().getField("MY_QNAME"); 
      qname = (QName)qnameField.get(aBean); 
     } catch (Exception e) { 
      // Some Axis2-generated objects don't have QNames. Supply 
      // one based on the object's class. 
      qname = new QName(aBean.getClass().getCanonicalName()); 
     } 
     Method getOMElement = aBean.getClass().getMethod("getOMElement", QName.class, OMFactory.class); 
     omElement = (OMElement)getOMElement.invoke(aBean, qname, OMAbstractFactory.getOMFactory()); 
    } catch (Exception e) { 
     log.warn("Reflection failed for " + aBean.toString() + ": " + e.toString()); 
     throw new XMLStreamException("Cannot serialize " + aBean.toString(), e); 
    } catch (NoClassDefFoundError e) { 
     log.error("NoClassDefFoundError while serializing " + aBean.toString() + ": " + e.toString()); 
     throw new XMLStreamException("Cannot serialize " + aBean.toString(), e); 
    } 
    String serialized = omElement.toStringWithConsume(); 
    return serialized; 
} 
2

나는이 오래된 질문 실현하지만, 경우에 그것은 당신의 서버 config.wsdd 파일에 globalConfig의 <requestFlow><responseFlow> 섹션 모두에이 태그를 넣어 당신이 로깅을 설정 할 수있는 모든 사용자를하는 데 도움이 :

<handler type="java:org.apache.axis.handlers.LogHandler"/> 
+1

이것은 Axis 1.x와 관련이 있지만 질문은 Axis2에 관한 것입니다. –

2
당신이 추가 로깅에 대한 사용자 정의 축 모듈을 작성 고려할 수

-

관련 문제