JAX-WS 웹 서비스에서 WSDL 바인딩에 대한 준수 강제 실행

JAX-WS(Java™ API for XML-Based Web Services) 버전 2.1에서는 특정 기능 및 동작을 프로그래밍 방식으로 제어하는 방법인 기능(feature)의 개념을 도입했습니다. RespectBindingFeature는 지원되는 표준 기능 중 하나입니다. RespectBindingFeature를 사용하여 JAX-WS 구현이 엔드포인트와 연관된 WSDL(Web Services Description Language) 바인딩의 컨텐츠를 요청하는 데 필요한지 여부를 제어할 수 있습니다.

이 태스크 정보

WSDL 문서는 개발 프로세스에 종종 사용되지만 런타임 시 제공된 WSDL 문서 스펙의 사용을 실제로 강제 실행하는 것은 버전 2.1 이전의 JAX-WS 스펙 버전에서는 제대로 정의되어 있지 않습니다. JAX-WS 버전 2.1 스펙에서는 RespectBindingFeature 기능이 추가되어 JAX-WS 런타임 환경에서 wsdl:binding의 영향을 명료화했습니다.

RespectBindingFeature 기능을 사용으로 설정하면 JAX-WS 런타임 환경에서 런타임 시 엔드포인트에 대한 wsdl:binding을 검사하여 SEI(Service Endpoint Interface) 매개변수 및 리턴 값의 바인딩이 준수되는지 확인할 수 있습니다. 또한 이 기능을 사용하면 모든 필수 wsdl:binding 확장이 런타임 환경에서 파악되어 사용되거나, 애플리케이션에서 이 확장을 명시적으로 사용 안함으로 설정하도록 할 수 있습니다. JAX-WS 애플리케이션에서는 이 기능과 연관된 적절한 어노테이션을 사용하거나, javax.xml.ws.WebServiceFeature 인터페이스를 허용하는 API를 사용하거나, 배치 디스크립터를 구성하여 WebServiceFeature 인터페이스가 정의된 특정 wsdl:binding 확장을 사용 안함으로 설정할 수 있습니다.

RespectBindingFeature 기능을 사용으로 설정(기본값)하지 않으면 런타임 환경에서 wsdl:binding의 임의 파트를 강제 실행할지 여부를 선택할 수 있습니다.

프로시저

  1. 웹 서비스 애플리케이션을 나타내는 WSDL(Web Services Description Language) 파일을 포함하는 JAX-WS 애플리케이션에 대한 Java 아티팩트를 개발하십시오.
    1. WSDL 파일을 사용하여 시작하는 경우, wsimport 명령을 통해 WSDL 파일에서 Java 아티팩트를 개발하여 필요한 JAX-WS 이식 가능 아티팩트를 생성하십시오.
    2. JavaBeans 컴포넌트를 사용하여 시작하는 경우 JAX-WS 애플리케이션에 대한 Java 아티팩트를 개발하고 wsgen 명령을 사용하여 WSDL 파일을 생성하십시오.
  2. 엔드포인트 구현 클래스에서 RespectBindingFeature를 사용으로 설정하려면 다음 메소드 중 하나를 사용하십시오.
    • 엔드포인트에서 @RespectBinding 어노테이션을 사용하십시오.

      엔드포인트에서 RespectBinding을 사용으로 설정하려면 엔드포인트에서 @RespectBinding(javax.xml.ws.RespectBinding) 어노테이션을 사용하십시오. @RespectBinding 어노테이션에는 한 개의 매개변수 enabled만 있습니다. 이 매개변수는 선택적입니다. 이 enabled 매개변수는 부울 값을 가지며 RespectBindingFeature가 JAX-WS 엔드포인트에 대해 사용으로 설정되는지를 표시합니다.

      다음 스니펫 예에서는 JAX-WS MyServiceImpl 엔드포인트에 대해 @RespectBinding 어노테이션을 추가하는 것을 보여줍니다.
      @RespectBinding(enabled=true))
      @WebService
      public class MyServiceImpl {
      ...
      }
    • <respect-binding> 배치 디스크립터 요소를 사용하십시오.
      서비스 엔드포인트 구현 클래스에서 @RespectBinding 어노테이션을 사용하는 대신에 webservices.xml 배치 디스크립터의 <port-component> 요소에서 <respect-binding> 요소를 사용할 수 있습니다. 예를 들면, 다음과 같습니다.
      <port-component>
           <port-component-name>MyPort1</port-component-name>
           <respect-binding>
               <enabled>true</enabled>
           </respect-binding>
           <service-impl-bean>
               <servlet-link>MyPort1ImplBean</servlet-link>
           </service-impl-bean>
      </port-component>
  3. 클라이언트에서 RespectBindingFeature를 사용으로 설정하려면 다음 메소드 중 하나를 사용하십시오.
    • 디스패치 클라이언트에서 RespectBindingFeature를 사용으로 설정하십시오. 예를 들면, 다음과 같습니다.
      RespectBindingFeature respectBinding = new RespectBindingFeature();
      Service svc = Service.create(serviceName);
      svc.addPort(portName, SOAPBinding.SOAP11_HTTP_BINDING, endpointUrl);
      Dispatch<Source> dsp = svc.createDispatch(portName, Source.class, Service.Mode.PAYLOAD, respectBinding);
    • 동적 프록시 클라이언트에서 RespectBindingFeature를 사용으로 설정하십시오. 예를 들면, 다음과 같습니다.
      // Create a dynamic proxy with RespectBinding enabled.
        Service svc = Service.create(serviceName);
        RespectBindingFeature respectBinding = new RespectBindingFeature();
        RespectBindingSample proxy = svc.getPort(portName, RespectBindingSample.class, respectBinding);
    • @RespectBinding 어노테이션을 사용하여 클라이언트에서 RespectBindingFeature를 사용으로 설정하십시오. 예를 들면, 다음과 같습니다.
      public class MyClientApplication {
      
                     // Enable RespectBinding for a port-component-ref resource injection.
                         @RespectBinding(enabled=true)
                         @WebServiceRef(MyService.class)
                         private MyPortType myPort;
                     ...
      }
    • port-component-ref 요소 내의 배치 디스크립터 요소를 사용하여 클라이언트에서 RespectBindingFeature를 사용으로 설정하십시오. 예를 들면, 다음과 같습니다.
      <service-ref>
          <service-ref-name>service/MyPortComponentRef</service-ref-name>
          <service-interface>com.example.MyService</service-ref-interface>
          <port-component-ref>
              <service-endpoint-interface>com.example.MyPortType</service-endpoint-interface>
              <respect-binding>
                  <enabled>true</enabled>
              </respect-binding>
          </port-component-ref>
      </service-ref>

결과

RespectBindingFeature 기능을 구현함으로써 JAX-WS 애플리케이션에서 엔드포인트와 연관된 WSDL 바인딩의 컨텐츠 준수를 강제 실행하도록 지정했습니다.


주제 유형을 표시하는 아이콘 태스크 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_enablerespectbindingfeature
파일 이름:twbs_enablerespectbindingfeature.html