예: WS-Notification 공개자 등록
제공된 코드 추출 예를 기반으로 이용자 애플리케이션을 브로커에 등록할 수 있는 등록자 클라이언트 애플리케이션에 대한 코드를 작성하려면 이 태스크를 사용합니다.
이 태스크 정보
이 예제는 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 클라이언트 애플리케이션 프로그래밍에 생소하면 다음 주제를 참조하십시오.
이용자 애플리케이션을 브로커에 등록할 수 있는 공개자 클라이언트 애플리케이션의 코드를 작성하려면 다음 단계를 완료하십시오. 자세한 정보는 코드 추출 예를 참조하십시오.
프로시저
예
다음 코드 예는 공개자(생성자) 애플리케이션을 브로커에 등록하여 공개자 등록 역할을 수행하는 JAX-RPC 클라이언트를 나타냅니다.
// 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 a reference for the publisher (producer) being registered. This contains the address of the
// producer web service.
EndpointReference publisherEPR =
EndpointReferenceManager.createEndpointReference(new URI("http://myserver.mysom.com:9080/Producer"));
// Create a list (array) of topic expressions to describe the topics to which the producer publishes
// messages. For this example you add one topic
Map prefixMappings = new HashMap();
prefixMappings.put("abc", "uri:mytopicns");
TopicExpression topic =
new TopicExpression(TopicExpression.SIMPLE_TOPIC_EXPRESSION, "abc:xyz", prefixMappings);
TopicExpression[] topics = new TopicExpression[] {topic};
// Indicate that you do not want the publisher to use demand based publishing
Boolean demand = Boolean.FALSE;
// Set a value for the initial termination time of the registration. For example, set a value 1 year in
// the future
Calendar initialTerminationTime = Calendar.getInstance();
initialTerminationTime.add(Calendar.YEAR, 1);
// Create holders to hold the multiple values returned from the broker:
// PublisherRegistrationReference: An endpoint reference for use in lifetime management of
// the registration
EndpointReferenceTypeHolder pubRegMgrEPR = new EndpointReferenceTypeHolder();
// ConsumerReference: An endpoint reference for use in subsequent publishing of messages
EndpointReferenceTypeHolder consEPR = new EndpointReferenceTypeHolder();
// Invoke the RegisterPublisher operation by calling the associated method on the stub
stub.registerPublisher(publisherEPR, topics, demand, initialTerminationTime, null, pubRegMgrEPR, consEPR);
// Retrieve the PublisherRegistrationReference
EndpointReference registrationEPR = pubRegMgrEPR.value;
// Retrieve the ConsumerReference
EndpointReference consumerReferenceEPR = consEPR.value;