예: WS-Notification 이용자 등록

제공된 코드 추출 예를 기반으로 브로커에 공개자(생성자) 애플리케이션을 등록하여 공개자 등록 역할을 수행하는 JAX-RPC 클라이언트에 대한 코드를 작성하려면 이 태스크를 사용합니다.

이 태스크 정보

이 예제는 XML 기반 원격 프로시저 호출(JAX-RPC) API용 Java™ API를 WS-Notification 서비스 지점 작성의 결과로 생성된 알림 브로커 WSDL에 대해 실행되는 WSDL2Java 도구를 사용하여 생성된 코드와 WebSphere® Application Server API 및 SPI와 함께 사용하는 것을 기반으로 합니다.

WebSphere Application Server에서는 WS-Notification 서비스의 두 가지 구현(버전 6.1 및 버전 7.0)이 있습니다. 이 JAX-RPC 예제는 버전 6.1 또는 버전 7.0 WS-Notification 서비스 지점과 상호작용할 수 있습니다. 그러나 정책 세트가 있는 WS-Notification을 사용하려면(예를 들어, WS-ReliableMessaging이 있는 컴포지션을 사용하려면), WS-Notification 애플리케이션이 XML 기반 웹 서비스(JAX-WS) 프로그래밍 모델용 Java API를 사용하도록 인코딩되어야 하며 버전 7.0 WS-Notification 서비스 지점과 상호작용해야 합니다. JAX-WS 클라이언트 애플리케이션 프로그래밍에 생소하면 다음 주제를 참조하십시오. WS-Notification용 JAX-WS 애플리케이션 작성 문서에는 JAX-WS 등록자 클라이언트 애플리케이션의 예가 포함됩니다.
원시 등록:

이 예에서 첫 번째 선택적 코드 블록은 원시 등록을 작성하는 방법을 보여줍니다. 이 개념은 웹 서비스 기본 알림 스펙의 섹션 4.2에 정의됩니다.

일반적으로 랩핑된 등록은 일치 이벤트 알림을 사용할 수 있게 될 때 NotificationConsumer의 알림 조작을 구동시킵니다. 대신 등록자가 대신 새 등록을 작성하는 경우에는 이벤트 알림의 애플리케이션 특정 컨텐츠(즉, NotificationMessage 요소의 컨텐츠)만 대상 이용자 엔드포인트로 전송됩니다. UseRaw(즉, 원시 등록 요청)도 지정하는 등록 요청의 ConsumerReference에서 지정된 웹 서비스 엔드포인트는 NotificationConsumer 포트 유형을 구현하지 않아도 됩니다. 이벤트 알림을 전달하기 위해 알림 조작이 사용되지 않기 때문입니다.

이는 지정된 토픽에서 공개될 애플리케이션 컨텐츠 유형 각각에 대한 조작을 이용자가 승인할 수 있어야 함을 의미합니다. 이 패턴은 WS-Notification이 WS-Notification을 인식하지 못하지만 동일한 정보를 수신해야 하는 기존 웹 서비스 애플리케이션 그룹을 호출할 수 있도록 허용합니다.

JAX-WS는 조치 기반 디스패치를 지원하며 JAX-WS 원시 이용자 애플리케이션은 http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/Notify 조치 URI를 승인해야 합니다. 자세한 정보는 문제점 해결 팁 중개 대상 알림의 원 이용자인 JAX-WS 애플리케이션이 알림 브로커 SOAP 조치를 인식해야 함의 내용을 참조하십시오.

브로커에 공개자(생성자) 애플리케이션을 등록하여 공개자 등록 역할을 수행하는 JAX-RPC 클라이언트에 대한 코드를 작성하려면 코드 추출 예에서 자세한 정보를 참조하여 다음 단계를 완료하십시오.

프로시저

  1. JAX-RPC 서비스를 찾아보십시오. JNDI 이름은 웹 서비스 클라이언트 구현에 따라 다릅니다.
  2. 조작을 호출하려는 포트의 스텁을 가져오십시오.
  3. ConsumerReference를 작성하십시오. 등록되는 이용자 웹 서비스의 주소 또는 풀 포인트에 대한 참조가 포함됩니다. 풀 포인트 EPR 지정은 이용자가 풀 기반 알림을 사용하게 됨을 나타냅니다.
  4. 필터를 작성하십시오. 이용자를 등록하려는 토픽의 이름을 제공합니다.
  5. 토픽 표현식을 작성하고 필터에 추가하십시오. prefixMapping은 네임스페이스 접두부와 표현식에서 사용되는 접두부에 대한 해당 네임스페이스 간의 맵핑입니다.
  6. XPath 1.0 메시지 컨텐츠 필터를 작성하십시오. 예를 들어, 급여 수준에 따라 토픽에서 사용 가능한 메시지의 서브세트를 선택할 수 있습니다. 메시지 컨텐츠 필터 사용 예는 공개의 메시지 컨텐츠 필터링의 내용을 참조하십시오.
  7. InitialTerminationTime을 작성하십시오. 이는 등록을 종료하려는 시간입니다. 예를 들어, 향후 1년의 시간을 설정할 수 있습니다.
  8. 정책 정보를 작성하십시오.
  9. 옵션: 이용자가 원시 스타일 알림을 수신함을 나타내는 정책을 구성하십시오.
  10. 브로커에서 리턴된 여러 값을 보유할 홀더를 작성하십시오.
    • 등록 참조
    • 브로커의 현재 시간
    • 등록 종료 시간
    • 추가 요소
  11. 스텁에 대한 연관된 메소드를 호출하여 등록 조작을 호출하십시오.
  12. 리턴값을 가져오십시오.
    • 작성된 등록에 대한 엔드포인트 참조. 등록의 후속 수명 관리(예를 들어, 등록 일시정지)에 필요합니다.
    • 브로커에서의 현재 시간
    • 등록 종료 시간
    • 기타 정보

다음 코드 예는 브로커에 이용자 애플리케이션을 등록할 수 있는 등록자 클라이언트 애플리케이션을 설명합니다.
// Look up the JAX-RPC service. The JNDI name is specific to your web services client implementation
InitialContext context = new InitialContext();
javax.xml.rpc.Service service = (javax.xml.rpc.Service) context.lookup(
    "java:comp/env/services/NotificationBroker");

// Get a stub for the port on which you want to invoke operations
NotificationBroker stub = (NotificationBroker) service.getPort(NotificationBroker.class);

// Create the ConsumerReference. This contains the address of the consumer web service that is being
// subscribed, or alternatively is a reference to a pull point (see alternative below). Specifying a
// pull point EPR indicates that the consumer is to use pull-based notifications.
EndpointReference consumerEPR = 
    EndpointReferenceManager.createEndpointReference(new URI("http://myserver.mycom.com:9080/Consumer"));

/*
// Alternative ConsumerReference for pull-based notifications:

EndpointReference consumerEPR = pullPointEPR;

*/

// Create the Filter. This provides the name of the topic to which you want to subscribe the consumer
Filter filter = new Filter();

// Create a topic expression and add it to the filter. The prefixMappings are mappings between namespace
// prefixes and their corresponding namespaces for prefixes used in the expression
Map prefixMappings = new HashMap();
prefixMappings.put("abc", "uri:example");
TopicExpression exp =
    new TopicExpression(TopicExpression.SIMPLE_TOPIC_EXPRESSION, "abc:ExampleTopic", prefixMappings);        
filter.addTopicExpression(exp);


//Create an XPath 1.0 message content filter
//This example selects a subset of the available messages in the topic, based upon salary level
String filterExpression = "/company/department/employee/salary > 10000";
URI xpathURI = new URI(http://www.w3.org/TR/1999/REC-xpath-19991116);

QueryExpression qexp = 
    new QueryExpression(xpathURI, filterExpression);

filter.addMessageContentExpression(qexp);

// Create the InitialTerminationTime. This is the time when you want the subscription to terminate.
// For example, set a time of 1 year in the future.
Calendar cal = Calendar.getInstance();
cal.add(Calendar.YEAR, 1);
AbsoluteOrRelativeTime initialTerminationTime = new AbsoluteOrRelativeTime(cal);

// Create the Policy information
SOAPElement[] policyElements = null;

/*
Optional
--------
The following lines show how to construct a policy indicating that the consumer is to 
receive raw style notifications:

    javax.xml.soap.SOAPFactory soapFactory = javax.xml.soap.SOAPFactory.newInstance();
    SOAPElement useRawElement = null;

    if (soapFactory instanceof IBMSOAPFactory) {
        // You can use the value add methods provided by the IBMSOAPFactory API to create the SOAPElement
        // from an XML string.
       String useRawElementXML = "<mno:UseRaw xmlns:mno=\"http://docs.oasis-open.org/wsn/b-2\"/>";
        useRawElement = ((IBMSOAPFactory) soapFactory).createElementFromXMLString(useRawElementXML);
            } else {
        useRawElement = soapFactory.createElement("UseRaw", "mno", "http://docs.oasis-open.org/wsn/b-2");
    }

    policyElements =  new SOAPElement[] { useRawElement };
*/

// Create holders to hold the multiple values returned from the broker:
// The subscription reference
EndpointReferenceTypeHolder subscriptionRefHolder = new EndpointReferenceTypeHolder();

// The current time at the broker
CalendarHolder currentTimeHolder = new CalendarHolder();

// The termination time for the subscription
CalendarHolder terminationTimeHolder = new CalendarHolder();

// Any additional elements
AnyArrayHolder anyOtherElements = new AnyArrayHolder();

// Invoke the Subscribe operation by calling the associated method on the stub
stub.subscribe(consumerEPR,
                       filter,
                       initialTerminationTime,
                       policyElements,
                       anyOtherElements,
                       subscriptionRefHolder,
                       currentTimeHolder,
                       terminationTimeHolder);

// Get the returned values:
// An endpoint reference for the subscription that has been created. It is required for
// subsequent lifetime management of the subscription, for example pausing the subscription
com.ibm.websphere.wsaddressing.EndpointReference subscriptionRef = subscriptionRefHolder.value;

// The current time at the broker
Calendar currentTime = currentTimeHolder.value;

// The termination time of the subscription
Calendar terminationTime = terminationTimeHolder.value;

// Any other information
SOAPElement[] otherElements = anyOtherElements.value;

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



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