2014-03-12 3 views
1

프로젝트가 Java 웹 애플리케이션이지만 클라이언트로서 만 웹 서비스를 사용합니다.Axis2 클라이언트 프로젝트 내에서 Rampart 모듈을로드 할 수 없습니다.

Apache Axis2로 스텁을 성공적으로 작성하고 SoapUI로 테스트했습니다. 이제 보안을 구현할 차례입니다. This is 내가 통합해야하는 서비스 중 하나. WS-Security 정책을 제공하므로 자격 증명을 올바르게 전송해야합니다.

내 프로젝트에 Apache Rampart를 통합하려고합니다. 필요한 JAR 및 MAR 파일을 다운로드하는 데 많은 어려움이 있음을 발견했지만 사용했습니다.

webapp 
    -- WEB-INF 
     -- classes 
     -- conf 
      -- axis2.xml 
     -- modules 
      -- several -mar files 
      -- rampart-1.6.2.mar 
      -- modules.list 
     -- spring 
      -- various context files 
     -- web.xml 

나는 봄이 웹 서비스 스텁을 포함한 모든 콩을 초기화하는 데 사용

는 이제 다음 프로젝트 구조를 가지고있다. Spring이 정상적으로 인스턴스화하도록하면 예상대로 작동합니다. 나는 성벽 모듈 참여를 유도하기 위해 BeanPostProcessor을 사용하지만 그것이 내가 addressing

<module ref="rampart" />을 추가 한 내 axis2.xml에서

Caused by: org.apache.axis2.AxisFault: Unable to engage module : rampart 
at org.apache.axis2.client.ServiceClient.engageModule(ServiceClient.java:363) 
at it.csttech.edwin.security.SecurityHandler.engage(SecurityHandler.java:52) 

실패합니다 다음 코드와 램 파트를 활성화합니다

RampartConfig rc = new RampartConfig(); 
    rc.setUser(user); 
    Policy policy = PolicyEngine.getPolicy(new StAXOMBuilder(policyStream).getDocumentElement()); //XML policy file in classpath 
    policy.addAssertion(rc); 
    serviceClient.engageModule("rampart"); //this fails 
    Options options = serviceClient.getOptions(); 
    options.setProperty(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler); //This will provide password 
    options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy); //This will provide policy 

나는 내가하는 것을 발견했다 Map<String, AxisModule> modules = serviceClient.getAxisConfiguration().getModules(); 나는 단지 빈지도를 얻는다! !!!

모듈이 전혀로드되지 않습니다.

그런 다음 모듈/디렉토리를 하드 드라이브의 다른 위치로 이동하고 시스템 속성 axis2.repo을 통해 링크하려고 시도했지만 악의적 인 경로를 기꺼이 설정하면 Axis2가로드되지 않더라도로드되지 않습니다. 파일과지도는 여전히 비어 있습니다.

나는 정신 나간다. Rampart를 제대로 설치하는 방법을 모르겠습니다. Spring IoC를 사용하여 적절한 구성을 주입하거나 Rampart를 모든 서비스에 투입 할 수 있는지 여부조차 모르겠습니다.

답변

0

ConfigurationContext를 생성 해보고 ServiceClient를 사용할 수 있습니다.

// create configuration context 
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(RESOURCES_DIR, null); 

// create service client 
ServiceClient serClient = new ServiceClient(ctx, null); 

// engage modules 
serClient.engageModule("rampart"); 

여기서 'RESOURCES_DIR'은 .mar 파일의 위치를 ​​가리켜 야합니다.

+0

같은 오류가 발생했습니다. System.getProperty ("axis2.repo")가 올바른 방향 (즉, "C :/path/to/modules /")으로 평가되는지 3 번 확인했습니다. –

관련 문제