本文整理汇总了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);
}
开发者ID:.NET开发者,项目名称:System.Web.Services.Protocols,代码行数:70,代码来源:SoapClientMessage
注:本文中的System.Web.Services.Protocols.SoapClientMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论