TransEventService.asmx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Soap;

namespace EventWebService
{
/// zzsummary>
/// Summary description for TransEventService.
/// zz/summary>
[WebService(Namespace="http://cocreate.com/EventWebService/")]
public class TransEventService : EventService
{

public TransEventService()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}

/// zzsummary>
/// Get the event, serialize it to a file in the TEMP directory of the current user
/// zz/summary>
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://cocreate.com/EventWebService/HandleEvents", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
public override void HandleEvents([System.Xml.Serialization.XmlElementAttribute(Namespace="http://cocreate.com/EventWebService/")] TransactionEvent transactionEvent)
{
String tempPath = Environment.GetEnvironmentVariable("TEMP");
IFormatter formatter = new SoapFormatter();
try
{
Stream stream = new FileStream(tempPath + "\\TransactionEvent.soap", FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, transactionEvent);
stream.Close();
}
catch (Exception e)
{
Console.Out.WriteLine("Exception in serialization." + e);
}

}

/// zzsummary>
/// Deserialize the file in the TEMP directory of the current user
/// zz/summary>
[WebMethod]
public TransactionEvent getTransactionEvent()
{
String tempPath = Environment.GetEnvironmentVariable("TEMP");
TransactionEvent te = null;
IFormatter formatter = new SoapFormatter();
try
{
Stream stream = new FileStream(tempPath + "\\TransactionEvent.soap", FileMode.Open, FileAccess.Read, FileShare.Read);
te = (TransactionEvent) formatter.Deserialize(stream);
stream.Close();
}
catch (Exception e)
{
Console.Out.WriteLine("Exception in deserialization." + e);
}

return te;

}


#region Component Designer generated code

//Required by the Web Services Designer
private IContainer components = null;

/// zzsummary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// zz/summary>
private void InitializeComponent()
{

}

/// zzsummary>
/// Clean up any resources being used.
/// zz/summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion


}
}

Was this helpful?