Interface of managed Windows Service published as WebService ?

J

Josef Fa

Hi all,

I have a WebService - WindowsService architectural question.
Given a managed windows service, written in C#, and running independently
of IIS as a windows service. I want to publish an open interface as a web
service. The methods of the open interface have a lot parameters / return
values of complex data types.

What is the simples solution to do this ?

One possible ( but propably not the easiest) solution is to implement an
ASP.NET webservice. This webservice calls over .NET remoting the managed
windows service object (singleton) over a companion remoted interface, like
this:

ASP.NET Project foo.asmx.cs :

[WebService]
public class MyService : System.Web.Services.WebService
{
static public IMyRemotingService server = Activator.GetObject(...);

[WebMethod]
public ComplexData1 Foo([XmlAttribute] ComplexData2[] p1, out
ComplexData3 p2)
{
RemoteComplexData1 result;
RemoteComplexData2[] rp1 = Convert.ToRemote(p1);
RemoteComplexData3 rp2;

result = server.Foo(rp1, out rp2);

p2 = Convert.FromRemote(rp2);
return Convert.From(result);
}
...
}

public class ComplexData1
{
....
}
....


Windows Service Project server.cs:

public interface IMyRemotingService
{
RemoteComplexData1 Foo(RemoteComplexData2 p1, out RemoteComplexData3
p2);
}

[Serializable]
public class RemoteComplexData1
{
....
}

public class MyRemotingService : MarshalByObjRef, IMyRemotingService
{
public RemoteComplexData1 Foo(RemoteComplexData2 p1, out
RemoteComplexData3 p2)
{
...
}
}


Is there a better solution without defining the whole interface and the
parameter classes twice (webservice and serializable) and write a wrapper ?

Is there a direct way to publish an interface running in an independent
windows service as a real webservice (as recommended under IIS/ASP.NET)?

thanks for any suggestion,
Josef
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top