コード例 #1
0
        /// <summary>
        /// Method used to write an endpoint reference and reference parameters or properties.
        /// </summary>
        /// <param name="xmlWriter">An XmlWriter used to write the endpoint reference.</param>
        /// <param name="endpointRef">A WsWsaEndpointRef containing the information to write.</param>
        private void WriteEndpointRef(XmlWriter xmlWriter, WsWsaEndpointRef endpointRef, String name)
        {
            xmlWriter.WriteStartElement(WsNamespacePrefix.Wse, name, null);
            xmlWriter.WriteStartElement(WsNamespacePrefix.Wsa, "Address", null);
            xmlWriter.WriteString(endpointRef.Address.AbsoluteUri);
            xmlWriter.WriteEndElement(); // End Address

            // if ref paramters write them
            if (endpointRef.RefParameters != null && endpointRef.RefParameters.Count > 0)
            {
                xmlWriter.WriteStartElement(WsNamespacePrefix.Wsa, "ReferenceParameters", null);

                // Iterate ref parameters
                int count = endpointRef.RefParameters.Count;
                for (int i = 0; i < count; i++)
                {
                    WsXmlNode refParam = endpointRef.RefParameters[i];
                    // Write the element name
                    xmlWriter.WriteStartElement(refParam.Prefix, refParam.LocalName, refParam.NamespaceURI);
                    // Write the value
                    xmlWriter.WriteString(refParam.Value);
                    xmlWriter.WriteEndElement(); // End param element
                }

                xmlWriter.WriteEndElement(); // End ReferenceParameters
            }

            // if ref properties write them
            if (endpointRef.RefProperties != null && endpointRef.RefProperties.Count > 0)
            {
                xmlWriter.WriteStartElement(WsNamespacePrefix.Wsa, "ReferenceProperties", null);

                // Iterate ref parameters
                int count = endpointRef.RefProperties.Count;
                for (int i = 0; i < count; i++)
                {
                    WsXmlNode refProp = endpointRef.RefProperties[i];
                    // Write the element name
                    xmlWriter.WriteStartElement(refProp.Prefix, refProp.LocalName, refProp.NamespaceURI);
                    // Write the value
                    xmlWriter.WriteString(refProp.Value);
                    xmlWriter.WriteEndElement(); // End property element
                }

                xmlWriter.WriteEndElement(); // End ReferenceProperties
            }

            xmlWriter.WriteEndElement(); // End EndpointReference

            return;
        }
コード例 #2
0
        /// <summary>
        /// Starting at the current reader position, builds an arrray of
        /// XmlElement objects up to the end tag of the enclosing element or until namespace
        /// validation rules are violated.
        /// </summary>
        /// <param name="reader">An XmlReader positioned at a start element.</param>
        /// <param name="isRequired">True if minoccurs > 0 for an element.</param>
        /// <returns>An array of XmlElements.</returns>
        /// <remarks>ProcessContent validation is not supported.</remarks>
        protected WsXmlNode[] ReadAnyElement(XmlReader reader, bool isRequired)
        {
            if (isRequired && !reader.IsStartElement())
            {
                throw new XmlException("Parsing Error. Any element is required.");
            }

            ArrayList nodeList = new ArrayList();

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                WsXmlNode tempNode = new WsXmlNode(reader);
                nodeList.Add(tempNode);
            }

            return((WsXmlNode[])nodeList.ToArray(typeof(WsXmlNode)));
        }
コード例 #3
0
        public MFTestResults XmlTest5_WsXmlNodeList()
        {
            /// <summary>
            /// 1. Verifies the properties of a WsWsaEndpointRefs object
            /// 2. Adds elements to it
            /// 3. Re-verifies
            /// 4. Empties the object
            /// 5. Re-verifies
            /// </summary>
            ///
            bool testResult = true;

            try
            {
                WsXmlNodeList testWXNs = new WsXmlNodeList();

                if (testWXNs.Count != 0)
                {
                    throw new Exception("Count did not set correctly on new");
                }

                testWXNs.Add(new WsXmlNode());

                WsXmlNode testWXN = new WsXmlNode();
                testWXN.LocalName = "testWXN local name";
                testWXNs.Add(testWXN);

                if (testWXNs.Count != 2)
                {
                    throw new Exception("Count did not set correctly on new");
                }
            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return(testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
コード例 #4
0
        /// <summary>
        /// Creates an instance of a DpwsEventSubscription class.
        /// </summary>
        internal DpwsEventSubscription(XmlReader reader, ProtocolVersion version)
        {
            reader.ReadStartElement("SubscribeResponse", version.EventingNamespace);

            if (reader.IsStartElement("SubscriptionManager", version.EventingNamespace))
            {
                this.SubscriptionManager = new WsWsaEndpointRef(reader, version.AddressingNamespace);

                this.Expires = new WsDuration(reader.ReadElementString("Expires", version.EventingNamespace));

                WsXmlNode identifier = this.SubscriptionManager.RefParameters.GetNode("Identifier", version.EventingNamespace);
                this.SubscriptionID = identifier.Value;

                if (this.SubscriptionID == null)
                {
                    throw new XmlException();
                }
            }
            else
            {
                throw new XmlException();
            }
        }
コード例 #5
0
        /// <summary>
        /// Creates an instance of a DpwsEventSubscription class.
        /// </summary>
        internal DpwsEventSubscription(XmlReader reader)
        {
            reader.ReadStartElement("SubscribeResponse", WsWellKnownUri.WseNamespaceUri);

            if (reader.IsStartElement("SubscriptionManager", WsWellKnownUri.WseNamespaceUri))
            {
                this.SubscriptionManager = new WsWsaEndpointRef(reader);

                this.Expires = new WsDuration(reader.ReadElementString("Expires", WsWellKnownUri.WseNamespaceUri));

                WsXmlNode identifier = this.SubscriptionManager.RefParameters.GetNode("Identifier", WsWellKnownUri.WseNamespaceUri);
                this.SubscriptionID = identifier.Value;

                if (this.SubscriptionID == null)
                {
                    throw new XmlException();
                }
            }
            else
            {
                throw new XmlException();
            }
        }
コード例 #6
0
        /// <summary>
        /// Creates an instance a DpwsSubscribeRequest class initialized with the service endpoint Address,
        /// notifyTo callback endpoint address and event duration.
        /// </summary>
        /// <param name="subscriptionType">A DpwsServieType object containing a definition of the service being subscripbed to.</param>
        /// <param name="endpointAddress">A string containing an event source endpoint address.</param>
        /// <param name="notifyToAddress">A string containing the notifyTo endpoint address.</param>
        /// <param name="expires">
        /// A string containing the subscription expiration time in duration format. If
        /// null the event does not expire.
        /// </param>
        /// <param name="identifier">A WsWsaRefParamter object containing a unique identifier.
        /// This value will be included in an event messages soap header as a reference parameter.
        /// This value is not processed by a service it is intended to provide a unique identified
        /// a client can use for any purpose.</param>
        /// <remarks>
        /// This constructor sets the endTo address to null indicating that the notifyTo address should receive
        /// subscription end messages. A user ID for the event is not set by default.
        /// </remarks>
        /// <exception cref="ArgumentException">If duration format is invalid.</exception>
        public DpwsSubscribeRequest(DpwsServiceType subscriptionType, string endpointAddress, string notifyToAddress, string expires, WsXmlNode identifier)
        {
            if (endpointAddress == null || notifyToAddress == null)
            {
                throw new ArgumentNullException();
            }

            this.SubscriptionType = subscriptionType;
            this.EndpointAddress  = new Uri(endpointAddress);

            this.NotifyTo = new WsWsaEndpointRef(new Uri(notifyToAddress));
            this.EndTo    = new WsWsaEndpointRef(new Uri(notifyToAddress));

            if (identifier != null)
            {
                this.NotifyTo.RefProperties.Add(identifier);
                this.EndTo.RefProperties.Add(identifier);
            }

            if (expires != null)
            {
                this.Expires = new WsDuration(expires);
            }
        }
コード例 #7
0
        public MFTestResults XmlTest_XmlNode()
        {
            /// <summary>
            /// 1. Gets and verifies each of the properties of a WsXmlNode object
            /// 2. Sets and re-verifies all properties
            /// See 18325 for more info re: childNodes
            /// </summary>
            ///
            bool testResult = true;

            try
            {
                WsXmlNode testWXN = new WsXmlNode();

                Log.Comment("LocalName");
                if (testWXN.LocalName != null)
                {
                    if (testWXN.LocalName.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("LocalName wrong type");
                    }
                }

                testWXN.LocalName = "test datum 1";

                if (testWXN.LocalName.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("LocalName wrong type after set");
                }

                if (testWXN.LocalName != "test datum 1")
                {
                    throw new Exception("LocalName wrong data");
                }


                Log.Comment("NamespaceURI");
                if (testWXN.NamespaceURI != null)
                {
                    if (testWXN.NamespaceURI.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("NamespaceURI wrong type");
                    }
                }

                testWXN.NamespaceURI = "test datum 3";

                if (testWXN.NamespaceURI.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("NamespaceURI wrong type after set");
                }

                if (testWXN.NamespaceURI != "test datum 3")
                {
                    throw new Exception("NamespaceURI wrong data");
                }

                Log.Comment("Prefix");
                if (testWXN.Prefix != null)
                {
                    if (testWXN.Prefix.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("Prefix wrong type");
                    }
                }

                testWXN.Prefix = "test datum 4";

                if (testWXN.Prefix.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("Prefix wrong type after set");
                }

                if (testWXN.Prefix != "test datum 4")
                {
                    throw new Exception("Prefix wrong data");
                }

                Log.Comment("Value");
                if (testWXN.Value != null)
                {
                    if (testWXN.Value.GetType() !=
                        Type.GetType("System.String"))
                    {
                        throw new Exception("Value wrong type");
                    }
                }

                testWXN.Value = "test datum 5";

                if (testWXN.Value.GetType() !=
                    Type.GetType("System.String"))
                {
                    throw new Exception("Value wrong type after set");
                }

                if (testWXN.Value != "test datum 5")
                {
                    throw new Exception("Value wrong data");
                }

                Log.Comment("Attributes");
                if (testWXN.Attributes != null)
                {
                    if (testWXN.Attributes.GetType() !=
                        Type.GetType("Ws.Services.Xml.WsXmlAttributeCollection"))
                    {
                        throw new Exception("Value wrong type");
                    }
                }

                Log.Comment("ChildNodes");
                if (testWXN.ChildNodes != null)
                {
                    if (testWXN.ChildNodes.GetType() !=
                        Type.GetType("Ws.Services.Xml.WsXmlNodeList"))
                    {
                        throw new Exception("ChildNodes wrong type");
                    }
                }
            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }

            return(testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }