コード例 #1
0
ファイル: TraceExtension.cs プロジェクト: louislatreille/xsp
	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();
	}
コード例 #2
0
// </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();
    }
コード例 #3
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();
    }
コード例 #4
0
        /// <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());
                        }
                    }
                }
            }
        }