سؤال

أعلم أن WCF يدعم العديد من بروتوكولات WS-* ولكن يبدو أن WS-Eventing مدرج في القائمة.

أعلم أن WCF لديه نموذج حانة/فرعي، ولكن هل هو متوافق مع WS-Eventing؟

هل كانت مفيدة؟

المحلول

يبدو أنني أتذكر أنني قرأت عن هذا في CodeProject منذ فترة.

آسف لا أستطيع المساعدة أكثر، ولكن هذا هو المقال بواسطة قبلة رومانية.

نصائح أخرى

على الأقل باستخدام WCF4، يمكنك ببساطة إنشاء عميل wsdl عن طريق استيراد WS-Eventing WSDL (مع ربط الصابون).يتطلب ربطًا مزدوجًا لذا يجب أن يعمل http-duplex أو 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);
                        }

لا يوجد نموذج حانة/فرعي أصلي في WCF 3.0، ولكن هناك بعض الخيارات.
- مقالة القبلة الرومانية التي وجدها آش.
- هناك الكثير من الأنماط الأخرى التي يمكنك تنفيذها (مذكورة في MSDN ماج)
- لدى Juval Lowy تطبيقان لإطار العمل يمكنك تنزيلهما على موقعه على انا اصمم
- وأخيرًا، ما أستخدمه حاليًا لتقليد هذا مع القليل من الحمل هو MSMQ.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top