本文整理匯總了C#中System.Web.Services.Protocols.SoapClientMessage類的典型用法代碼示例。如果您正苦於以下問題:C# SoapClientMessage類的具體用法?C# SoapClientMessage怎麽用?C# SoapClientMessage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SoapClientMessage類屬於System.Web.Services.Protocols命名空間,在下文中一共展示了SoapClientMessage類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ProcessMessage
// Process the SOAP message received and write to a log file.
public override void ProcessMessage(SoapMessage message)
{
switch (message.Stage)
{
case SoapMessageStage.BeforeSerialize:
break;
case SoapMessageStage.AfterSerialize:
WriteOutput((SoapClientMessage)message);
break;
case SoapMessageStage.BeforeDeserialize:
WriteInput((SoapClientMessage)message);
break;
case SoapMessageStage.AfterDeserialize:
break;
default:
throw new Exception("invalid stage");
}
}
// Write the contents of the outgoing SOAP message to the log file.
public void WriteOutput(SoapClientMessage message)
{
newStream.Position = 0;
FileStream myFileStream = new FileStream(filename, FileMode.Append,
FileAccess.Write);
StreamWriter myStreamWriter = new StreamWriter(myFileStream);
myStreamWriter.WriteLine(
"================================== Request at "
+ DateTime.Now);
// Print to the log file the request header field for SoapAction header.
myStreamWriter.WriteLine("The SoapAction Http request header field is: ");
myStreamWriter.WriteLine("\t" + message.Action);
// Print to the log file the type of the client that invoked
// the XML Web service method.
myStreamWriter.WriteLine("The type of the client is: ");
if((message.Client.GetType()).Equals(typeof(MathSvc)))
myStreamWriter.WriteLine("\tMathSvc");
// Print to the log file the method invoked by the client.
myStreamWriter.WriteLine(
"The method that has been invoked by the client is:");
myStreamWriter.WriteLine("\t" + message.MethodInfo.Name);
// Print to the log file if the method invoked is OneWay.
if(message.OneWay)
myStreamWriter.WriteLine(
"The client doesn't wait for the server to finish processing");
else
myStreamWriter.WriteLine(
"The client waits for the server to finish processing");
// Print to the log file the URL of the site that provides
// implementation of the method.
myStreamWriter.WriteLine(
"The URL of the XML Web service method that has been requested is: ");
myStreamWriter.WriteLine("\t" + message.Url);
myStreamWriter.WriteLine("The contents of the SOAP envelope are: ");
myStreamWriter.Flush();
// Copy the contents of one stream to another.
Copy(newStream, myFileStream);
myFileStream.Close();
newStream.Position = 0;
// Copy the contents of one stream to another.
Copy(newStream, oldStream);
}