public UnsubscribeResponse Unsubscribe([System.Xml.Serialization.XmlElementAttribute("Unsubscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Unsubscribe Unsubscribe1)
        {
            if (Application["consumer"] == null)
            {
                SoapFaultSubCode subCode =
                    new SoapFaultSubCode(new XmlQualifiedName("ResourseUnknown", "http://www.onvif.org/ver10/error"));

                SoapException exception = new SoapException("Invalid Argument",
                                                            new XmlQualifiedName("Sender",
                                                                                 "http://www.w3.org/2003/05/soap-envelope"),
                                                            subCode);
                throw exception;
            }

            Application["consumer"] = null;

            UnsubscribeResponse response = new UnsubscribeResponse();

            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeResponse";


            return(response);
        }
Exemplo n.º 2
0
        public static void Check(SoapHeaderCollection headers)
        {
            string wsu = ConfigurationSettings.AppSettings["wsu"];

            if (wsu != "true")
            {
                return;
            }

            bool authorized = false;

            foreach (SoapHeader header in headers)
            {
                SoapUnknownHeader unknown = header as SoapUnknownHeader;
                if (unknown != null)
                {
                    if (unknown.Element.LocalName == "Security" &&
                        unknown.Element.NamespaceURI == "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
                    {
                        authorized = true;
                    }
                }
            }

            if (!authorized)
            {
                SoapFaultSubCode subCode  = new SoapFaultSubCode(new XmlQualifiedName("SenderNotAuthorized", "http://www.onvif.org/ver10/error"));
                SoapFaultSubCode subCode1 = new SoapFaultSubCode(new XmlQualifiedName("NotAuthorized", "http://www.onvif.org/ver10/error"), subCode);
                throw new SoapException("AccessDenied", new XmlQualifiedName("Sender", "http://www.w3.org/2003/05/soap-envelope"), subCode1);
            }
        }
Exemplo n.º 3
0
        public static void ReturnFault(string[] codes)
        {
            SoapFaultSubCode subCode = null;

            for (int i = codes.Length - 1; i > 0; i--)
            {
                SoapFaultSubCode currentSubCode = new SoapFaultSubCode(new XmlQualifiedName(codes[i], "http://www.onvif.org/ver10/error"), subCode);
                subCode = currentSubCode;
            }
            throw new SoapException("Error", new XmlQualifiedName(codes[0], "http://www.w3.org/2003/05/soap-envelope"), subCode);
        }
 private static void DetailException(StringBuilder detail, SoapException soapException)
 {
     if (soapException == null)
     {
         return;
     }
     if (soapException.Code != null)
     {
         detail.AppendFormat("Code: {0}", soapException.Code);
         detail.AppendLine();
     }
     if (soapException.SubCode != null)
     {
         int num = 0;
         detail.Append("SubCode: ");
         SoapFaultSubCode subCode = soapException.SubCode;
         while (subCode != null)
         {
             if (subCode.Code != null)
             {
                 detail.Append(subCode.Code.ToString());
             }
             subCode = subCode.SubCode;
             num++;
             if (num > 10)
             {
                 break;
             }
             if (subCode != null)
             {
                 detail.Append(", ");
             }
         }
         detail.AppendLine();
     }
     if (soapException.Detail != null)
     {
         detail.AppendFormat("Detail: {0}", soapException.Detail.OuterXml);
         detail.AppendLine();
     }
 }
Exemplo n.º 5
0
        public RenewResponse Renew([System.Xml.Serialization.XmlElementAttribute("Renew", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Renew Renew1)
        {
            if (Application["consumer"] == null)
            {
                SoapFaultSubCode subCode =
                    new SoapFaultSubCode(new XmlQualifiedName("ResourseUnknown1", "http://www.onvif.org/ver10/error"));

                SoapException exception = new SoapException("Invalid Argument",
                                                            new XmlQualifiedName("Sender",
                                                                                 "http://www.w3.org/2003/05/soap-envelope"),
                                                            subCode);
                throw exception;
            }

            RenewResponse response = new RenewResponse();

            response.CurrentTime          = System.DateTime.Now;
            response.CurrentTimeSpecified = true;
            response.TerminationTime      = response.CurrentTime.AddSeconds(15);

            return(response);
        }
Exemplo n.º 6
0
        static public SoapException GetSoapException(FaultType faultType, string message)
        {
            SoapException res = null;

            switch (faultType)
            {
            case FaultType.General:
            {
                System.Xml.XmlQualifiedName code    = SoapException.ClientFaultCode;
                SoapFaultSubCode            subCode = null;
                res = new SoapException(message, code, subCode);
                break;
            }

            case FaultType.Custom:
            {
                System.Xml.XmlQualifiedName code    = SoapException.ClientFaultCode;
                SoapFaultSubCode            subCode = null;
                res = new SoapException(message, code, subCode);
                break;
            }
            }
            return(res);
        }
 public SoapHeaderException(string message, System.Xml.XmlQualifiedName code, string actor, string role, string lang, SoapFaultSubCode subCode, System.Exception innerException)
 {
 }
        public static SoapException WOFExceptionToSoapException(Exception ex)
        {
            Type          eType = ex.GetType();
            SoapException se;
            String        actor      = null;
            String        detailText = null;
            string        message    = null;

            if (eType == typeof(WaterOneFlowException))
            {
                XmlQualifiedName soapCode = ClientFaultCode;
                se = new SoapException(ex.Message, soapCode);
                if (log.IsDebugEnabled)
                {
                    log.Debug(ex.Message);
                }
            }
            else if (eType == typeof(WaterOneFlowSourceException))
            {
                XmlQualifiedName soapCode = ServerFaultCode;
                se = new SoapException(ex.Message, soapCode);
                if (log.IsErrorEnabled)
                {
                    log.Error(ex.Message);
                }
            }
            else if (eType == typeof(WaterOneFlowServerException))
            {
                // create a soap fault with a subcode, external
                XmlQualifiedName soapCode    = ServerFaultCode;
                XmlQualifiedName subCodeName = new XmlQualifiedName("external", Constants.XML_SCHEMA_NAMSPACE);
                SoapFaultSubCode subCode     = new SoapFaultSubCode(subCodeName);

                se = new SoapException(ex.Message, soapCode, subCode);
                if (log.IsErrorEnabled)
                {
                    log.Error(ex.Message);
                }
            }
            else if (eType == typeof(ArgumentException))
            {
                XmlQualifiedName soapCode = ClientFaultCode;
                se = new SoapException(ex.Message, soapCode);
                if (log.IsDebugEnabled)
                {
                    log.Debug(ex.Message);
                }
            }
            else if (eType == typeof(OverflowException))
            {
                XmlQualifiedName soapCode = ServerFaultCode;
                se = new SoapException(ex.Message, soapCode);
                if (log.IsErrorEnabled)
                {
                    log.Error(ex.Message);
                }
            }

            else
            {
                XmlQualifiedName soapCode = ServerFaultCode;
                se = new SoapException(ex.Message, soapCode);
                if (log.IsErrorEnabled)
                {
                    log.Error(ex.Message);
                }
            }
            return(se);
        }
 public SoapFaultSubCode(System.Xml.XmlQualifiedName code, SoapFaultSubCode subCode)
 {
 }
 public SoapFaultSubCode(System.Xml.XmlQualifiedName code, SoapFaultSubCode subCode)
 {
 }
Exemplo n.º 11
0
        public static SoapException GetException(string message, System.Xml.XmlQualifiedName code, System.Xml.XmlNode detail, SoapFaultSubCode subCode, Exception innerException)
        {
            string actor = "http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver";
            string role  = "http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver";
            string lang  = "en";

            return(new SoapException(message, code, actor, role, lang, detail, subCode, innerException));
        }
 public SoapException(string message, System.Xml.XmlQualifiedName code, SoapFaultSubCode subCode)
 {
 }
 public SoapHeaderException(string message, System.Xml.XmlQualifiedName code, string actor, string role, string lang, SoapFaultSubCode subCode, System.Exception innerException)
 {
 }
        public System.DateTime PullMessages(
            [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string Timeout,
            int MessageLimit,
            [System.Xml.Serialization.XmlAnyElementAttribute()] System.Xml.XmlElement[] Any,
            out System.DateTime TerminationTime,
            [System.Xml.Serialization.XmlElementAttribute("NotificationMessage", Namespace = "http://docs.oasis-open.org/wsn/b-2")] out NotificationMessageHolderType[] NotificationMessage)
        {
            if (Timeout == "PT24H")
            {
                SoapFaultSubCode subCode =
                    new SoapFaultSubCode(new XmlQualifiedName("ShitHappens", "http://www.onvif.org/ver10/error"));

                SoapException exception = new SoapException("Invalid Argument",
                                                            new XmlQualifiedName("Sender",
                                                                                 "http://www.w3.org/2003/05/soap-envelope"),
                                                            subCode);
                throw exception;
            }

            //if (Timeout == "PT20S")
            //{
            //    PullMessagesFaultResponseType details = new PullMessagesFaultResponseType();
            //    details.MaxMessageLimit = 5;
            //    details.MaxTimeout = "PT15S";

            //    FaultException<PullMessagesFaultResponseType> exception = new FaultException<PullMessagesFaultResponseType>(details, "InvalidArg", new FaultCode("Sender", "http://www.w3.org/2003/05/soap-envelope"));
            //    throw exception;
            //}

            string varName = "PullMessagesCounter";

            int cnt = 0;

            if (Application.AllKeys.Contains(varName))
            {
                cnt = (int)Application[varName];
            }

            if (cnt % 2 == 0)
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml("<tt:Message UtcTime=\"2008-10-10T12:24:57.321\" xmlns:tt=\"http://www.onvif.org/ver10/schema\"><tt:Source><tt:SimpleItem Name=\"RecordingJobToken\" Value=\"1\"/></tt:Source><tt:Data><tt:SimpleItem Name=\"State\" Value=\"Idle\" /><tt:ElementItem Name=\"Information\"><tt:RecordingJobStateInformation><tt:RecordingToken>Recording1</tt:RecordingToken><tt:State>Active</tt:State></tt:RecordingJobStateInformation></tt:ElementItem></tt:Data></tt:Message>");

                NotificationMessageHolderType notification1 = CreateMessage(doc,
                                                                            "tns1",
                                                                            "http://www.onvif.org/ver10/topics",
                                                                            "RecordingConfig/JobState");

                //NotificationMessageHolderType notification2 = CreateMessage(doc, "tns1", "PropertyTopic2");

                NotificationMessage = new NotificationMessageHolderType[] { notification1 /*, notification2*/ };
            }
            else
            {
                NotificationMessage = new NotificationMessageHolderType[] { };
            }
            cnt++;
            Application[varName] = cnt;

            TerminationTime = System.DateTime.Now.AddMinutes(3);
            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesResponse";

            return(System.DateTime.Now.AddSeconds(10));
        }
 public SoapException(string message, System.Xml.XmlQualifiedName code, SoapFaultSubCode subCode)
 {
 }