JAX-RPC Generichandler는 WebSphere Application Server v6.0.2.35에서 실패합니다

StackOverflow https://stackoverflow.com/questions/1806412

  •  05-07-2019
  •  | 
  •  

문제

SoapheaderHandler라는 Generichandler의 확장을 만들었습니다. 핸들러에 log4j 문을 배치했으며 생성자가 구축되는 것을 볼 수 있습니다. 그러나 SOAP 메시지를 생성 할 때 Handlerequest 메소드와 관련된 메시지가 표시되지 않습니다. 다음과 같이 스텁에 핸들러를 등록했습니다.

if (service == null) {
    super.service = new com.ibm.ws.webservices.engine.client.Service();
}
else {
    super.service = service;
}
List handlerInfoList = new ArrayList();
QName[] headersArr = null;
HandlerInfo handlerInfo = new HandlerInfo(com.xxxxxx.hdhp.business.debitcard.cardservices.CardServiceSOAPHeaderHandler.class, 
     null, headersArr);
handlerInfoList.add(handlerInfo);
service.getHandlerRegistry().setHandlerChain(new QName("MetavanteDebitCard"), handlerInfoList);

핸들러는 다음과 같습니다.

public class AccountManagementSOAPHeaderHandler extends GenericHandler {
 private static Logger logger = Logger.getLogger  (AccountManagementSOAPHeaderHandler.class);
 private HandlerInfo handlerInfo = null;

public AccountManagementSOAPHeaderHandler () {
 logger.info("Constructing AccountManagementSOAPHeaderHandler");
}

 /* (non-Javadoc)
  * @see javax.xml.rpc.handler.GenericHandler#getHeaders()
  */
 public QName[] getHeaders() {
 logger.info("calling getHeaders()");
  return null;
 }

 public boolean handleFault(MessageContext arg0) {
     logger.info("Fault in AccountManagementSOAPHeaderHandler");
  return true;
 }
 public boolean handleResponse(MessageContext arg0) {
   logger.info("Response in AccountManagementSOAPHeaderHandler");
   return true;
 }
 public void init(HandlerInfo arg0) {
  logger.info("init in AccountManagementSOAPHeaderHandler");
  handlerInfo = arg0;
  super.init(arg0);
 }

 public void destroy() {
  logger.info("--- In AccountManagementSOAPHeaderHandler.destroy ()");
 } 

 public boolean handleRequest(MessageContext ctx) {
     logger.debug("BEGIN handleRequest()");
     if (ctx instanceof SOAPMessageContext) {
        SOAPMessageContext context = (SOAPMessageContext) ctx;
        logger.debug("instance of SOAPMessageContext");
        try {
           SOAPHeader header = context.getMessage().getSOAPPart()
                .getEnvelope().getHeader();
           logger.debug("SOAP Header is " + ((header==null)?"NULL":"NOT NULL"));
           Iterator headers = header
                .extractHeaderElements("http://schemas.xmlsoap.org/soap/actor/next");
           while (headers.hasNext()) {
               SOAPHeaderElement he = (SOAPHeaderElement) headers.next();
               logger.info("HEADER Qn " + he.getElementName().getQualifiedName());
           }
       } catch (SOAPException x) {
           logger.error("SOAPException while handlingRequest for SOAP: '" + x.getMessage() + "'");
   }
  }
 return true;
}

다음과 같이 web.xml을 변경했습니다.

   <service-ref>
        <description>WSDL Service AccountManagerService</description>
        <service-ref-name>service/AccountManagerService</service-ref-name>
        <service-interface>com.medibank.www.AccountManagerService</service-interface>
<!--        <wsdl-file>WEB-INF/wsdl/AccountManagerService.asmx.wsdl</wsdl-file>-->
        <jaxrpc-mapping-file>WEB-INF/AccountManagerService.asmx_mapping.xml</jaxrpc-mapping-file>
        <service-qname xmlns:pfx="http://www.medibank.com/MBIWebServices/Access/Services/AccountManager/2004/06/">pfx:AccountManagerService</service-qname>
        <port-component-ref>
            <service-endpoint-interface>com.medibank.www.AccountManagerServiceSoap</service-endpoint-interface>
        </port-component-ref>
        <port-component-ref>
            <service-endpoint-interface>com.medibank.www.AccountManagerServiceSoap</service-endpoint-interface>
        </port-component-ref>
        <handler>
         <description>
         </description>
         <display-name></display-name>
         <handler-name>AccountManagementSOAPHeaderHandler</handler-name>
         <handler-class>com.xxxxx.hdhp.business.debitcard.accountmanagement.AccountManagementSOAPHeaderHandler</handler-class>
        </handler>
    </service-ref>

이것은 WebSphere Application Server v6.0.2.35에 배포됩니다. 문제가 무엇인지 아이디어가 있습니까? 핸들러의 로거 진술이 실행되지 않는 이유는 무엇입니까? 핸들러를 올바르게 등록하지 못했습니까? 어떤 서비스 방법을 처리 해야하는지 지정해야합니까?

도움이 되었습니까?

해결책

나는 실행되는 Jax-RPC 비누 클라이언트 몇 개를 6.0으로 썼으며, 메시지를 요청하기 위해 사용자 정의 비누 헤더를 추가하는 GenerichandLers가 필요합니다. 또한 클라이언트 코드베이스에서 서비스 -ref를 사용하지 않아야 할 필요가 있었으므로 클라이언트 클래스는 프로그래밍 방식으로 핸들러를 설정합니다. 이것은 구성의 작동 방식에 정확하게 적용되지 않을 수 있지만 무언가가 사용될 수 있습니다.

ANT에서 RAD 7.5의 WSDL2Java 도구로 생성 된 클라이언트 코드로 시작했지만 "웹 서비스 클라이언트"마법사도 사용합니다. 그것은 모든 비즈니스 객체, 시리얼 라이저/사막화기, 로케이터 및 비누 바인딩 클래스 등을 만들었습니다. 그런 다음 나는 당신이 가진 것과 유사한 맞춤형 Generichandler를 만들었습니다.

서비스 레프를 사용할 수 없었기 때문에 그런 식으로 클라이언트에게 바인딩 할 수 없었습니다. 그래서 클라이언트 클래스 자체의 다음 코드를 사용하여 핸들러를 프로그래밍 방식으로 추가했습니다.

private AccountManager createAccountManagerStub() throws Exception {
    AccountManagerServiceLocator locator = new AccountManagerServiceLocator();

    // Set the JMS endpoint address
    AccountManagerSOAPBindingStub accountManagerStub = (AccountManagerSOAPBindingStub) locator
            .getAccountManagerSOAPPort(new URL(generateJMSEndpointAddress()));

    // Set the Client Handler
    HandlerRegistry registry = locator.getHandlerRegistry();
    List chain = registry
            .getHandlerChain((QName) locator.getPorts().next());
    HandlerInfo handlerInfo = new HandlerInfo();
    handlerInfo.setHandlerClass(AccountManagerClientHandler.class);
    chain.add(handlerInfo);

    return (AccountManager) accountManagerStub;
}

해당 메소드에 의해 반환 된 객체가 완전히 설정되어 있으며 해당 클래스의 클라이언트 메소드를 호출하는 것이 올바르게 작동합니다. ac

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top