예: 알림 이용자 웹 서비스 스켈레톤 작성
웹 서비스 기본 알림 스펙으로 정의된 NotificationConsumer portType을 구현하는 웹 서비스를 작성할 때 이 예를 사용합니다.
이 태스크 정보
이 태스크는 두 가지 코드 예를 제공합니다.
- 웹 서비스 기본 알림 스펙으로 정의된 NotificationConsumer portType을 구현하는 웹 서비스를 설명하는 WSDL 문서 예
- WSDL2Java 도구를 사용하여 이전 WSDL 문서에서 생성된 SEI(Service Endpoint Interface)의 기본 구현
참고: WS-Notification용 JAX-WS
애플리케이션 작성 문서에는 또한 이용자 웹 서비스 예가
포함됩니다.
프로시저
알림
이용자 웹 서비스 스켈레톤을 작성하는
경우 다음 코드 예를 참조하십시오.
예
다음 WSDL 문서 예는 웹 서비스 기본 알림 스펙으로 정의된 NotificationConsumer portType을 구현하는 웹 서비스를 설명합니다.
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsn-bw="http://docs.oasis-open.org/wsn/bw-2"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="uri:example.wsn/consumer"
targetNamespace="uri:example.wsn/consumer">
<wsdl:import namespace="http://docs.oasis-open.org/wsn/bw-2"
location="http://docs.oasis-open.org/wsn/bw-2.wsdl" />
<wsdl:binding name="NotificationConsumerBinding" type="wsn-bw:NotificationConsumer">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Notify">
<wsdlsoap:operation soapAction="" />
<wsdl:input>
<wsdlsoap:body use="literal" />
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NotificationConsumerService">
<wsdl:port name="NotificationConsumerPort" binding="tns:NotificationConsumerBinding">
<wsdlsoap:address location="http://myserver.mycom.com:9080/Consumer" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
다음 예는 WSDL2Java 도구를 사용하여 이전 WSDL 문서에서 생성된 SEI(Service Endpoint Interface)의 기본 구현을 보여줍니다.
public class ConsumerExample implements NotificationConsumer {
public void notify(NotificationMessage[] notificationMessage, SOAPElement[] any)
throws RemoteException {
// Process each NotificationMessage
for (int i=0; i<notificationMessage.length; i++) {
NotificationMessage message = notificationMessage[i];
// Get the contents of the message
SOAPElement messageContent = message.getMessageContents();
// Get the expression indicating which topic the message is associated with
TopicExpression topic = message.getTopic();
// Get a reference to the producer (this value is optional and so might be null)
EndpointReference producerRef = message.getProducerReference();
// Get a reference to the subscription (this value is optional and so might be null)
EndpointReference subscriptionRef = message.getSubscriptionReference();
// User defined processing ...
}
}
}