コード例 #1
0
        /// <summary>
        /// Gets a custom exception that wraps the SOAP exception thrown
        /// by the server.
        /// </summary>
        /// <param name="ex">SOAPException that was thrown by the server.</param>
        /// <returns>A custom exception object that wraps the SOAP exception.
        /// </returns>
        protected override Exception GetCustomException(SoapException exception)
        {
            string defaultNs = GetDefaultNamespace();

              if (!string.IsNullOrEmpty(defaultNs) && exception.Detail != null) {
            // Extract the ApiExceptionFault node.
            XmlElement faultNode = GetFaultNode(exception, defaultNs, "ApiExceptionFault");

            if (faultNode != null) {
              try {
            AdWordsApiException awapiException = new AdWordsApiException(
                SerializationUtilities.DeserializeFromXmlTextCustomRootNs(
                    faultNode.OuterXml, Assembly.GetExecutingAssembly().GetType(
                    this.GetType().Namespace + ".ApiException"), defaultNs, "ApiExceptionFault"),
                    AdWordsErrorMessages.AnApiExceptionOccurred, exception);
            if (AdWordsErrorHandler.IsOAuthTokenExpiredError(awapiException)) {
              return new AdWordsCredentialsExpiredException(
                  (string) ContextStore.GetValue("OAuthHeader"));
            } else {
              return awapiException;
            }
              } catch (Exception) {
            // deserialization failed, but we can safely ignore it.
              }
            }
              }
              return new AdWordsApiException(null, AdWordsErrorMessages.AnApiExceptionOccurred, exception);
        }
コード例 #2
0
ファイル: Fault12.cs プロジェクト: Profit0004/mono
		public Soap12Fault (SoapException ex) 
		{
			Code = new Soap12FaultCode ();
			Code.Value = ex.Code;
			if (ex.SubCode != null)
				Code.Subcode = CreateFaultCode (ex.SubCode);
			Node = ex.Node;
			Role = ex.Role;
			Reason = new Soap12FaultReason ();
			Soap12FaultReasonText text =
				new Soap12FaultReasonText ();
			text.XmlLang = ex.Lang;
			text.Value = ex.Message;
			Reason.Texts = new Soap12FaultReasonText [] {text};
			if (ex.Detail != null) {
				Detail = new Soap12FaultDetail ();
				if (ex.Detail.NodeType == XmlNodeType.Attribute)
					Detail.Attributes = new XmlAttribute [] {
						(XmlAttribute) ex.Detail};
				else if (ex.Detail.NodeType == XmlNodeType.Element)
					Detail.Children = new XmlElement [] {
						(XmlElement) ex.Detail};
				else
					Detail.Text = ex.Detail.Value;
			}
		}
コード例 #3
0
		public Fault (SoapException ex) 
		{
			faultcode = ex.Code;
			faultstring = ex.Message;
			faultactor = ex.Actor;
			detail = ex.Detail;
		}
コード例 #4
0
 public Fault(SoapException ex)
 {
     faultcode   = ex.Code;
     faultstring = ex.Message;
     faultactor  = ex.Actor;
     detail      = ex.Detail;
 }
コード例 #5
0
ファイル: AxConnectorServer.cs プロジェクト: MaKeBits/AxRest
 /// <summary>
 /// Calls an AX method
 /// </summary>
 /// <param name="className">Class name</param>
 /// <param name="methodName">Method name</param>
 /// <param name="paramList">Parameters list</param>
 /// <returns></returns>
 public Object CallAxMethod(string className, string methodName, params object[] paramList)
 {
     try
     {
         //this.AxLogin();
         this.AxLoginAs();
         return this.callMethod(className, methodName, paramList);
     }
     catch (Microsoft.Dynamics.AxaptaException ex)
     {
         this.WriteErrorToEventLog(ex);
         SoapException se = new SoapException(ex.Message, SoapException.ServerFaultCode, ex.InnerException);
         throw se;
     }
     catch (Exception ex)
     {
         this.WriteErrorToEventLog(ex);
         SoapException se = new SoapException(ex.Message, SoapException.ClientFaultCode, ex.InnerException);
         throw se;
     }
     finally
     {
         this.AxLogoff();
     }
 }
コード例 #6
0
        void SerializeFault(HttpContext context, SoapServerMessage requestMessage, Exception ex)
        {
            SoapException soex = ex as SoapException;

            if (soex == null)
            {
                soex = new SoapException(ex.ToString(), WebServiceHelper.ServerFaultCode(requestMessage != null && requestMessage.IsSoap12), ex);
            }

            SoapServerMessage faultMessage;

            if (requestMessage != null)
            {
                faultMessage = new SoapServerMessage(context.Request, soex, requestMessage.MethodStubInfo, requestMessage.Server, requestMessage.Stream);
            }
            else
            {
                faultMessage = new SoapServerMessage(context.Request, soex, null, null, null);
            }
#if NET_2_0
            object soapVer = context.Items ["WebServiceSoapVersion"];
            if (soapVer != null)
            {
                faultMessage.SetSoapVersion((SoapProtocolVersion)soapVer);
            }
#endif

            SerializeResponse(context.Response, faultMessage);
            context.Response.End();
            return;
        }
 internal HttpStatusCode SetResponseErrorCode(HttpResponse response, SoapException soapException)
 {
     if ((soapException.SubCode != null) && (soapException.SubCode.Code == Soap12FaultCodes.UnsupportedMediaTypeFaultCode))
     {
         response.StatusCode = 0x19f;
         soapException.ClearSubCode();
     }
     else if (SoapException.IsClientFaultCode(soapException.Code))
     {
         System.Web.Services.Protocols.ServerProtocol.SetHttpResponseStatusCode(response, 500);
         for (Exception exception = soapException; exception != null; exception = exception.InnerException)
         {
             if (exception is XmlException)
             {
                 response.StatusCode = 400;
             }
         }
     }
     else
     {
         System.Web.Services.Protocols.ServerProtocol.SetHttpResponseStatusCode(response, 500);
     }
     response.StatusDescription = HttpWorkerRequest.GetStatusDescription(response.StatusCode);
     return (HttpStatusCode) response.StatusCode;
 }
コード例 #8
0
		/// <summary>
		/// Creates a new <see cref="SoapOriginalException"/> instance.
		/// </summary>
		/// <param name="exception"></param>
		public SoapOriginalException(SoapException exception) : base(GetNodeText(exception.Detail, "Message"), DeserializeException(exception.Detail))
		{
			if(exception.Detail != null)
			{
				_type = GetNodeText(exception.Detail, "Type");
				_stackTrace = GetNodeText(exception.Detail, "StackTrace");
			}
		}
コード例 #9
0
 private static void PublishSoapException(SoapException ex){
     if (ex.Detail.FirstChild.Name.Contains("RemoteAuthenticationException")){
         throw new FunctionalException("Error authenticating to JIRA: bad UserName or Password");
     }else{
         LogManager.WriteDebugMessage("TECHNICAL ERROR: " + ex.Message + "\n" + ex.StackTrace);
         throw new TechnicalException();
     }
 }
コード例 #10
0
		internal SoapServerMessage (HttpRequest request, SoapException exception, SoapMethodStubInfo stubInfo, object server, Stream stream)
			: base (stream, exception)
		{
			this.action = request.Headers ["SOAPAction"];
			this.stubInfo = stubInfo;
			this.server = server;
			this.url = request.Url.ToString();
		}
コード例 #11
0
 internal override void WriteFault(XmlWriter writer, SoapException soapException, HttpStatusCode statusCode)
 {
     if ((statusCode == HttpStatusCode.InternalServerError) && (soapException != null))
     {
         SoapServerMessage message = base.ServerProtocol.Message;
         writer.WriteStartDocument();
         writer.WriteStartElement("soap", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
         writer.WriteAttributeString("xmlns", "soap", null, "http://schemas.xmlsoap.org/soap/envelope/");
         writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
         writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
         if (base.ServerProtocol.ServerMethod != null)
         {
             SoapHeaderHandling.WriteHeaders(writer, base.ServerProtocol.ServerMethod.outHeaderSerializer, message.Headers, base.ServerProtocol.ServerMethod.outHeaderMappings, SoapHeaderDirection.Fault, base.ServerProtocol.ServerMethod.use == SoapBindingUse.Encoded, base.ServerType.serviceNamespace, base.ServerType.serviceDefaultIsEncoded, "http://schemas.xmlsoap.org/soap/envelope/");
         }
         else
         {
             SoapHeaderHandling.WriteUnknownHeaders(writer, message.Headers, "http://schemas.xmlsoap.org/soap/envelope/");
         }
         writer.WriteStartElement("Body", "http://schemas.xmlsoap.org/soap/envelope/");
         writer.WriteStartElement("Fault", "http://schemas.xmlsoap.org/soap/envelope/");
         writer.WriteStartElement("faultcode", "");
         XmlQualifiedName name = TranslateFaultCode(soapException.Code);
         if (((name.Namespace != null) && (name.Namespace.Length > 0)) && (writer.LookupPrefix(name.Namespace) == null))
         {
             writer.WriteAttributeString("xmlns", "q0", null, name.Namespace);
         }
         writer.WriteQualifiedName(name.Name, name.Namespace);
         writer.WriteEndElement();
         writer.WriteStartElement("faultstring", "");
         if ((soapException.Lang != null) && (soapException.Lang.Length != 0))
         {
             writer.WriteAttributeString("xml", "lang", "http://www.w3.org/XML/1998/namespace", soapException.Lang);
         }
         writer.WriteString(base.ServerProtocol.GenerateFaultString(soapException));
         writer.WriteEndElement();
         string actor = soapException.Actor;
         if (actor.Length > 0)
         {
             writer.WriteElementString("faultactor", "", actor);
         }
         if (!(soapException is SoapHeaderException))
         {
             if (soapException.Detail == null)
             {
                 writer.WriteStartElement("detail", "");
                 writer.WriteEndElement();
             }
             else
             {
                 soapException.Detail.WriteTo(writer);
             }
         }
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.Flush();
     }
 }
コード例 #12
0
        internal override void WriteFault(XmlWriter writer, SoapException soapException)
        {
            SoapServerMessage message = ServerProtocol.Message;

            writer.WriteStartDocument();
            writer.WriteStartElement("soap", Soap.Envelope, Soap.Namespace);
            writer.WriteAttributeString("xmlns", "soap", null, Soap.Namespace);
            writer.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
            writer.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace);
            if (ServerProtocol.ServerMethod != null)
            {
                SoapHeaderHandling.WriteHeaders(writer, ServerProtocol.ServerMethod.outHeaderSerializer, message.Headers, ServerProtocol.ServerMethod.outHeaderMappings, SoapHeaderDirection.Fault, ServerProtocol.ServerMethod.use == SoapBindingUse.Encoded, ServerType.serviceNamespace, ServerType.serviceDefaultIsEncoded, Soap.Namespace);
            }
            else
            {
                SoapHeaderHandling.WriteUnknownHeaders(writer, message.Headers, Soap.Namespace);
            }
            writer.WriteStartElement(Soap.Body, Soap.Namespace);

            writer.WriteStartElement(Soap.Fault, Soap.Namespace);
            writer.WriteStartElement(Soap.FaultCode, "");
            XmlQualifiedName code = TranslateFaultCode(soapException.Code);

            if (code.Namespace != null && code.Namespace.Length > 0 && writer.LookupPrefix(code.Namespace) == null)
            {
                writer.WriteAttributeString("xmlns", "q0", null, code.Namespace);
            }
            writer.WriteQualifiedName(code.Name, code.Namespace);
            writer.WriteEndElement();
            writer.WriteElementString(Soap.FaultString, "", ServerProtocol.GenerateFaultString(soapException));
            // Only write an actor element if the actor was specified (it's optional for end-points)
            string actor = soapException.Actor;

            if (actor.Length > 0)
            {
                writer.WriteElementString(Soap.FaultActor, "", actor);
            }

            // Only write a FaultDetail element if exception is related to the body (not a header)
            if (!(soapException is SoapHeaderException))
            {
                if (soapException.Detail == null)
                {
                    writer.WriteStartElement(Soap.FaultDetail, "");
                    writer.WriteEndElement();
                }
                else
                {
                    soapException.Detail.WriteTo(writer);
                }
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Flush();
        }
コード例 #13
0
        internal override void WriteFault(XmlWriter writer, SoapException soapException)
        {
            writer.WriteStartDocument();
            writer.WriteStartElement("soap", Soap.Envelope, Soap12.Namespace);
            writer.WriteAttributeString("xmlns", "soap", null, Soap12.Namespace);
            writer.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
            writer.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace);
            if (ServerProtocol.ServerMethod != null)
            {
                SoapHeaderHandling.WriteHeaders(writer, ServerProtocol.ServerMethod.outHeaderSerializer, ServerProtocol.Message.Headers, ServerProtocol.ServerMethod.outHeaderMappings, SoapHeaderDirection.Fault, ServerProtocol.ServerMethod.use == SoapBindingUse.Encoded, ServerType.serviceNamespace, ServerType.serviceDefaultIsEncoded, Soap12.Namespace);
            }
            else
            {
                SoapHeaderHandling.WriteUnknownHeaders(writer, ServerProtocol.Message.Headers, Soap12.Namespace);
            }

            writer.WriteStartElement(Soap.Body, Soap12.Namespace);

            writer.WriteStartElement(Soap.Fault, Soap12.Namespace);
            writer.WriteStartElement(Soap12.FaultCode, Soap12.Namespace);
            WriteFaultCodeValue(writer, TranslateFaultCode(soapException.Code), soapException.Subcode);
            writer.WriteEndElement(); // </faultcode>
            writer.WriteElementString(Soap12.FaultReason, Soap12.Namespace, ServerProtocol.GenerateFaultString(soapException));
            // Only write an actor element if the actor was specified (it's optional for end-points)
            string actor = soapException.Actor;

            if (actor.Length > 0)
            {
                writer.WriteElementString(Soap12.FaultNode, Soap12.Namespace, actor);
            }

            string role = soapException.Role;

            if (role.Length > 0)
            {
                writer.WriteElementString(Soap12.FaultRole, Soap12.Namespace, role);
            }

            // Only write a FaultDetail element if exception is related to the body (not a header)
            if (!(soapException is SoapHeaderException))
            {
                if (soapException.Detail == null)
                {
                    writer.WriteStartElement(Soap12.FaultDetail, Soap12.Namespace);
                    writer.WriteEndElement();
                }
                else
                {
                    soapException.Detail.WriteTo(writer);
                }
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Flush();
        }
コード例 #14
0
 internal override void WriteFault(XmlWriter writer, SoapException soapException, HttpStatusCode statusCode)
 {
     if ((statusCode == HttpStatusCode.InternalServerError) && (soapException != null))
     {
         writer.WriteStartDocument();
         writer.WriteStartElement("soap", "Envelope", "http://www.w3.org/2003/05/soap-envelope");
         writer.WriteAttributeString("xmlns", "soap", null, "http://www.w3.org/2003/05/soap-envelope");
         writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
         writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
         if (base.ServerProtocol.ServerMethod != null)
         {
             SoapHeaderHandling.WriteHeaders(writer, base.ServerProtocol.ServerMethod.outHeaderSerializer, base.ServerProtocol.Message.Headers, base.ServerProtocol.ServerMethod.outHeaderMappings, SoapHeaderDirection.Fault, base.ServerProtocol.ServerMethod.use == SoapBindingUse.Encoded, base.ServerType.serviceNamespace, base.ServerType.serviceDefaultIsEncoded, "http://www.w3.org/2003/05/soap-envelope");
         }
         else
         {
             SoapHeaderHandling.WriteUnknownHeaders(writer, base.ServerProtocol.Message.Headers, "http://www.w3.org/2003/05/soap-envelope");
         }
         writer.WriteStartElement("Body", "http://www.w3.org/2003/05/soap-envelope");
         writer.WriteStartElement("Fault", "http://www.w3.org/2003/05/soap-envelope");
         writer.WriteStartElement("Code", "http://www.w3.org/2003/05/soap-envelope");
         WriteFaultCodeValue(writer, TranslateFaultCode(soapException.Code), soapException.SubCode);
         writer.WriteEndElement();
         writer.WriteStartElement("Reason", "http://www.w3.org/2003/05/soap-envelope");
         writer.WriteStartElement("Text", "http://www.w3.org/2003/05/soap-envelope");
         writer.WriteAttributeString("xml", "lang", "http://www.w3.org/XML/1998/namespace", System.Web.Services.Res.GetString("XmlLang"));
         writer.WriteString(base.ServerProtocol.GenerateFaultString(soapException));
         writer.WriteEndElement();
         writer.WriteEndElement();
         string actor = soapException.Actor;
         if (actor.Length > 0)
         {
             writer.WriteElementString("Node", "http://www.w3.org/2003/05/soap-envelope", actor);
         }
         string role = soapException.Role;
         if (role.Length > 0)
         {
             writer.WriteElementString("Role", "http://www.w3.org/2003/05/soap-envelope", role);
         }
         if (!(soapException is SoapHeaderException))
         {
             if (soapException.Detail == null)
             {
                 writer.WriteStartElement("Detail", "http://www.w3.org/2003/05/soap-envelope");
                 writer.WriteEndElement();
             }
             else
             {
                 soapException.Detail.WriteTo(writer);
             }
         }
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.Flush();
     }
 }
コード例 #15
0
ファイル: SoapServerMessage.cs プロジェクト: Profit0004/mono
		internal SoapServerMessage (HttpRequest request, SoapException exception, SoapMethodStubInfo stubInfo, object server, Stream stream)
			: base (stream, exception)
		{
			this.action = request.Headers ["SOAPAction"];
			if (this.action != null)
				this.action = action.Trim ('"',' ');
			this.stubInfo = stubInfo;
			this.server = server;
			this.url = request.Url.ToString();
			ContentEncoding = request.Headers ["Content-Encoding"];
		}
コード例 #16
0
ファイル: Case.asmx.cs プロジェクト: BrandonErb/SOA_A3
        public string CaseConvert(string incoming, int flag)
        {
            try
            {
                string result = "UNKNOWN ERROR";
                //test
                //maybe do a check for numerical contents??? probably not nessesary
                if (incoming == "")
                {
                    SoapException newEr = new SoapException("First parameter cannot be empty", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri);
                    throw newEr;
                }
                else
                {
                    switch (flag)
                    {
                        //flag indicated that user wishes to convert to upper case
                        case 1:
                            result = incoming.ToUpper();
                            break;

                        //flag indicated that user wishes to convert to upper case
                        case 2:
                            result = incoming.ToLower();
                            break;
                        default:
                            //make an error if the user enters a values other than 1 or 2 for the flag
                            SoapException newEr = new SoapException("Flag must be 1 OR 2", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri);
                            throw newEr;
                    }
                }
                return result;
            }
            //Catches a soap exception and places the error in a log file on the service machines desktop
            catch (SoapException er)
            {
                using (StreamWriter w = File.AppendText("C:\\Users\\Connor\\Desktop\\log.txt"))
                {
                    w.WriteLine(er.Message);
                }
                throw er;
            }
            //Catches any standard exception and places the error in a log file on the service machines desktop
            catch (Exception er)
            {
                using (StreamWriter w = File.AppendText("C:\\Users\\Connor\\Desktop\\log.txt"))
                {
                    w.WriteLine(er.Message);
                }
                throw er;
            }
        }
コード例 #17
0
 internal SoapServerMessage(HttpRequest request, SoapException exception, SoapMethodStubInfo stubInfo, object server, Stream stream)
     : base(stream, exception)
 {
     this.action = request.Headers ["SOAPAction"];
     if (this.action != null)
     {
         this.action = action.Trim('"', ' ');
     }
     this.stubInfo   = stubInfo;
     this.server     = server;
     this.url        = request.Url.ToString();
     ContentEncoding = request.Headers ["Content-Encoding"];
 }
コード例 #18
0
        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;
        }
コード例 #19
0
        public void AfterThrowing(SoapException ex)
        {
            Exception exception = null;
            try
            {
                exception = TransferException.DeserializeFromMessage(ex.Message);
            }
            catch
            {
                throw ex;
            }

            if (exception == null) throw ex;
            throw exception;
        }
コード例 #20
0
        /// <summary>
        /// A method used to load the XML string for the detail element in the SOAP exception.
        /// </summary>
        /// <param name="soapEx">A parameter represents SOAP exception.</param>
        /// <returns>A return value represents the xml string of the "Detail" property in SOAP exception.</returns>
        private static string LoadSoapFaultDetailXml(SoapException soapEx)
        {
            if (null == soapEx.Detail || string.IsNullOrEmpty(soapEx.Detail.OuterXml))
            {
                throw new ArgumentException("The SOAP exception should contain the detail value.");
            }

            // Load the original "detail" element.
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(soapEx.Detail.OuterXml);
            XmlElement originalDetailElement = xmlDoc.DocumentElement;

            if (!originalDetailElement.LocalName.Equals("detail", StringComparison.OrdinalIgnoreCase))
            {
                string errorMsg = string.Format("The root element should be \"Detail\" or \"detail\".Current XML fragment:\r\n[{0}]", soapEx.Detail.OuterXml);
                throw new XmlSchemaValidationException(errorMsg);
            }
 
            // [Note] According to SOAP1.1 and SOAP 1.2 definitions, SOAP1.1 defines subelement 'detail' in SOAP Fault element, SOAP1.2 defines subelement "Detail". But actually, whether the soap fault response message are formatted with SOAP 1.1 or 1.2, the subelement name in O12, O14 and O15 response is always "detail".
            // This test suite does not verify the SOAP fault element whether contain the correct "detail" or "Detail" element in sequence. The "detail" and "Detail" element is defined as extendable element in W3C standard, there are some different implementations for them.
            // This test suite only verify the "detail" or "Detail" element whether contain the correct extendable content which is defined in MS-COPYS.(child elements definitions of as described in section 2.2.2.1), so the test suite will construct a new "detail" element to store all the child elements in order to perform the schema validation. 
            XmlDocument newXmlfragment = new XmlDocument();

            // This test suite will build a new "detail" element which contains the actual detail information, and this new "detail" element always point to the "http://schemas.microsoft.com/sharepoint/soap/" name space.
            XmlElement newBuildDetailElement = newXmlfragment.CreateElement("detail");

            // Copy the attributes from original detail element.
            if (null != originalDetailElement.Attributes && 0 != originalDetailElement.Attributes.Count)
            {
                foreach (XmlAttribute attributeItem in originalDetailElement.Attributes)
                {
                    XmlAttribute newAddedAttribute = newXmlfragment.CreateAttribute(attributeItem.Name, attributeItem.NamespaceURI);
                    newAddedAttribute.Value = attributeItem.Value;
                    newBuildDetailElement.Attributes.Append(newAddedAttribute);
                }
            }

            // Copy the child nodes from original detail element. 
            foreach (XmlNode xmlNodeItem in originalDetailElement.ChildNodes)
            {
                newXmlfragment.LoadXml(xmlNodeItem.OuterXml);
                newBuildDetailElement.AppendChild(newXmlfragment.DocumentElement);
            }

            // Point to the "http://schemas.microsoft.com/sharepoint/soap/" namespace which matches the WSDL used by test suite.
            newBuildDetailElement.SetAttribute("xmlns", @"http://schemas.microsoft.com/sharepoint/soap/");
            return newBuildDetailElement.OuterXml;
         }
コード例 #21
0
        public void SetSoapFaultException(WSOperation operation, SoapException soapEx, WSDescriberForReport WSItemVulnerabilities, bool isDebug)
        {
            if (WSItemVulnerabilities.Vulns.Where(v => v.VulnerableMethodName.Equals(operation.MethodName) && v.Vuln.id == 7).Count() <= 0) // aynı method için sadece 1 tane soap fault zafiyeti yaz
            {
                mainForm.Log("   Soap Exception: " + soapEx.ToString(), FontStyle.Regular, isDebug);

                VulnerabilityForReport soapFaultVuln = new VulnerabilityForReport();
                soapFaultVuln.Vuln = MainForm.vulnerabilities.Vulnerability.Where(v => v.id == 7).FirstOrDefault();
                soapFaultVuln.VulnerableMethodName = operation.MethodName;
                soapFaultVuln.VulnerableParamName = "";
                soapFaultVuln.Payload = "";
                soapFaultVuln.Response = soapEx.Message;
                soapFaultVuln.StatusCode = "";

                WSItemVulnerabilities.Vulns.Add(soapFaultVuln);
            }
        }
コード例 #22
0
ファイル: ErrorUtility.cs プロジェクト: udbeeq5566/ESB
 /// <summary>
 /// Extracts the error code.
 /// </summary>
 /// <param name="ex">The executable.</param>
 /// <returns></returns>
 public static int ExtractErrorCode(SoapException ex)
 {
     if (ex.Detail != null)
     {
         var element = ex.Detail.SelectSingleNode("error/code") as XmlElement;
         if (element != null)
         {
             string innerText = element.InnerText;
             if (innerText.StartsWith("0x", StringComparison.Ordinal))
             {
                 innerText = innerText.Substring(2);
             }
             return int.Parse(innerText, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);
         }
     }
     return -2147220970;
 }
コード例 #23
0
        protected static void Error(Exception e)
        {
            StringBuilder sb = new StringBuilder();

            if (e is System.Web.Services.Protocols.SoapException)
            {
                System.Web.Services.Protocols.SoapException se = e as System.Web.Services.Protocols.SoapException;
                sb.Append("SOAP-Fault code: " + se.Code.ToString());
                sb.Append("\n");
            }
            if (e != null)
            {
                sb.Append(e.ToString());
            }
            Console.WriteLine("*** Exception Raised ***");
            Console.WriteLine(sb.ToString());
            Console.WriteLine("************************");
        }
コード例 #24
0
        internal StepType GetNodesTest(out PTZNode[] target, out System.Web.Services.Protocols.SoapException ex, out int Timeout)
        {
            StepType res = StepType.None;

            Timeout = 0;
            ex      = null;
            target  = null;
            bool   passed     = true;
            string logMessage = "";

            string tmpCommandName   = "GetNodes";
            int    tmpCommandNumber = GetNodes;


            //Get step list for command
            XmlNodeList m_testList = m_TestCommon.GetStepsForCommand(ServiceName + "." + tmpCommandName);

            //TEMP: for backward compatibility
            if (m_testList.Count == 0)
            {
                m_testList = m_TestCommon.GetStepsForCommand(tmpCommandName);
            }

            if (m_testList.Count != 0)
            {
                //Get current step
                XmlNode test = m_testList[m_commandCount[tmpCommandNumber]];

                //Generate response
                object targetObj;
                res    = m_TestCommon.GenerateResponseStepTypeNotVoid(test, out targetObj, out ex, out Timeout, typeof(PTZNode[]));
                target = (PTZNode[])targetObj;

                //Log message
                m_TestCommon.writeToLog(test, logMessage, passed);

                Increment(m_testList.Count, tmpCommandNumber);
            }
            else
            {
                throw new SoapException("NO " + ServiceName + "." + tmpCommandName + " COMMAND IN SCRIPT", SoapException.ServerFaultCode);
            }
            return(res);
        }
コード例 #25
0
        /// <summary>
        /// Verify the requirements of the SOAP fault when the SOAP fault is received.
        /// </summary>
        /// <param name="soapExp">The returned SOAP fault</param>
        private void VerifySoapFaultRequirements(SoapException soapExp) 
        {
            // If a SOAP fault is returned and the SOAP fault is not null, which means protocol server faults are returned using SOAP faults, then the following requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                soapExp,
                3000,
                @" [In Transport]Protocol server faults MUST be returned using SOAP faults as specified either in [SOAP1.1], section 4.4 ""SOAP Fault"" or in [SOAP1.2/1], section 5.4 ""SOAP Fault.""");

            // The schemas are validated during invoking the operations and an XmlSchemaValidationException will be thrown if anyone of the schemas is incorrect, there is no such exception thrown, so the following requirement can be captured.
            Site.CaptureRequirement(
                7,
                @"[In SOAPFaultDetails]The schema of SOAPFaultDetails is defined as: <s:schema xmlns:s=""http://www.w3.org/2001/XMLSchema"" targetNamespace="" http://schemas.microsoft.com/sharepoint/soap"">
                   <s:complexType name=""SOAPFaultDetails"">
                      <s:sequence>
                         <s:element name=""errorstring"" type=""s:string""/>
                         <s:element name=""errorcode"" type=""s:string"" minOccurs=""0""/>
                      </s:sequence>
                   </s:complexType>
                </s:schema>");
           
            // Extract the errorcode from SOAP fault.
            string strErrorCode = Common.ExtractErrorCodeFromSoapFault(soapExp);
            if (strErrorCode != null)
            {
                Site.Assert.IsTrue(strErrorCode.StartsWith("0x", StringComparison.CurrentCultureIgnoreCase), "The error code value should start with '0x'.");
                Site.Assert.IsTrue(strErrorCode.Length == 10, "The error code value's length should be 10.");
    
                // If the value of the errorcode starts with "0x" and the length is 10, which means the format of the value is 0xAAAAAAAA, then the following requirement can be captured.
                Site.CaptureRequirement(
                    2015,
                    @"[In SOAPFaultDetails]The format inside the string [errorcode] MUST be 0xAAAAAAAA.");
            }

            // If a SOAP fault is returned and the SOAP fault is not null, which means protocol server faults are returned using SOAP faults, then the following requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                soapExp,
                2019,
                @"[In Protocol Details]This protocol [MS-ADMINS] allows protocol servers to notify protocol clients of application-level faults using SOAP faults.");

            // The schemas are validated during invoking the operations and an XmlSchemaValidationException will be thrown if anyone of the schemas is incorrect, there is no such exception thrown and only SOAPFaultDetails complex type is included in the schemas, which means the detail element in the SOAP faults is conforms to the SOAPFaultDetails complex type, so the following requirement can be captured.
            Site.CaptureRequirement(
                2020,
                @"[In Protocol Details]This protocol [MS-ADMINS] allows protocol servers to provide additional details for SOAP faults by including a detail element as specified either in [SOAP1.1], section 4.4 ""SOAP Fault"" or [SOAP1.2/1], section 5.4 ""SOAP Fault"" that conforms to the XML schema of the SOAPFaultDetails complex type specified in section 2.2.4.1.");
        }
コード例 #26
0
ファイル: SoapErrorHandler.cs プロジェクト: 0anion0/IBN
        public static SyncronizationServiceError HandleError(SoapException soapException)
        {
            SyncronizationServiceError error = null;
            XmlDocument xml = new XmlDocument();
            XmlNodeList detailErrors = null;
            XmlNamespaceManager nameSpaceManager = null;

            try
            {
                if (soapException.Detail.OuterXml.IndexOf("detail") > 0)
                {
                    nameSpaceManager = new XmlNamespaceManager(xml.NameTable);
                    xml.LoadXml(soapException.Detail.OuterXml);
                    nameSpaceManager = new XmlNamespaceManager(xml.NameTable);
                    nameSpaceManager.AddNamespace("tns", soapException.Node);
                    detailErrors = xml.SelectNodes("//tns:Error", nameSpaceManager);

                    foreach (XmlNode detailError in detailErrors)
                    {
                        error = new SyncronizationServiceError();

                        error.stackTrace = detailError.SelectSingleNode("./tns:ErrorStackTrace", nameSpaceManager).InnerText;

                        error.message = detailError.SelectSingleNode("./tns:ErrorMessage", nameSpaceManager).InnerText;

                        error.name = detailError.SelectSingleNode("./tns:ErrorSource", nameSpaceManager).InnerText;

                        string errorType = detailError.SelectSingleNode("./tns:ErrorType", nameSpaceManager).InnerText;
                        error.errorType = SyncronizationServiceError.eServiceErrorType.Undef;
                        if(!string.IsNullOrEmpty(errorType))
                        {
                            error.errorType = (SyncronizationServiceError.eServiceErrorType)
                                                Enum.Parse(typeof(SyncronizationServiceError.eServiceErrorType), errorType);
                        }
                        break;
                    }
                }
            }
            catch (Exception)
            {
            }
            return error;
        }
コード例 #27
0
 internal override void SetResponseErrorCode(HttpResponse response, SoapException soapException)
 {
     if (soapException.Subcode != null && soapException.Subcode.Code == Soap12FaultCodes.UnsupportedMediaTypeFaultCode)
     {
         response.StatusCode        = (int)HttpStatusCode.UnsupportedMediaType;
         response.StatusDescription = Res.GetString(Res.WebUnsupportedMediaTypeStatusDescription);
         soapException.ClearSubcode();
     }
     else if (SoapException.IsClientFaultCode(soapException.Code))
     {
         response.StatusCode        = (int)HttpStatusCode.BadRequest;
         response.StatusDescription = Res.GetString(Res.WebBadRequestStatusDescription);
     }
     else
     {
         response.StatusCode        = (int)HttpStatusCode.InternalServerError;
         response.StatusDescription = Res.GetString(Res.WebRequestErrorStatusDescription);
     }
 }
コード例 #28
0
 /// <summary>
 /// Extracts the original exception from a soap call, so that the calling code
 /// does not see the exception as a soap exception.
 /// </summary>
 private SoapException HandleSoapException(SoapException e)
 {
     try {
         string st            = e.Message;
         int    i             = st.IndexOf("--->") + 5;
         int    j             = st.IndexOf(":", i) - 1;
         string ExceptionName = st.Substring(i, j - i);
         i  = j + 3;
         j  = st.IndexOf("\n", i) - i;
         st = st.Substring(i, j);
         Exception e1;
         try { e1 = (Exception)Type.GetType(ExceptionName).GetConstructor(new Type[] { typeof(string) }).Invoke(new object[] { st }); }
         catch { e1 = new Exception(st); }
         e = new System.Web.Services.Protocols.SoapException(e.Message.Replace("\n", "\r\n").Replace("--->", "\r\n   --->"), e.Code, e.Actor, e.Detail, e1);
     }
     // PC Security Defect Fix -CH1 -START Modified the below code to add logging inside the catch block
     catch (Exception ex) { Logger.Log(ex.ToString()); }
     // PC Security Defect Fix -CH1 -END Modified the below code to add logging inside the catch block
     return(e);
 }
コード例 #29
0
ファイル: Fault12.cs プロジェクト: samcf111/unityMono5.5.0
        public Soap12Fault(SoapException ex)
        {
            Code       = new Soap12FaultCode();
            Code.Value = ex.Code;
            if (ex.SubCode != null)
            {
                Code.Subcode = CreateFaultCode(ex.SubCode);
            }
            Node   = ex.Node;
            Role   = ex.Role;
            Reason = new Soap12FaultReason();
            Soap12FaultReasonText text =
                new Soap12FaultReasonText();

            text.XmlLang = ex.Lang;
            text.Value   = ex.Message;
            Reason.Texts = new Soap12FaultReasonText [] { text };
            if (ex.Detail != null)
            {
                Detail = new Soap12FaultDetail();
                if (ex.Detail.NodeType == XmlNodeType.Attribute)
                {
                    Detail.Attributes = new XmlAttribute [] {
                        (XmlAttribute)ex.Detail
                    }
                }
                ;
                else if (ex.Detail.NodeType == XmlNodeType.Element)
                {
                    Detail.Children = new XmlElement [] {
                        (XmlElement)ex.Detail
                    }
                }
                ;
                else
                {
                    Detail.Text = ex.Detail.Value;
                }
            }
        }
コード例 #30
0
    private object InvokeConfluenceMethod(string methodName, params object[] args)
    {
        int numOfCalls = 0;

        while (true)
        {
            try {
                object[] newArgs = new object[args.Length + 1];
                newArgs[0] = _token;
                args.CopyTo(newArgs, 1);
                return(_confluenceSoapServiceType.InvokeMember(methodName, System.Reflection.BindingFlags.InvokeMethod,
                                                               null, _confluenceService, newArgs));
            } catch (System.Reflection.TargetInvocationException e) {
                if (e.InnerException == null)
                {
                    throw;
                }
                System.Web.Services.Protocols.SoapException soapException =
                    e.InnerException as System.Web.Services.Protocols.SoapException;
                if (soapException == null)
                {
                    throw e.InnerException;
                }
                numOfCalls++;
                if (numOfCalls >= MaxMethodCalls)
                {
                    throw soapException;
                }

                string message = "Confluence exception. ";
                if (soapException.Detail != null)
                {
                    message += soapException.Detail.OuterXml;
                }
                WriteToLog(message);

                Reconnect();
            }
        }
    }
コード例 #31
0
 /// <summary>
 /// Grab the response code from within a soap exception (Listing 18-16)
 /// </summary>
 /// <param name="soapException">Soap Exception to examine</param>
 /// <returns>True if parse was successful</returns>
 ///
 public static bool TryGetResponseCodeFromSoapException(
                                     SoapException soapException,
                                     out ResponseCodeType responseCode)
 {
     responseCode = ResponseCodeType.NoError;
     XmlElement detailElement = (XmlElement)soapException.Detail;
     if (detailElement == null)
     {
         return false;
     }
     XmlElement responseCodeElement = detailElement[
                "ResponseCode",
                "http://schemas.microsoft.com/exchange/services/2006/errors"];
     if (responseCodeElement == null)
     {
         return false;
     }
     responseCode = (ResponseCodeType)Enum.Parse(
                     typeof(ResponseCodeType),
                     responseCodeElement.InnerText);
     return true;
 }
コード例 #32
0
        /// <summary>
        /// A method used to record a SOAP Exception information into the log.
        /// </summary>
        /// <param name="soapEx">A parameter represents the SoapException instance which will be record.</param>
        /// <param name="testSiteInstance">A parameter represents the ITestSite instance which contains test context.</param>
        private static void RecordSoapExceptionInfor(SoapException soapEx, ITestSite testSiteInstance)
        {
            string detailOutPut = string.Empty;
            if (null == soapEx.Detail || string.IsNullOrEmpty(soapEx.Detail.OuterXml))
            {
                detailOutPut = "None";
            }
            else
            {
                detailOutPut = soapEx.Detail.OuterXml;
            }

            TestSuiteManageHelper.Initialize(testSiteInstance);
            testSiteInstance.Log.Add(
                                    LogEntryKind.Debug,
                                    @"There is a SoapException generated. Information:\r\nMessage:[{0}]\r\nStackTrace:[{1}]\r\ndetail:[{2}]\r\nSoapVersion:[{3}]\r\nUrl:[{4}]",
                                    soapEx.Message,
                                    soapEx.StackTrace,
                                    detailOutPut,
                                    TestSuiteManageHelper.CurrentSoapVersion,
                                    string.IsNullOrEmpty(soapEx.Role) ? "None/Empty" : soapEx.Role);
        }
コード例 #33
0
        /// <summary>
        /// A method used to validate the schema definition for the detail element of a SOAP fault. If the schema validation is not successful, this method will raise an XmlSchemaValidationException.
        /// </summary>
        /// <param name="soapEx">A parameter represents the SoapException instance which will be recorded.</param>
        /// <param name="testSiteInstance">A parameter represents the ITestSite instance which contains test context.</param>
        public static void ValidateSoapFaultDetail(SoapException soapEx, ITestSite testSiteInstance)
        { 
           if (null == soapEx)
           {
               throw new ArgumentNullException("soapEx");
           }

          if (null == testSiteInstance)
          {
             throw new ArgumentNullException("testSiteInstance");
          }

          RecordSoapExceptionInfor(soapEx, testSiteInstance);

          string detailValue = LoadSoapFaultDetailXml(soapEx);
          SchemaValidation.ValidateXml(testSiteInstance, detailValue);
          if (SchemaValidation.XmlValidationErrors.Count != 0 || SchemaValidation.XmlValidationWarnings.Count != 0)
          {
              string errorString = string.Format("There are schema validation issues for detail element of SOAP fault.\r\n:{0}", SchemaValidation.GenerateValidationResult());
              throw new XmlSchemaValidationException(errorString);
          }
        }
コード例 #34
0
    /// <summary>
    /// Gets a custom exception that wraps the SOAP exception thrown
    /// by the server.
    /// </summary>
    /// <param name="ex">SOAPException that was thrown by the server.</param>
    /// <returns>A custom exception object that wraps the SOAP exception.
    /// </returns>
    protected override Exception GetCustomException(SoapException ex) {
      string defaultNs = GetDefaultNamespace();
      if (!string.IsNullOrEmpty(defaultNs)) {
        // Extract the ApiExceptionFault node.
        XmlElement faultNode = GetFaultNode(ex, defaultNs, "ApiExceptionFault");

        if (faultNode != null) {
          try {
            DfpApiException dfpException = new DfpApiException(
                SerializationUtilities.DeserializeFromXmlTextCustomRootNs(
                    faultNode.OuterXml,
                    Assembly.GetExecutingAssembly().GetType(
                        this.GetType().Namespace + ".ApiException"), defaultNs,
                        "ApiExceptionFault"),
                ex.Message, ex);
            return dfpException;
          } catch (Exception) {
            // deserialization failed, but we can safely ignore it.
          }
        }
      }
      return new DfpApiException(null, ex.Message, ex);
    }
コード例 #35
0
        /// <summary>
        /// Validate SOAP Fault message according to schema and capture related requirements.
        /// </summary>
        /// <param name="exception">The SoapException thrown.</param>
        private void ValidateAndCaptureSoapFaultRequirements(SoapException exception)
        {
            // Since there is an SoapException returned, MS-MEETS_R4101 can be verified.
            Site.CaptureRequirementIfIsNotNull(
                exception,
                4101,
                @"[In Transport][Protocol server faults MUST be returned by]using SOAP faults as specified in [SOAP1.1]section 4.4, SOAP Fault or [SOAP1.2/1]section 5.4, SOAP Fault.");

            bool isResponseValid = SchemaValidation.ValidateXml(this.Site, SchemaValidation.GetSoapFaultDetailBody(exception.Detail.OuterXml)) == ValidationResult.Success;

            // If the schema validation for SOAP fault is success, MS-MEETS_R3021 can be verified.
            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                3021,
                @"[In Detail]Whenever an operation in this protocol fails, it [server] returns a SOAP fault in this format [as in Detail schema].");

            // If the schema validation for SOAP fault is success, MS-MEETS_R3022 can be verified.
            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                3022,
                @"[In Detail]This element [Detail]is defined as follows.
                <s:element name=""detail"">
                  <s:complexType>
                    <s:sequence>
                      <s:element name=""errorstring"" type=""s:string"" minOccurs=""1"" maxOccurs=""1""/>
                      <s:element name=""errorcode"" type=""s:string"" minOccurs=""0"" maxOccurs=""1""/>
                    </s:sequence>
                  </s:complexType>
                </s:element>");

            // After validating SOAP fault message xml, we can make sure that the response soap fault body contains them.
            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                10,
                @"[In Detail]It [detail]consists of a SOAP fault code combined with SOAP fault detail text that describes the error.");
        }
コード例 #36
0
        internal override bool WriteException(Exception e, Stream outputStream)
        {
            if (message == null)
            {
                return(false);
            }

            message.Headers.Clear();
            if (serverMethod != null)
            {
                SoapHeaderHandling.GetHeaderMembers(message.Headers, this.Target, serverMethod.outHeaderMappings, SoapHeaderDirection.Fault, false);
            }

            SoapException soapException;

            if (e is SoapException)
            {
                soapException = (SoapException)e;
            }
            else if (serverMethod != null && serverMethod.rpc && helper.Version == SoapProtocolVersion.Soap12 && e is ArgumentException)
            {
                // special case to handle soap 1.2 rpc "BadArguments" fault
                soapException = new SoapException(Res.GetString(Res.WebRequestUnableToProcess), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace), null, null, null, new SoapFaultSubcode(Soap12FaultCodes.RpcBadArgumentsFaultCode), e);
            }
            else
            {
                soapException = new SoapException(Res.GetString(Res.WebRequestUnableToProcess), new XmlQualifiedName(Soap.ServerCode, Soap.Namespace), e);
            }

            if (SoapException.IsVersionMismatchFaultCode(soapException.Code))
            {
                if (IsSupported(ProtocolsEnum.HttpSoap12))
                {
                    SoapUnknownHeader unknownHeader = CreateUpgradeHeader();
                    if (unknownHeader != null)
                    {
                        Message.Headers.Add(unknownHeader);
                    }
                }
            }

            Response.ClearHeaders();
            Response.Clear();
            helper.SetResponseErrorCode(Response, soapException);

            bool disableExtensions = false;

            if (message.allExtensions != null)
            {
                message.SetExtensionStream(new SoapExtensionStream());
            }

            try {
                message.InitExtensionStreamChain(message.allExtensions);
            }
            catch (Exception) {
                disableExtensions = true;
            }
            message.SetStage(SoapMessageStage.BeforeSerialize);
            message.ContentType = ContentType.Compose(helper.HttpContentType, Encoding.UTF8);
            message.SetException(soapException);
            if (!disableExtensions)
            {
                try {
                    message.RunExtensions(message.allExtensions);
                }
                catch (Exception) {
                    disableExtensions = true;
                }
            }
            message.SetStream(outputStream);
            Response.ContentType = message.ContentType;
            if (message.ContentEncoding != null && message.ContentEncoding.Length > 0)
            {
                Response.AppendHeader(ContentType.ContentEncoding, message.ContentEncoding);
            }

            bool          isEncoded = serverMethod != null && serverMethod.use == SoapBindingUse.Encoded;
            StreamWriter  sw        = new StreamWriter(message.Stream, new UTF8Encoding(false), 128);
            XmlTextWriter writer    = isEncoded && message.Headers.Count > 0 ? new XmlSpecialTextWriter(sw, helper.Version) : new XmlTextWriter(sw);

            writer.Formatting  = Formatting.Indented; // CONSIDER, don't format to save space
            writer.Indentation = 2;                   // CONSIDER, don't indent to save space

            helper.WriteFault(writer, soapException);

            if (!disableExtensions)
            {
                try {
                    message.SetStage(SoapMessageStage.AfterSerialize);
                    message.RunExtensions(message.allExtensions);
                }
                catch (Exception) {
                    // it's too late to do anything about this -- we've already written to the stream
                }
            }
            return(true);
        }
コード例 #37
0
		/// <summary>
		/// Parses a soap fault into an ApiException.
		/// </summary>
		/// <param name="soapex">The <see cref="SoapException"/>.</param>
		/// <returns>The <see cref="ApiException"/>.</returns>
		static public ApiException FromSoapException(SoapException soapex)
		{
			ErrorType errorType = new ErrorType();
			XmlNode details = soapex.Detail;

			XPathExpression expr;
			XPathNavigator nav = details.CreateNavigator();
			System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(details.OwnerDocument.NameTable);
			//nsmgr.AddNamespace("pfx", "urn:ebay:apis:eBLBaseComponents");

			expr = nav.Compile("/FaultDetail");
			expr.SetContext(nsmgr);

			XmlNode faultdet = XmlUtility.GetChildNode(nav, expr);

			if (faultdet != null)
			{
				nav = faultdet.CreateNavigator();
				errorType.ShortMessage  = soapex.Message.Trim();

				expr = nav.Compile("Severity");
				expr.SetContext(nsmgr);

				if (XmlUtility.GetString(nav, expr).Trim() == "Warning")
					errorType.SeverityCode = SeverityCodeType.Warning;
				else 
					errorType.SeverityCode = SeverityCodeType.Error;

				expr = nav.Compile("DetailedMessage");
				expr.SetContext(nsmgr);
				errorType.LongMessage = XmlUtility.GetString(nav, expr).Trim();

				expr = nav.Compile("ErrorCode");
				expr.SetContext(nsmgr);
				errorType.ErrorCode = XmlUtility.GetString(nav, expr).Trim();
			} 
			else
			{
				errorType.SeverityCode = SeverityCodeType.Error;
				errorType.ShortMessage  = soapex.Code.Name.Trim();
				errorType.LongMessage = soapex.Message.Trim();
				errorType.ErrorCode = "0";

			}
			
			ErrorTypeCollection etc = new ErrorTypeCollection();
			etc.Add(errorType);
		
			return new ApiException(etc);

		}
コード例 #38
0
 internal override void SetResponseErrorCode(HttpResponse response, SoapException soapException)
 {
     response.StatusCode        = (int)HttpStatusCode.InternalServerError;
     response.StatusDescription = Res.GetString(Res.WebRequestErrorStatusDescription);
 }
コード例 #39
0
        private static void ProcessException(Exception e, StringBuilder sb)
        {
            if (e != null)
            {
                if (e is WebException)
                {
                    // Process the Web Exception.
                    WebException webExcep = e as WebException;
                    if (webExcep.Response != null)
                    {
                        WebResponse response       = webExcep.Response;
                        string      str            = webExcep.Message;
                        Stream      responseStream = response.GetResponseStream();

                        if (responseStream.CanRead)
                        {
                            StreamReader reader   = new StreamReader(responseStream, System.Text.Encoding.UTF8);
                            string       excepStr = reader.ReadToEnd();
                            sb.Append("Web Exception Occured: " + excepStr);
                        }
                        else
                        {
                            sb.Append("Web Exception Occured: " + e.ToString());
                        }
                    }
                    else
                    {
                        sb.Append("Web Exception Occured: " + e.ToString());
                    }
                }
                else
                {
                    if (e is System.Web.Services.Protocols.SoapException)
                    {
                        System.Web.Services.Protocols.SoapException se = e as System.Web.Services.Protocols.SoapException;
                        sb.Append("System.Web.Services.Protocols.SoapException:");
                        sb.Append(Environment.NewLine);
                        sb.Append("SOAP-Fault code: " + se.Code.ToString());
                        sb.Append(Environment.NewLine);
                        sb.Append("Message: ");
                    }
                    else
                    {
                        sb.Append(e.GetType().FullName);
                        sb.Append(": ");
                    }

                    sb.Append(e.Message);

                    if (e.InnerException != null)
                    {
                        sb.Append(" ---> ");
                        ProcessException(e.InnerException, sb);
                        sb.Append(Environment.NewLine);
                        sb.Append("--- End of Inner Exception ---");
                    }

                    if (e.StackTrace != null)
                    {
                        sb.Append(Environment.NewLine);
                        sb.Append(e.StackTrace);
                    }
                }
            }
        }
コード例 #40
0
		//
		// TODO:
		//    Handle other web responses (multi-output?)
		//    
		object [] ReceiveResponse (WebResponse response, SoapClientMessage message, SoapExtension[] extensions)
		{
			SoapMethodStubInfo msi = message.MethodStubInfo;
			HttpWebResponse http_response = response as HttpWebResponse;
			
			if (http_response != null)
			{
				HttpStatusCode code = http_response.StatusCode;
	
				if (!(code == HttpStatusCode.Accepted || code == HttpStatusCode.OK || code == HttpStatusCode.InternalServerError)) {
					string msg = "The request failed with HTTP status {0}: {1}";
					msg = String.Format (msg, (int) code, code);
					throw new WebException (msg, null, WebExceptionStatus.ProtocolError, http_response);
				}
				if (message.OneWay && response.ContentLength == 0 && (code == HttpStatusCode.Accepted || code == HttpStatusCode.OK)) {
					return new object[0];
				}
			}
			
			//
			// Remove optional encoding
			//
			string ctype;
			Encoding encoding = WebServiceHelper.GetContentEncoding (response.ContentType, out ctype);
			if (ctype != "text/xml")
				WebServiceHelper.InvalidOperation (
					"Content is not 'text/xml' but '" + response.ContentType + "'",
					response, encoding);

			message.ContentType = ctype;
			message.ContentEncoding = encoding.WebName;
			
			Stream stream = response.GetResponseStream ();

			if (extensions != null) {
				stream = SoapExtension.ExecuteChainStream (extensions, stream);
				message.SetStage (SoapMessageStage.BeforeDeserialize);
				SoapExtension.ExecuteProcessMessage (extensions, message, false);
			}
			
			// Deserialize the response

			SoapHeaderCollection headers;
			object content;

			using (StreamReader reader = new StreamReader (stream, encoding, false)) {
				XmlTextReader xml_reader = new XmlTextReader (reader);

				WebServiceHelper.ReadSoapMessage (xml_reader, type_info, msi.Use, msi.ResponseSerializer,
								out content, out headers);
			}

			
			if (content is Fault)
			{
				Fault fault = (Fault) content;
				SoapException ex = new SoapException (fault.faultstring, fault.faultcode, fault.faultactor, fault.detail);
				message.SetException (ex);
			}
			else
				message.OutParameters = (object[]) content;
			
			message.SetHeaders (headers);
			message.UpdateHeaderValues (this, message.MethodStubInfo.Headers);

			if (extensions != null) {
				message.SetStage (SoapMessageStage.AfterDeserialize);
				SoapExtension.ExecuteProcessMessage (extensions, message, false);
			}

			if (message.Exception == null)
				return message.OutParameters;
			else
				throw message.Exception;
		}
コード例 #41
0
        internal override bool WriteException(Exception e, Stream outputStream)
        {
            SoapException exception;

            if (this.message == null)
            {
                return(false);
            }
            this.message.Headers.Clear();
            if ((this.serverMethod != null) && (this.Target != null))
            {
                SoapHeaderHandling.GetHeaderMembers(this.message.Headers, this.Target, this.serverMethod.outHeaderMappings, SoapHeaderDirection.Fault, false);
            }
            if (e is SoapException)
            {
                exception = (SoapException)e;
            }
            else if (((this.serverMethod != null) && this.serverMethod.rpc) && ((this.helper.Version == SoapProtocolVersion.Soap12) && (e is ArgumentException)))
            {
                exception = SoapException.Create(this.Version, System.Web.Services.Res.GetString("WebRequestUnableToProcess"), new XmlQualifiedName("Client", "http://schemas.xmlsoap.org/soap/envelope/"), null, null, null, new SoapFaultSubCode(Soap12FaultCodes.RpcBadArgumentsFaultCode), e);
            }
            else
            {
                exception = SoapException.Create(this.Version, System.Web.Services.Res.GetString("WebRequestUnableToProcess"), new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/"), e);
            }
            if (SoapException.IsVersionMismatchFaultCode(exception.Code) && this.IsSupported(WebServiceProtocols.HttpSoap12))
            {
                SoapUnknownHeader header = this.CreateUpgradeHeader();
                if (header != null)
                {
                    this.Message.Headers.Add(header);
                }
            }
            base.Response.ClearHeaders();
            base.Response.Clear();
            HttpStatusCode      statusCode      = this.helper.SetResponseErrorCode(base.Response, exception);
            bool                flag            = false;
            SoapExtensionStream extensionStream = new SoapExtensionStream();

            if (this.message.allExtensions != null)
            {
                this.message.SetExtensionStream(extensionStream);
            }
            try
            {
                this.message.InitExtensionStreamChain(this.message.allExtensions);
            }
            catch (Exception exception2)
            {
                if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException))
                {
                    throw;
                }
                if (Tracing.On)
                {
                    Tracing.ExceptionCatch(TraceEventType.Warning, this, "WriteException", exception2);
                }
                flag = true;
            }
            this.message.SetStage(SoapMessageStage.BeforeSerialize);
            this.message.ContentType = ContentType.Compose(this.helper.HttpContentType, Encoding.UTF8);
            this.message.Exception   = exception;
            if (!flag)
            {
                try
                {
                    this.message.RunExtensions(this.message.allExtensions, false);
                }
                catch (Exception exception3)
                {
                    if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException))
                    {
                        throw;
                    }
                    if (Tracing.On)
                    {
                        Tracing.ExceptionCatch(TraceEventType.Warning, this, "WriteException", exception3);
                    }
                    flag = true;
                }
            }
            this.message.SetStream(outputStream);
            base.Response.ContentType = this.message.ContentType;
            if ((this.message.ContentEncoding != null) && (this.message.ContentEncoding.Length > 0))
            {
                base.Response.AppendHeader("Content-Encoding", this.message.ContentEncoding);
            }
            XmlWriter writerForMessage = this.GetWriterForMessage(this.message, 0x200);

            if (writerForMessage == null)
            {
                throw new InvalidOperationException(System.Web.Services.Res.GetString("WebNullWriterForMessage"));
            }
            this.helper.WriteFault(writerForMessage, this.message.Exception, statusCode);
            if (!flag)
            {
                SoapException exception4 = null;
                try
                {
                    this.message.SetStage(SoapMessageStage.AfterSerialize);
                    this.message.RunExtensions(this.message.allExtensions, false);
                }
                catch (Exception exception5)
                {
                    if (((exception5 is ThreadAbortException) || (exception5 is StackOverflowException)) || (exception5 is OutOfMemoryException))
                    {
                        throw;
                    }
                    if (Tracing.On)
                    {
                        Tracing.ExceptionCatch(TraceEventType.Warning, this, "WriteException", exception5);
                    }
                    if (!extensionStream.HasWritten)
                    {
                        exception4 = SoapException.Create(this.Version, System.Web.Services.Res.GetString("WebExtensionError"), new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/"), exception5);
                    }
                }
                if (exception4 != null)
                {
                    base.Response.ContentType = ContentType.Compose("text/plain", Encoding.UTF8);
                    StreamWriter writer2 = new StreamWriter(outputStream, new UTF8Encoding(false));
                    writer2.WriteLine(base.GenerateFaultString(this.message.Exception));
                    writer2.Flush();
                }
            }
            return(true);
        }
コード例 #42
0
		internal SoapMessage (Stream stream, SoapException exception)
		{
			this.exception = exception;
			this.stream = stream;
			headers = new SoapHeaderCollection ();
		}
コード例 #43
0
        private static Exception ConvertSoapException(SoapException e)
        {
            //log.Error("CSLG Exception", e);

            Match m = Regex.Match(e.Message, @"<Fault>(.+)</Fault>", RegexOptions.Singleline);

            if (m.Success)
            {
                string text = m.Groups[1].Value;
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(m.Value);
                    text = doc.InnerText;
                }
                catch (XmlException)
                {
                }
                return new Failure(text);
            }
            return e;
        }
コード例 #44
0
 internal abstract void WriteFault(XmlWriter writer, SoapException soapException, HttpStatusCode statusCode);
コード例 #45
0
        object[] DeserializeResponse(Stream responseBodyStream, HttpStatusCode statusCode, string contentType, SoapClientMessage message, SoapExtension[] extensions)
        {
            try {
                var msi = ReflectionHelper.GetFieldValue(message, "MethodStubInfo");

                //web exception
                if (!(statusCode == HttpStatusCode.Accepted || statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.InternalServerError))
                {
                    string msg = "The request failed with HTTP status {0}: {1}";
                    msg = String.Format(msg, (int)statusCode, statusCode);
                    throw new WebException(msg, null, WebExceptionStatus.ProtocolError, null);
                }

                //no response to process
                if (message.OneWay && responseBodyStream.Length <= 0 && (statusCode == HttpStatusCode.Accepted || statusCode == HttpStatusCode.OK))
                {
                    return(new object[0]);
                }


                string   ctype;
                Encoding encoding = GetContentEncoding(contentType, out ctype);
                ctype = ctype.ToLower(CultureInfo.InvariantCulture);

                if (ctype != "text/xml")
                {
                    ReflectionHelper.ExecuteStaticMethod(WebServiceHelperType, "InvalidOperation", null, String.Format("Not supported Content-Type in the response: '{0}'", ctype), null, encoding);
                }

                message.ContentType     = ctype;
                message.ContentEncoding = encoding.WebName;

                if (extensions != null)
                {
                    responseBodyStream = (Stream)ReflectionHelper.ExecuteStaticMethod(SoapExtensionType, "ExecuteChainStream", null, extensions, responseBodyStream);
                    ReflectionHelper.ExecuteMethod(message, "SetStage", null, SoapMessageStage.BeforeDeserialize);
                    ReflectionHelper.ExecuteStaticMethod(SoapExtensionType, "ExecuteProcessMessage", null, extensions, message, responseBodyStream, true);
                }

                // Deserialize the response
                SoapHeaderCollection headers = null;
                object content = null;

                var isSoap12Bool          = ReflectionHelper.GetPropertyValue(message, "IsSoap12");
                var methodStubInfo        = ReflectionHelper.GetFieldValue(message, "MethodStubInfo");
                var methodStubInfoHeaders = ReflectionHelper.GetFieldValue(methodStubInfo, "Headers");


                using (StreamReader reader = new StreamReader(responseBodyStream, encoding, false)) {
                    using (XmlTextReader xml_reader = new XmlTextReader(reader)) {
//						Type[] methodTypes = new Type[] {
//							typeof(XmlTextReader),
//							MethodStubInfoType,
//							typeof(SoapHeaderDirection),
//							typeof(bool),
//							typeof(object),
//							typeof(SoapHeaderCollection)
//						};

                        ReadSoapMessage(xml_reader, msi, SoapHeaderDirection.Out, (bool)isSoap12Bool, out content, out headers);
                        //(XmlTextWriter)ReflectionHelper.ExecuteStaticMethod (webServiceHelperType, "ReadSoapMessage", methodTypes, xml_reader, msi, SoapHeaderDirection.Out, isSoap12Bool, content, headers);
                    }
                }

                if (content.GetType() == FaultType)
                {
                    object        fault       = content;
                    object        faultstring = ReflectionHelper.GetFieldValue(fault, "faultstring");
                    object        faultcode   = ReflectionHelper.GetFieldValue(fault, "faultcode");
                    object        faultactor  = ReflectionHelper.GetFieldValue(fault, "faultactor");
                    object        faultdetail = ReflectionHelper.GetFieldValue(fault, "detail");
                    SoapException ex          = new SoapException((string)faultstring, (XmlQualifiedName)faultcode, (string)faultactor, (XmlNode)faultdetail);
                    ReflectionHelper.ExecuteMethod(message, "SetException", ex);
                }
                else
                {
                    ReflectionHelper.SetPropertyValue(message, "OutParameters", (object[])content);
                }

                ReflectionHelper.ExecuteMethod(message, "SetHeaders", null, headers);
                ReflectionHelper.ExecuteMethod(message, "UpdateHeaderValues", null, this, methodStubInfoHeaders);


                if (extensions != null)
                {
                    ReflectionHelper.ExecuteMethod(message, "SetStage", SoapMessageStage.AfterDeserialize);
                    ReflectionHelper.ExecuteStaticMethod(SoapExtensionType, "ExecuteProcessMessage", null, extensions, message, responseBodyStream, true);
                }


                if (message.Exception == null)
                {
                    var outParameters = ReflectionHelper.GetPropertyValue(message, "OutParameters");
                    return((object[])outParameters);
                }
                else
                {
                    Console.WriteLine(message.Exception.Message);
                    throw message.Exception;
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                throw ex;
            } finally {
            }
        }
コード例 #46
0
 internal void SetException(SoapException exception)
 {
     this.exception = exception;
 }
コード例 #47
0
        //
        // TODO:
        //    Handle other web responses (multi-output?)
        //
        object [] ReceiveResponse(WebResponse response, SoapClientMessage message, SoapExtension[] extensions)
        {
            SoapMethodStubInfo msi           = message.MethodStubInfo;
            HttpWebResponse    http_response = response as HttpWebResponse;

            if (http_response != null)
            {
                HttpStatusCode code = http_response.StatusCode;

                if (!(code == HttpStatusCode.Accepted || code == HttpStatusCode.OK || code == HttpStatusCode.InternalServerError))
                {
                    string msg = "The request failed with HTTP status {0}: {1}";
                    msg = String.Format(msg, (int)code, code);
                    throw new WebException(msg, null, WebExceptionStatus.ProtocolError, http_response);
                }
                if (message.OneWay && response.ContentLength <= 0 && (code == HttpStatusCode.Accepted || code == HttpStatusCode.OK))
                {
                    return(new object[0]);
                }
            }

            //
            // Remove optional encoding
            //
            string   ctype;
            Encoding encoding = WebServiceHelper.GetContentEncoding(response.ContentType, out ctype);

            ctype = ctype.ToLower(CultureInfo.InvariantCulture);
            if ((!message.IsSoap12 || ctype != "application/soap+xml") && ctype != "text/xml")
            {
                WebServiceHelper.InvalidOperation(
                    String.Format("Not supported Content-Type in the response: '{0}'", response.ContentType),
                    response, encoding);
            }

            message.ContentType     = ctype;
            message.ContentEncoding = encoding.WebName;

            Stream stream = response.GetResponseStream();

            if (extensions != null)
            {
                stream = SoapExtension.ExecuteChainStream(extensions, stream);
                message.SetStage(SoapMessageStage.BeforeDeserialize);
                SoapExtension.ExecuteProcessMessage(extensions, message, stream, false);
            }

            // Deserialize the response

            SoapHeaderCollection headers;
            object content;

            using (StreamReader reader = new StreamReader(stream, encoding, false)) {
                XmlTextReader xml_reader = new XmlTextReader(reader);

                WebServiceHelper.ReadSoapMessage(xml_reader, msi, SoapHeaderDirection.Out, message.IsSoap12, out content, out headers);
            }

            if (content is Soap12Fault)
            {
                SoapException ex = WebServiceHelper.Soap12FaultToSoapException((Soap12Fault)content);
                message.SetException(ex);
            }
            else
            if (content is Fault)
            {
                Fault         fault = (Fault)content;
                SoapException ex    = new SoapException(fault.faultstring, fault.faultcode, fault.faultactor, fault.detail);
                message.SetException(ex);
            }
            else
            {
                message.OutParameters = (object[])content;
            }

            message.SetHeaders(headers);
            message.UpdateHeaderValues(this, message.MethodStubInfo.Headers);

            if (extensions != null)
            {
                message.SetStage(SoapMessageStage.AfterDeserialize);
                SoapExtension.ExecuteProcessMessage(extensions, message, stream, false);
            }

            if (message.Exception == null)
            {
                return(message.OutParameters);
            }
            else
            {
                throw message.Exception;
            }
        }
コード例 #48
0
 internal abstract void SetResponseErrorCode(HttpResponse response, SoapException soapException);
コード例 #49
0
		internal void SetException (SoapException ex)
		{
			exception = ex;
		}
コード例 #50
0
        internal override bool Initialize()
        {
            this.GuessVersion();
            this.message             = new SoapServerMessage(this);
            this.onewayInitException = null;
            this.serverType          = (SoapServerType)base.GetFromCache(typeof(SoapServerProtocol), base.Type);
            if (this.serverType == null)
            {
                lock (ServerProtocol.InternalSyncObject)
                {
                    this.serverType = (SoapServerType)base.GetFromCache(typeof(SoapServerProtocol), base.Type);
                    if (this.serverType == null)
                    {
                        this.serverType = new SoapServerType(base.Type, this.protocolsSupported);
                        base.AddToCache(typeof(SoapServerProtocol), base.Type, this.serverType);
                    }
                }
            }
            Exception innerException = null;

            try
            {
                this.message.highPriConfigExtensions = SoapMessage.InitializeExtensions(this.serverType.HighPriExtensions, this.serverType.HighPriExtensionInitializers);
                this.message.highPriConfigExtensions = this.ModifyInitializedExtensions(PriorityGroup.High, this.message.highPriConfigExtensions);
                this.message.SetStream(base.Request.InputStream);
                this.message.InitExtensionStreamChain(this.message.highPriConfigExtensions);
                this.message.SetStage(SoapMessageStage.BeforeDeserialize);
                this.message.ContentType     = base.Request.ContentType;
                this.message.ContentEncoding = base.Request.Headers["Content-Encoding"];
                this.message.RunExtensions(this.message.highPriConfigExtensions, false);
                innerException = this.message.Exception;
            }
            catch (Exception exception2)
            {
                if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException))
                {
                    throw;
                }
                if (Tracing.On)
                {
                    Tracing.ExceptionCatch(TraceEventType.Warning, this, "Initialize", exception2);
                }
                innerException = exception2;
            }
            this.message.allExtensions = this.message.highPriConfigExtensions;
            this.GuessVersion();
            try
            {
                this.serverMethod = this.RouteRequest(this.message);
                if (this.serverMethod == null)
                {
                    throw new SoapException(System.Web.Services.Res.GetString("UnableToHandleRequest0"), new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/"));
                }
            }
            catch (Exception exception3)
            {
                if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException))
                {
                    throw;
                }
                if (this.helper.RequestNamespace != null)
                {
                    this.SetHelper(SoapServerProtocolHelper.GetHelper(this, this.helper.RequestNamespace));
                }
                this.CheckHelperVersion();
                throw;
            }
            this.isOneWay = this.serverMethod.oneWay;
            if (innerException == null)
            {
                try
                {
                    SoapReflectedExtension[] reflectedExtensions = (SoapReflectedExtension[])CombineExtensionsHelper(this.serverMethod.extensions, this.serverType.LowPriExtensions, typeof(SoapReflectedExtension));
                    object[] extensionInitializers = (object[])CombineExtensionsHelper(this.serverMethod.extensionInitializers, this.serverType.LowPriExtensionInitializers, typeof(object));
                    this.message.otherExtensions = SoapMessage.InitializeExtensions(reflectedExtensions, extensionInitializers);
                    this.message.otherExtensions = this.ModifyInitializedExtensions(PriorityGroup.Low, this.message.otherExtensions);
                    this.message.allExtensions   = (SoapExtension[])CombineExtensionsHelper(this.message.highPriConfigExtensions, this.message.otherExtensions, typeof(SoapExtension));
                }
                catch (Exception exception4)
                {
                    if (((exception4 is ThreadAbortException) || (exception4 is StackOverflowException)) || (exception4 is OutOfMemoryException))
                    {
                        throw;
                    }
                    if (Tracing.On)
                    {
                        Tracing.ExceptionCatch(TraceEventType.Warning, this, "Initialize", exception4);
                    }
                    innerException = exception4;
                }
            }
            if (innerException != null)
            {
                if (!this.isOneWay)
                {
                    if (innerException is SoapException)
                    {
                        throw innerException;
                    }
                    throw SoapException.Create(this.Version, System.Web.Services.Res.GetString("WebConfigExtensionError"), new XmlQualifiedName("Server", "http://schemas.xmlsoap.org/soap/envelope/"), innerException);
                }
                this.onewayInitException = innerException;
            }
            return(true);
        }
コード例 #51
0
ファイル: Utility.cs プロジェクト: Novthirteen/sih-les
 public static void ShowMessageBox(SoapException ex)
 {
     string message = FormatExMessage(ex.Message);
     ShowMessageBox(message);
 }
コード例 #52
0
 internal void SetException(SoapException ex)
 {
     exception = ex;
 }
コード例 #53
0
 public static void ProcessSoapException(SoapException ex)
 {
     Regex errorReg = new Regex(@"<Error>([^<]+)<ErrorCode>([^<]+)</ErrorCode></Error>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
     Match errorMatch = errorReg.Match(ex.Message);
     if (errorMatch.Success)
     {
         MessageBox.Show("Error (" +
             errorMatch.Groups[2].Value + "): " +
             errorMatch.Groups[1].Value);
     }
     else
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #54
0
 internal SoapMessage(Stream stream, SoapException exception)
 {
     this.exception = exception;
     this.stream    = stream;
     headers        = new SoapHeaderCollection();
 }
コード例 #55
0
ファイル: ExcepcionesSOAP.cs プロジェクト: pjeconde/eFact
        public static SoapException RaiseException(string uri, string webServiceNamespace,

                                        string errorMessage,

                                        string errorNumber,

                                        string errorSource,

                                        FaultCode code)
        {

            XmlQualifiedName faultCodeLocation = null;

            //Identify the location of the FaultCode

            switch (code)
            {

                case FaultCode.Client:

                    faultCodeLocation = SoapException.ClientFaultCode;

                    break;

                case FaultCode.Server:

                    faultCodeLocation = SoapException.ServerFaultCode;

                    break;

            }

            XmlDocument xmlDoc = new XmlDocument();

            //Create the Detail node

            XmlNode rootNode = xmlDoc.CreateNode(XmlNodeType.Element,

                                          SoapException.DetailElementName.Name,

                                          SoapException.DetailElementName.Namespace);

            //Build specific details for the SoapException

            //Add first child of detail XML element.

            XmlNode errorNode = xmlDoc.CreateNode(XmlNodeType.Element, "Error",

                                                  webServiceNamespace);

            //Create and set the value for the ErrorNumber node

            XmlNode errorNumberNode =

              xmlDoc.CreateNode(XmlNodeType.Element, "ErrorNumber",

                                webServiceNamespace);

            errorNumberNode.InnerText = errorNumber;

            //Create and set the value for the ErrorMessage node

            XmlNode errorMessageNode = xmlDoc.CreateNode(XmlNodeType.Element,

                                                        "ErrorMessage",

                                                        webServiceNamespace);

            errorMessageNode.InnerText = errorMessage;

            //Create and set the value for the ErrorSource node

            XmlNode errorSourceNode =

              xmlDoc.CreateNode(XmlNodeType.Element, "ErrorSource",

                                webServiceNamespace);

            errorSourceNode.InnerText = errorSource;

            //Append the Error child element nodes to the root detail node.

            errorNode.AppendChild(errorNumberNode);

            errorNode.AppendChild(errorMessageNode);

            errorNode.AppendChild(errorSourceNode);

            //Append the Detail node to the root node

            rootNode.AppendChild(errorNode);

            //Construct the exception

            SoapException soapEx = new SoapException(errorMessage,

                                                     faultCodeLocation, uri,

                                                     rootNode);

            //Raise the exception  back to the caller

            return soapEx;

        }
コード例 #56
0
 internal abstract void WriteFault(XmlWriter writer, SoapException soapException);