2008-09-20 5 views

답변

3

얼마 전에 CodeProject에서이 사실을 읽은 것 같습니다.

죄송합니다. 더 이상 도와 드릴 수 없지만, Roman Kiss의 this is the article.

0

WCF 3.0에는 기본 pub/sub 모델이 없지만 몇 가지 옵션이 있습니다.
- 로마 키스 기사 Ash가 발견되었습니다.
- (MSDN Mag에 포함) 구현할 수있는 다른 패턴이 많이있다
- 마지막으로 제가 현재 사용하고하는 것은 약간의 오버 헤드로 이것을 모방 - 쥬발 로이는 IDesign
에서 자신의 사이트에서 다운로드 할 수있는 두 개의 프레임 워크 구현을 가지고 MSMQ입니다.

1

적어도 WCF4를 사용하면 WS-Eventing WSDL을 가져와 wsdl 클라이언트를 간단히 만들 수 있습니다 (비누 바인딩 포함). 듀플렉스 바인딩이 필요하므로 http-duplex 또는 simple tcp가 작동해야합니다. 문제는 올바른 콜백을 추가하는 것입니다. 우리에게 이것은 트릭을 만들었습니다.

      Subscribe s = new Subscribe(); 
         (s.Delivery = new DeliveryType()).Mode = "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push"; 

         XmlDocument doc = new XmlDocument(); 
         using (XmlWriter writer = doc.CreateNavigator().AppendChild()) 
         { 
          EndpointReferenceType notifyTo = new EndpointReferenceType(); 

          (notifyTo.Address = new AttributedURI()).Value = callbackEndpoint.Uri.AbsoluteUri; 

          XmlRootAttribute notifyToElem = new XmlRootAttribute("NotifyTo"); 
          notifyToElem.Namespace = "http://schemas.xmlsoap.org/ws/2004/08/eventing"; 

          XmlDocument doc2 = new XmlDocument();          
          using (XmlWriter writer2 = doc2.CreateNavigator().AppendChild()) 
          { 
           XmlRootAttribute ReferenceElement = new XmlRootAttribute("ReferenceElement"); 
           foreach(AddressHeader h in callbackEndpoint.Headers) 
           { 
            h.WriteAddressHeader(writer2); 
           } 

           writer2.Close(); 
           notifyTo.ReferenceParameters = new ReferenceParametersType(); 
           notifyTo.ReferenceParameters.Any = notifyTo.ReferenceParameters.Any = doc2.ChildNodes.Cast<XmlElement>().ToArray<XmlElement>();    
          } 

          new XmlSerializer(notifyTo.GetType(), notifyToElem).Serialize(writer, notifyTo); 
         } 

         (s.Delivery.Any = new XmlElement[1])[0] = doc.DocumentElement; 
         (s.Filter = new FilterType()).Dialect = "http://schemas.xmlsoap.org/ws/2006/02/devprof/Action"; 
         (s.Filter.Any = new System.Xml.XmlNode[1])[0] = new System.Xml.XmlDocument().CreateTextNode("http://www.teco.edu/SensorValues/SensorValuesEventOut"); 

         SubscribeResponse subscription; 
         try 
         { 
          Console.WriteLine("Subscribing to the event..."); 
          //Console.ReadLine(); 
          subscription = eventSource.SubscribeOp(s); 
         } 
관련 문제