protected void EnsureStage(SoapMessageStage stage) { if ((((int)stage) & ((int)Stage)) == 0) { throw new InvalidOperationException("The current SoapMessageStage is not the asserted stage or stages."); } }
/* * internal abstract SoapReflectedExtension[] Extensions { * get; * } * * internal abstract object[] ExtensionInitializers { * get; * } */ /// <include file='doc\SoapMessage.uex' path='docs/doc[@for="SoapMessage.EnsureStage"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void EnsureStage(SoapMessageStage stage) { if ((this.stage & stage) == 0) { throw new InvalidOperationException(Res.GetString(Res.WebCannotAccessValueStage, this.stage.ToString())); } }
protected void EnsureStage(SoapMessageStage stage) { if ((this.stage & stage) == ((SoapMessageStage)0)) { throw new InvalidOperationException(Res.GetString("WebCannotAccessValueStage", new object[] { this.stage.ToString() })); } }
protected void EnsureStage(SoapMessageStage stage) { if ((this.stage & stage) == ((SoapMessageStage) 0)) { throw new InvalidOperationException(Res.GetString("WebCannotAccessValueStage", new object[] { this.stage.ToString() })); } }
protected void EnsureStage(SoapMessageStage stage) { if ((this.stage & stage) != (SoapMessageStage)0) { return; } throw new InvalidOperationException(Res.GetString("WebCannotAccessValueStage", new object[1] { (object)((object)this.stage).ToString() })); }
/// <summary> /// When called with a message that contains an exception. Logs the exception. /// </summary> public override void ProcessMessage(SoapMessage Message) { Stage = Message.Stage; ServerMessage = typeof(SoapServerMessage).IsInstanceOfType(Message); if (!ServerMessage) { return; } switch (Stage) { case SoapMessageStage.AfterSerialize: if (!Logger.IsIgnoreable(Message.Exception)) { Log(Message.Exception); } if (CallLog == "") { Log(Message); } if (NewStream != null) { ProcessStream(Message.Exception); } else { Log(Message.Exception == null); } OldStream = null; NewStream = null; break; case SoapMessageStage.AfterDeserialize: if (LogSoapCalls) { Log(Message); } break; case SoapMessageStage.BeforeDeserialize: InputString = ReadStream(Message.Stream); // PT.Ch1 - Modified by COGNIANT - 6/24/09 - Added Mask.Replace to mask the CCNumber field (Credit Card number) if input XML is written to SOAP log files if (LogSoapInput) { Log(Mask.Replace(InputString, "$1****")); } break; default: break; } }
protected void EnsureStage (SoapMessageStage stage) { if ((((int) stage) & ((int) Stage)) == 0) throw new InvalidOperationException ("The current SoapMessageStage is not the asserted stage or stages."); }
internal void SetStage (SoapMessageStage stage) { this.stage = stage; }
//This method is a standin for the real method so that the example will compile private static void EnsureStage(SoapMessageStage sms) { }
internal void SetStage(SoapMessageStage stage) { this.stage = stage; }
/// <summary> /// this will be called four times (before/after serialize/deserialize) for each [WebMethod] /// </summary> /// <param name="message">Message being processed</param> public override void ProcessMessage(SoapMessage message) { Argument.Assert.IsNotNull(message, "message"); if (context.ClassContext) { return; } // this extension only cares about the BeforeSerialize stage where it Trace.WriteLine("process message"); // performs schema/assertion validation SoapMessageStage checkStage = context.CurrentEndpoint == Endpoint.Server ? SoapMessageStage.BeforeDeserialize : SoapMessageStage.AfterSerialize; if (checkStage == message.Stage && context != null) { Trace.WriteLine("Stage check"); Stream useStream = message.Stream; if (context.CurrentEndpoint == Endpoint.Client) { useStream = Filter; } long streamPosition = useStream.Position; try { useStream.Position = 0L; // create an XPathNavigator on the request stream XmlReader reader; // check to see if the user wants schema validation if (context.ValidationAttribute != null && context.ValidationAttribute.SchemaValidation) { // this message should be schema validated so // configure XmlValidatingReader // add specified schemas, including the ones from the WSDL file XmlReaderSettings settings = new XmlReaderSettings(); // add the schemas specified by settings.ValidationType = ValidationType.Schema; settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema; settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings; settings.Schemas.Add(context.SchemaCollection); XmlReader xmlValidatingReader = XmlReader.Create(useStream, settings); if (context.ValidationAttribute.CheckAssertions == false) { try { // read through the stream, // if something in it does not // comply with the schemas it // will through an exception //AssertNamespaceBindingAttribute while (xmlValidatingReader.Read()) { } // read through stream } catch (Exception) { ThrowSchemaError(); } } reader = xmlValidatingReader; } else { // if we get to here then no schema validation // was require, just make a reader that // can be used to evaluate xpath expressions reader = new XmlTextReader(useStream); } // evaluate the XPath assertions - if complete expression returns true // let the System.Web.Services infrastructure finish processing if (context.ValidationAttribute != null && context.ValidationAttribute.CheckAssertions) { Trace.WriteLine("validate"); // turn the message stream into an XPathDocument XPathDocument doc = new XPathDocument(reader); // get an navigator from the docuement XPathNavigator nav = doc.CreateNavigator(); if (context.ValidationAttribute.SchemaValidation) { Trace.WriteLine("Schema Check"); } if (context.CompleteRuleExpression != null && false == (bool)nav.Evaluate(context.CompleteRuleExpression)) { // otherwise generate a SOAP fault indicating exactly which // assertions failed // make a document to construct a detail element XmlDocument errorDoc = new XmlDocument(); // make a detail element XmlElement detailElement = errorDoc.CreateElement( SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); // make it the root of the document errorDoc.AppendChild(detailElement); // make an element that indicates that assertions failed XmlElement failedRulesElement = errorDoc.CreateElement("dm", "failedAssertions", ValidationNamespaces.DevInterop); // add the failure elememt to the detail detailElement.AppendChild(failedRulesElement); // generate namespace declarations required by assert expressions foreach (string prefix in context.NamespaceManager) { if (prefix.Equals("xml") || prefix.Equals("xmlns") || prefix.Length == 0) { continue; } XmlAttribute nsDeclAttribute = errorDoc.CreateAttribute("xmlns", prefix, ValidationNamespaces.XmlNamespace); nsDeclAttribute.Value = context.NamespaceManager.LookupNamespace(prefix); failedRulesElement.Attributes.Append(nsDeclAttribute); } // check to see which assertions failed and list in failedRules foreach (AssertAttribute assertAttribute in context.AssertAttributes) { // check the current assertion if (false == (bool)nav.Evaluate(assertAttribute.Expression)) { // it faild, make an element that indicates this XmlElement assertElement = errorDoc.CreateElement("dm", "assert", ValidationNamespaces.DevInterop); failedRulesElement.AppendChild(assertElement); // make an element that will hold the xpath expression that failed XmlElement expElement = errorDoc.CreateElement("dm", "expression", ValidationNamespaces.DevInterop); assertElement.AppendChild(expElement); expElement.InnerText = assertAttribute.Rule; // make an element that holds the error expression // associated with the xpath expression business rule XmlElement descElement = errorDoc.CreateElement("dm", "description", ValidationNamespaces.DevInterop); assertElement.AppendChild(descElement); descElement.InnerText = assertAttribute.Description; } } reader.Close(); // make an actor string to indicate // where error was detected string actor = context.CurrentEndpoint == Endpoint.Server ? HttpContext.Current.Request.Url.AbsoluteUri : "urn:ClientSide"; // throw soap excetion that describes error // this will be returned as soap error message throw new SoapException( "Business rules failed validation", SoapException.ClientFaultCode, actor, detailElement); } // message was validated and produced no assertion if (context.CurrentEndpoint == Endpoint.Client) { // if we got this and this is the client then // push the filer to the server Filter.Position = 0L; byte[] buffer = new byte[1024]; int read; while ((read = Filter.Read(buffer, 0, buffer.Length)) > 0) { Request.Write(buffer, 0, read); } Request.Close(); } } } catch (SoapException) { // if you get to here you are catching // the SoapException thrown by the assertion // check, so just rethrow it. throw; } catch (Exception) { // if you get to here then the // schema validator threw the exception, // turn it into a SoapException ThrowSchemaError(); } finally { // make sure you leave the stream the way you found it if (context.CurrentEndpoint != Endpoint.Client) { useStream.Position = streamPosition; } } } }
/* internal abstract SoapReflectedExtension[] Extensions { get; } internal abstract object[] ExtensionInitializers { get; } */ /// <include file='doc\SoapMessage.uex' path='docs/doc[@for="SoapMessage.EnsureStage"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected void EnsureStage(SoapMessageStage stage) { if ((this.stage & stage) == 0) throw new InvalidOperationException(Res.GetString(Res.WebCannotAccessValueStage, this.stage.ToString())); }
protected void EnsureStage(SoapMessageStage stage) { if ((this.stage & stage) != (SoapMessageStage) 0) return; throw new InvalidOperationException(Res.GetString("WebCannotAccessValueStage", new object[1] { (object) ((object) this.stage).ToString() })); }