Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.remoting
SoapSubs and Constructors
Cliff_Harker
7/21/2004 5:47:00 PM
I have read lots of messages about SoapSubs not creating Constructors
properly but wanted to know how I might hand craft that code when
Soapsubs has finished.
I have a dead noddy example RemoteObject
using System;
namespace Cliff.Samples
{
/// <summary>
/// Summary description for MyRemoteObject.
/// </summary>
public class MyBase : System.MarshalByRefObject
{
public MyBase()
{
Console.WriteLine( "Base con called" );
}
}
public class MyRemoteObject : MyBase
{
private int _a;
public int a
{
get { return _a; }
set { _a = value; }
}
public MyRemoteObject()
{
Console.WriteLine( "Constructor called" );
_a = 0;
}
public MyRemoteObject( int a )
{
Console.WriteLine( "2nd Constructor called" );
_a = a;
}
public string Hello()
{
Console.WriteLine("Hello called");
return "Hello";
}
public void WriteToDatabase()
{
Console.WriteLine( "database write " + _a.ToString() );
}
}
}
When I run SoapSubs I get
using System;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Metadata;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
namespace Cliff.Samples {
[SoapType(XmlNamespace=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples/MyRemoteObject%2C%20Version%3D1.0.1663.20057%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D...
,
XmlTypeNamespace=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples/MyRemoteObject%2C%20Version%3D1.0.1663.20057%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D...
)]
public class MyBase :
System.Runtime.Remoting.Services.RemotingClientProxy
{
// Constructor
public MyBase()
{
}
public Object RemotingReference
{
get{return(_tp);}
}
}
[SoapType(XmlNamespace=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples/MyRemoteObject%2C%20Version%3D1.0.1663.20057%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D...
,
XmlTypeNamespace=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples/MyRemoteObject%2C%20Version%3D1.0.1663.20057%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D...
)]
public class MyRemoteObject : MyBase
{
public Int32 a
{
[SoapMethod(SoapAction=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples.MyRemoteObject/MyRemoteObject#g...
)]
get{return ((MyRemoteObject) _tp).a;}
[SoapMethod(SoapAction=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples.MyRemoteObject/MyRemoteObject#s...
)]
set{((MyRemoteObject) _tp).a= value;}
}
[SoapMethod(SoapAction=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples.MyRemoteObject/MyRemoteObject#H...
)]
public String Hello()
{
return ((MyRemoteObject) _tp).Hello();
}
[SoapMethod(SoapAction=@"
http://schemas.microsoft.com/clr/nsassem/Cliff.Samples.MyRemoteObject/MyRemoteObject#WriteToData...
)]
public void WriteToDatabase()
{
((MyRemoteObject) _tp).WriteToDatabase();
}
}
}
Now my Client code
RemotingConfiguration.Configure("RemoteClient.exe.config");
MyRemoteObject obj = new MyRemoteObject(4);
Console.WriteLine( obj.Hello() );
obj.WriteToDatabase();
obj.a = 22;
obj.WriteToDatabase();
Console.ReadLine();
falls down because MyRemoteObject(4) fails because there is no
constructor that takes an int. In fact I can't see a "default"
constructor for MyRemoteObject either.
How do I get this too work. The remote objects are Client
Instantiated and are MarshalByRef so parameterised constructors are
allowed.
What gives? Any ideas?
thanks
Cliff
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
SoapSubs and Constructors
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password