开发者

SOAP with events in c#?

can i implement a SOAP Service 开发者_如何学Gowhich can deal with delegates/events?? Can i also use Streams with SOAP? How does it look like in C#?

thanks, el


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜