[Spring WebServices] Spring WebServices and JAX-WS HTTP Authentication




기존에 Spring WebServices 로 웹 서비스 클라이언트를 이용하려면 아래와 bean 을 이용하였습니다.






하지만 HTTP Authentication 을 거쳐야 한다면 -ㅁ-;;; 무언가의 작업이 필요합니다.


그냥 원래의 wsdl 주소를 읽으려고 하면 다음과 같은 오류가 발생합니다.



Caused by: javax.xml.ws.WebServiceException: Failed to access the WSDL at:



http://localhost:8080/WorkflowWebServices?wsdl



. It failed with:



Server returned HTTP response code: 401 for URL:



http://localhost:8080/WorkflowWebServices?wsdl



.








1. 브라우저를 통하여 wsdl 에 접근하여 해당 파일을 별도로 저장하여 클래스 패스에 위치시킵니다.

2. wsdlDocumentUrl 프로퍼티를 classpath 에서 읽을 수 있도록 설정합니다.

(해당 wsdl 자체에 접근하려면 인증이 필요한데 wsdl 을 읽을 단계에서는 인증처리가 안되기 때문입니다.)

3. username, password 프로퍼티를 설정합니다.

4. 웹 메소드 호출을 수행합니다.


username 과 password 가 옳지 않으면 다음과 같은 오류가 발생합니다.



Caused by: com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized




모든 조건을 만족하게 되면 정상적으로 웹 서비스의 웹 메소드를 호출할 수가 있습니다.




댓글

가장 많이 본 글