elCapitano
elCapitano

Reputation: 121

SOAP with events in c#?

can i implement a SOAP Service which can deal with delegates/events?? Can i also use Streams with SOAP? How does it look like in C#?

thanks, el

Upvotes: 1

Views: 754

Answers (1)

Manitra Andriamitondra
Manitra Andriamitondra

Reputation: 1249

The SOAP protocol is based on top of HTTP so cannot act as a 'PUSH' service without doing heavy tricks => you cannot easily create an event-based webservice in ASP.NET.

You cannot use Streams neither but you can transmit binary content using byte[] parameters or return types. This is how it looks like in C# :

///Server side
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service1 : System.Web.Services.WebService
{

    [WebMethod]
    public byte[] GetFile(string fullName)
    {
        return File.ReadAllBytes(fullName);
    }
}

///Client Side
private void button1_Click(object sender, EventArgs e)
{
    Service1 client = new Service1();
    pictureBox1.Image = Image.FromStream(
        new MemoryStream(
            client.GetFile("c:\\apple.jpg")));
}

That's it.

Upvotes: 2

Related Questions