WS를 호출 할 수 있도록 WS 클라이언트를 보호하려고합니다.
내 코드는 다음과 같습니다UsernameToken (SOAP 보안 헤더)을 사용하여 WS 클라이언트 보안
SendSmsService smsService = new SendSmsService();
SendSms sendSMS = smsService.getSendSms();
BindingProvider stub = (BindingProvider)sendSMS;
//Override endpoint with local copy of wsdl.
String URL ="";//here is the wsdl url
Map<String,Object> requestContext = stub.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, URL);
//Set usernametoken
URL fileURL = loader.getResource("client-config.xml");
File file = new File(fileURL.getFile());
FileInputStream clientConfig = null;
try {
clientConfig = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
XWSSecurityConfiguration config = null;
try {
config = SecurityConfigurationFactory.newXWSSecurityConfiguration(clientConfig);
} catch (Exception e) {
e.printStackTrace();
log.warn("Exception: "+e.getMessage());
}
requestContext.put(XWSSecurityConfiguration.MESSAGE_SECURITY_CONFIGURATION, config);
//Invoke the web service
String requestId = null;
try {
requestId = sendSMS.sendSms(addresses, senderName, charging, message, receiptRequest);
} catch (PolicyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
및 설정 파일은 다음과 같습니다
<xwss:JAXRPCSecurity xmlns:xwss="http://java.sun.com/xml/ns/xwss/config" optimize="true">
<xwss:Service>
<xwss:SecurityConfiguration dumpMessages="true"
xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
<xwss:UsernameToken name="username" password="password>
</xwss:SecurityConfiguration>
</xwss:Service>
<xwss:SecurityEnvironmentHandler>
util.SecurityEnvironmentHandler
</xwss:SecurityEnvironmentHandler>
</xwss:JAXRPCSecurity>
을 SecurityEnviromentHandler는 javax.security.auth.callback.CallbackHandler를 구현하는 더미 클래스입니다.
인증은 Oasis 웹 서비스 보안 사용자 이름 토큰 프로파일 1.0을 준수해야합니다.
하지만 계속해서 "보안 헤더 유효하지 않음"오류가 발생합니다.
내가 어디로 잘못 가고 있는지, 누구든지 말해 줄 수 있습니다.
나는 (내 클라이언트 클래스를 생성 JAX_WS 2.1) wsimport의 사용
참고 :이 WS에 대해 알고 한가지 내가 문제를 해결
안녕하세요, 질문보다는 대답을 제시하는 것이 좋습니다. – Benjol