/// <summary>
        /// Implements the IWsServiceEndpoint.ProcessRequest method.
        /// Gets a service operation based on the action property sent in the soap header and calls
        /// invoke on the service method.
        /// </summary>
        /// <param name="header">A WsWsaHeader containing the header proerties of a request.</param>
        /// <param name="envelope">A WsXmlDocument containing the entire envelope of the message in a node tree.</param>
        /// <returns>A byte array containing a soap response to the request.</returns>
        WsMessage ProcessRequest(WsMessage request)
        {
            WsWsaHeader header = request.Header;
            String      action = header.Action;

            // Display the action name.
            System.Ext.Console.Write("Action: " + action);

            // Look for a valid service Action
            WsServiceOperation operation = m_serviceOperations[action];

            if (operation != null)
            {
                System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(operation.MethodName);
                if (methodInfo == null)
                {
                    System.Ext.Console.Write("");
                    System.Ext.Console.Write("Operation method for action " + header.Action + " was not found");
                    System.Ext.Console.Write("");

                    throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable);
                }

                return((WsMessage)methodInfo.Invoke(this, new object[] { request }));
            }

            // If a valid Action is not found, fault
            throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable, "To: " + header.To + " Action: " + action);
        }
Exemple #2
0
        public TwoWayOperationService()
        {
            // The client filters devices when probing using the ServiceTypeName property
            this.ServiceTypeName = "TwoWayOperationServiceType";
            // Add a unique namespace for our service
            this.ServiceNamespace = new WsXmlNamespace("twoWay",        // prefix
                                                       c_namespaceUri); // URI
            // Unique ID to access the service
            this.ServiceID = "urn:uuid:93252386-0724-c8ca-bd31-000000732d93";
            // Add the two-way service operation
            WsServiceOperation operation =
                new WsServiceOperation(this.ServiceNamespace.NamespaceURI,      // namespace
                                       "MyTwoWayOperation");                    // operation method name

            this.ServiceOperations.Add(operation);
        }
Exemple #3
0
        public OneWayOperationService()
        {
            // The client filters devices when probing using the ServiceTypeName property
            this.ServiceTypeName = "OneWayOperationServiceType";
            // Add a unique namespace for our service
            this.ServiceNamespace = new WsXmlNamespace("oneWay",                                            // prefix
                                                       "http://schemas.sample.org/OneWayOperationService"); // URI
            // Unique ID to access the service
            this.ServiceID = "urn:uuid:93252386-0724-c8ca-bd31-000000732d93";
            // Add the one-way service operation
            WsServiceOperation operation =
                new WsServiceOperation(this.ServiceNamespace.NamespaceURI,      // namespace
                                       "MyOneWayOperation");                    // operation method name

            this.ServiceOperations.Add(operation);
        }
        /// <summary>
        /// Implements the IWsServiceEndpoint.ProcessRequest method.
        /// Gets a service operation based on the action property sent in the soap header and calls
        /// invoke on the service method.
        /// </summary>
        /// <param name="header">A WsWsaHeader containing the header proerties of a request.</param>
        /// <param name="envelope">A WsXmlDocument containing the entire envelope of the message in a node tree.</param>
        /// <returns>A byte array containing a soap response to the request.</returns>
        private byte[] ProcessRequest(WsWsaHeader header, XmlReader reader)
        {
            String action = header.Action;

            // Display the action name.
            System.Ext.Console.Write("Action: " + action);

            // Look for a valid service Action
            WsServiceOperation operation = m_serviceOperations[action];
            if (operation != null)
            {
                m_messageType = WsMessageType.Soap;
                System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(operation.MethodName);
                if (methodInfo == null)
                {
                    System.Ext.Console.Write("");
                    System.Ext.Console.Write("Operation method for action " + header.Action + " was not found");
                    System.Ext.Console.Write("");
                    throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable);
                }

                return (byte[])methodInfo.Invoke(this, new object[] { header, reader });
            }

            // Else look for event subscription Action
            if (action.IndexOf(WsWellKnownUri.WseNamespaceUri) == 0)
            {
                action = action.Substring(47/*WsWellKnownUri.WseNamespaceUri.Length + 1*/);
                switch (action)
                {
                    case "Subscribe":
                        return Subscribe(header, reader);
                    case "Unsubscribe":
                        return Unsubscribe(header, reader);
                    case "GetStatus":
                        return GetStatus(header, reader);
                    case "Renew":
                        return Renew(header, reader);
                }
            }

            // If a valid Action is not found, fault
            throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable, "To: " + header.To + " Action: " + action);
        }