WCF Service exporting 1 Interface with 2 Implementation classes
I'm new to WCF and C#.
I'm trying to create a WCF Service with 1 Interface (IA) with 1 method
(Do) which has 2 implementations (A1 & A2).
A silly example:
IA.cs:
namespace IA_NS
{
[ServiceContract]
public interface IA
{
[OperationContract]
int Do(B b);
}
[DataContract]
public class B
{
[DataMember]
public string b1 { get; set; }
}
}
A1.cs:
namespace A1_NS
{
public class A1 : A
{
public int Do(B b) {...}
}
}
A2.cs:
namespace A2_NS
{
public class A2 : A
{
public int Do(B b) {...}
}
}
I want my WCF Client to be able to call both classes:
Client.cs:
namespace Client_NS
{
class Program
{
static void Main(string[] args)
{
...
B myB;
if (...)
A1.Do(myB);
else
A2.Do(myB);
}
}
}
No luck ;-(
I tried putting 2 elements in my WCF-Service app.config:
<service name="A1_NS.A1" >
<endpoint address="http://localhost/A1"
contract="IA_NS.IA" />
</service>
<service name="A2_NS.A2" >
<endpoint address="http://localhost/A2"
contract="IA_NS.IA" />
contract="IA_NS.IA" />
</service>
When running the debugger - the debugging app (WCF Service Host) lets me
test the Do() method of both classes.
I can't get my Client to do it. I added Service References for both
services. Is it the Client app.config or am I misunderstanding something?
No comments:
Post a Comment