WCF服務能否返回其他服務?返回其他服務的WCF服務
代碼:
[ServiceContract]
public interface IServiceA
{
[OperationContract]
IServiceB GetServiceB();
[ServiceContract]
public interface IServiceB
{
public class ServiceA : IServiceA
{
public IServiceB GetServiceB()
{
return new ServiceB();
}
,這是激活ServiceA形式調用ServiceB:鑄造這樣當
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
ServiceReference1.ServiceAClient client = new
ServiceReference1.ServiceAClient();
IServiceB serviceB = client.GetServiceB();
Ofcourse這不能因爲GetServiceB進行()返回對象,而不是服務:
IServiceB serviceB = (ServiceB) client.GetServiceB();
我得到CommunicationException:「現有連接w由遠程主機強行關閉「
YPU爲什麼要這麼做呢?只需從客戶端調用ServiceB! – Jocke 2013-02-28 15:28:07
我只想要1個端點。ServiceA將向我展示許多對象,我不想要許多端點 – ilansch 2013-02-28 15:28:54
您正在尋找的是發現服務體系結構 – Dhawalk 2013-02-28 15:44:12