2012-09-07 5 views
1

사용자 이름과 암호로 보호되는 간단한 예제 webservice를 만들고 싶습니다. 내가 사용하는 출발점으로WS-Security : @EndpointConfig가 작동하지 않습니다.

: https://docs.jboss.org/author/display/JBWS/WS-Security

문제 : 심지어 웹 서비스 메소드를 호출 할 수 있습니다 잘못되거나 누락 된 자격 증명을 모든 클라이언트. 그래서 @EndpointConfig는 효과가없는 것처럼 보입니다. 하지만 디버깅 및 jboss 관리 콘솔을 사용하여 웹 서비스 구성에 대한 자세한 정보를 얻을 수 없었기 때문에 더 깊이 파고 드는 방법을 모르겠습니다.

WebService 클래스 :

@WebService(serviceName="MyWebService", portName="MyWebServicePort") 
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "myconfig") 
public class MyWebService{...} 

잭스 - WS-엔드 포인트-config.xml 파일 :

<?xml version="1.0" encoding="UTF-8"?> 
<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:javaee="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd"> 
    <endpoint-config> 
    <config-name>myconfig</config-name> 
    <property> 
     <property-name>ws-security.username</property-name> 
     <property-value>myusername</property-value> 
    </property> 
    <property> 
     <property-name>ws-security.password</property-name> 
     <property-value>mypassword</property-value> 
    </property> 
    </endpoint-config> 
</jaxws-config> 

어떤 제안이 승인되지 않은 클라이언트가 거부하려면?

+0

WSDL을 게시 할 수 있습니까? –

답변

1

기본적으로 WSDL에 정책을 게시해야합니다.

WSDL의 바인딩 부족 섹션을 추가해야합니다.

<binding name="SecurityServicePortBinding" type="tns:ServiceIface"> 
<wsp:PolicyReference URI="#SecurityServiceSignThenEncryptPolicy"/> 
... 
</binding> 

그리고 WSDL에 정책 정의 자체를 추가하십시오. 당신이 당신의 서비스 URL을 명중

<wsp:Policy wsu:Id="SecurityServiceSignThenEncryptPolicy" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
<wsp:ExactlyOne> 
    <wsp:All> 
    <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
    .... 
</wsp:ExactlyOne> 
</wsp:Policy> 

(예를 들어 http://localhost:8080/yourservice?wsdl), 당신은 반환 된 WSDL의 정책 참조를 볼 수 있어야합니다. 그렇지 않으면 인증/암호화가 수행되지 않습니다.

관련 문제