public override void ProcessMessage(SoapMessage message)
        {
            if (GlimpseManager.IsGlimpseActive() == false)
            {
                return;
            }

            switch (message.Stage)
            {
            case SoapMessageStage.BeforeSerialize:
                _result.RequestArgs = GetRequestArgs(message);
                break;

            case SoapMessageStage.AfterSerialize:
                _result.RequestXml = GetXml(_newStream);

                CopyStream(_newStream, _oldStream);
                break;

            case SoapMessageStage.BeforeDeserialize:
                CopyStream(_oldStream, _newStream);
                _result.ResponseXml = GetXml(_newStream);
                break;

            case SoapMessageStage.AfterDeserialize:
                TimerResult dt = GlimpseManager.GetExecutionTimer().Stop(_timer);

                bool   hasError = (message.Exception != null);
                object retVal;
                if (hasError)
                {
                    retVal = message.Exception;
                }
                else if (message.MethodInfo.IsVoid)
                {
                    retVal = "The SOAP call is to a void method";
                }
                else
                {
                    retVal = message.GetReturnValue();
                }

                _result.Url            = message.Url;
                _result.Method         = message.MethodInfo.Name + (hasError ? " - ERROR" : "");
                _result.ResponseResult = retVal;
                _result.Duration       = dt.Duration.Milliseconds + "ms";
                _result.Stacktrace     = new StackTrace(4, true).ToString();
                GlimpseManager.LogMessage(_result);

                var timeline = new SoapTimelineMessage();
                timeline.EventName     = message.MethodInfo.Name + (hasError ? " - ERROR" : "");
                timeline.EventSubText  = message.Url + "\n" + retVal;
                timeline.Offset        = dt.Offset;
                timeline.Duration      = dt.Duration;
                timeline.StartTime     = dt.StartTime;
                timeline.EventCategory = SoapTimelineCategory;
                GlimpseManager.LogMessage(timeline);
                break;
            }
        }
Exemple #2
0
	public void WriteOutput(SoapMessage message)
	{
		FileStream fs = new FileStream(filename, FileMode.Append, FileAccess.Write);
		StreamWriter w = new StreamWriter(fs);

		if (message is SoapServerMessage)
		{
			w.WriteLine("METHOD RESPONSE at " + DateTime.Now);
			int opc = message.MethodInfo.OutParameters.Length;
			if (opc > 0) w.WriteLine ("  Out parameters:");
			for (int n=0; n<opc; n++)
				w.WriteLine ("     " + message.GetOutParameterValue (n));
			w.WriteLine ("  Return value: " + message.GetReturnValue ());
		}

		w.Flush();
		w.Close();
	}
// </Snippet1>

    // Write the contents of the incoming SOAP message to the log file.
    public void WriteInputAfterDeserialize(SoapMessage myMessage)
    {
        FileStream myFileStream =
            new FileStream(myFileName, FileMode.Append, FileAccess.Write);
        StreamWriter myStreamWriter = new StreamWriter(myFileStream);

        myStreamWriter.WriteLine();

        myStreamWriter.WriteLine("The values of the out parameter are:");
        myStreamWriter.WriteLine("The value of the out parameter is: {0}",
                                 myMessage.GetOutParameterValue(0));

        myStreamWriter.WriteLine("The values of the return parameter are:");
        myStreamWriter.WriteLine("The value of the return parameter is: {0}",
                                 myMessage.GetReturnValue());

        myStreamWriter.Flush();
        myStreamWriter.Close();
        myFileStream.Close();
    }
Exemple #4
0
    public void WriteOutput(SoapMessage message)
    {
        FileStream   fs = new FileStream(filename, FileMode.Append, FileAccess.Write);
        StreamWriter w  = new StreamWriter(fs);

        if (message is SoapServerMessage)
        {
            w.WriteLine("METHOD RESPONSE at " + DateTime.Now);
            int opc = message.MethodInfo.OutParameters.Length;
            if (opc > 0)
            {
                w.WriteLine("  Out parameters:");
            }
            for (int n = 0; n < opc; n++)
            {
                w.WriteLine("     " + message.GetOutParameterValue(n));
            }
            w.WriteLine("  Return value: " + message.GetReturnValue());
        }

        w.Flush();
        w.Close();
    }
        /// <summary>
        /// Sets the method's DimeAttachment parameters and return value to the stored values.
        /// </summary>
        private void AfterDeSerialize(SoapMessage message)
        {
            if (contentType == DimeContentType)
            {
                if (message.GetType() != typeof(SoapClientMessage))
                {
                    throw new Exception("DIME library not for server side processing");

                    /*
                     * // check for unreferenced attachments in the container
                     * IDimeAttachmentContainer container = ((SoapServerMessage)message).Server as IDimeAttachmentContainer;
                     * if (container != null)
                     * {
                     *      if (container.RequestAttachments == null)
                     *              throw new InvalidOperationException("The IDimeAttachmentContainer.RequestAttachments property must not be null.");
                     *      container.RequestAttachments.AddRange(inputAttachments.Values);
                     * }
                     * else
                     * {
                     *      // check for referenced attachments in the parameter list
                     *      ParameterInfo[] parameters = message.MethodInfo.InParameters;
                     *      for (int i = 0; i < parameters.Length; i++)
                     *      {
                     *              Type type = parameters[i].ParameterType;
                     *              if (type == typeof(DimeAttachment))
                     *              {
                     *                      // only the id is in the SOAP body so copy over other attachment fields into
                     *                      // the DimeAttachment object created during deserialization
                     *                      CopyFieldsFromInputAttachment((DimeAttachment)message.GetInParameterValue(i));
                     *              }
                     *              else if (type == typeof(DimeAttachment[]))
                     *              {
                     *                      CopyFieldsFromInputAttachment((DimeAttachment[])message.GetInParameterValue(i));
                     *              }
                     *      }
                     * }
                     */
                }
                else                 //client side
                {
                    // check for unreferenced attachments in the container
                    IDimeAttachmentContainer container = ((SoapClientMessage)message).Client as IDimeAttachmentContainer;
                    if (container != null)
                    {
                        if (container.ResponseAttachments == null)
                        {
                            throw new InvalidOperationException("The IDimeAttachmentContainer.ResponseAttachments property must not be null.");
                        }
                        container.ResponseAttachments.AddRange(inputAttachments.Values);
                    }
                    else
                    {
                        // check for referenced attachments in the out parameter list
                        ParameterInfo[] parameters = message.MethodInfo.OutParameters;
                        for (int i = 0; i < parameters.Length; i++)
                        {
                            // Note, using the as operator to test the type since out params have a unique type
                            object         outValue = message.GetOutParameterValue(i);
                            DimeAttachment a        = outValue as DimeAttachment;
                            if (a != null)
                            {
                                CopyFieldsFromInputAttachment(a);
                            }
                            else
                            {
                                DimeAttachment[] aa = outValue as DimeAttachment[];
                                if (aa != null)
                                {
                                    CopyFieldsFromInputAttachment(aa);
                                }
                            }
                        }
                        Type returnType = message.MethodInfo.ReturnType;
                        if (returnType == typeof(DimeAttachment))
                        {
                            CopyFieldsFromInputAttachment((DimeAttachment)message.GetReturnValue());
                        }
                        else if (returnType == typeof(DimeAttachment[]))
                        {
                            CopyFieldsFromInputAttachment((DimeAttachment[])message.GetReturnValue());
                        }
                    }
                }
            }
        }