IClientService returns zero objects, even when fiddler2 tells me the respons contains the expected objects
-
I have a weird problem on my hands, we are using IClientService / ChanneFactory to communicate with the WCF service, the method looks like this
public List<IOrder> GetOrders(string userId, string password)
{
List<IOrder> orders = null;
try
{
IClientService wcfClient1 = _clientService.CreateChannel();
orders = wcfClient1.GetOrders(userId, password);
((IClientChannel)wcfClient1).Close();
ServerConnection = true;
}
catch (Exception ex)
{
ServerConnection = false;
SendError("GetOrders() " + ex);
}
return orders;
}and Fiddler2 Web debugger tells me that the request looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetOrders xmlns="http://tempuri.org/">
<userId>DemoUser</userId>
<password>DemoPass</password>
</GetOrders>
</s:Body>
</s:Envelope>and the response like this:
Di,Fe,Fr,Hi,Hy,Næ,Næ3,NæS,Op,Pr,RE,Sl,TG,VP 20 Restavfall 20 2011-07-20T00:00:00 101610 0 10 10 - Orkanger Test
so the response clearly contains the expected object, the problem is that, in the client side method GetOrders, after the line "orders = wcfClient1.GetOrders(userId, password)", the list "orders" becomes a list of 0 objects and not, as expected, a list with the one object returned by the service. anyone that have any idea of whats going on?
-
I have a weird problem on my hands, we are using IClientService / ChanneFactory to communicate with the WCF service, the method looks like this
public List<IOrder> GetOrders(string userId, string password)
{
List<IOrder> orders = null;
try
{
IClientService wcfClient1 = _clientService.CreateChannel();
orders = wcfClient1.GetOrders(userId, password);
((IClientChannel)wcfClient1).Close();
ServerConnection = true;
}
catch (Exception ex)
{
ServerConnection = false;
SendError("GetOrders() " + ex);
}
return orders;
}and Fiddler2 Web debugger tells me that the request looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetOrders xmlns="http://tempuri.org/">
<userId>DemoUser</userId>
<password>DemoPass</password>
</GetOrders>
</s:Body>
</s:Envelope>and the response like this:
Di,Fe,Fr,Hi,Hy,Næ,Næ3,NæS,Op,Pr,RE,Sl,TG,VP 20 Restavfall 20 2011-07-20T00:00:00 101610 0 10 10 - Orkanger Test
so the response clearly contains the expected object, the problem is that, in the client side method GetOrders, after the line "orders = wcfClient1.GetOrders(userId, password)", the list "orders" becomes a list of 0 objects and not, as expected, a list with the one object returned by the service. anyone that have any idea of whats going on?
Just curious....since you already have a proxy class, what does using that class return? e.g. _clientService.GetOrders(userId, password);
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Just curious....since you already have a proxy class, what does using that class return? e.g. _clientService.GetOrders(userId, password);
Mark Salsbery Microsoft MVP - Visual C++ :java:
_clientService is defined as
private ChannelFactory<IClientService> _clientService;
so it doesn't have a accessable GetOrders method. the _clientService is constructed like this:
BasicHttpBinding clientBinding = new BasicHttpBinding {MaxReceivedMessageSize = int.MaxValue};
EndpointAddress clientEndpoint = new EndpointAddress(serviceUrl);
_clientService = new ChannelFactory<IClientService>(clientBinding, clientEndpoint); -
_clientService is defined as
private ChannelFactory<IClientService> _clientService;
so it doesn't have a accessable GetOrders method. the _clientService is constructed like this:
BasicHttpBinding clientBinding = new BasicHttpBinding {MaxReceivedMessageSize = int.MaxValue};
EndpointAddress clientEndpoint = new EndpointAddress(serviceUrl);
_clientService = new ChannelFactory<IClientService>(clientBinding, clientEndpoint);Does the endpoint configuration match on both ends?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I have a weird problem on my hands, we are using IClientService / ChanneFactory to communicate with the WCF service, the method looks like this
public List<IOrder> GetOrders(string userId, string password)
{
List<IOrder> orders = null;
try
{
IClientService wcfClient1 = _clientService.CreateChannel();
orders = wcfClient1.GetOrders(userId, password);
((IClientChannel)wcfClient1).Close();
ServerConnection = true;
}
catch (Exception ex)
{
ServerConnection = false;
SendError("GetOrders() " + ex);
}
return orders;
}and Fiddler2 Web debugger tells me that the request looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetOrders xmlns="http://tempuri.org/">
<userId>DemoUser</userId>
<password>DemoPass</password>
</GetOrders>
</s:Body>
</s:Envelope>and the response like this:
Di,Fe,Fr,Hi,Hy,Næ,Næ3,NæS,Op,Pr,RE,Sl,TG,VP 20 Restavfall 20 2011-07-20T00:00:00 101610 0 10 10 - Orkanger Test
so the response clearly contains the expected object, the problem is that, in the client side method GetOrders, after the line "orders = wcfClient1.GetOrders(userId, password)", the list "orders" becomes a list of 0 objects and not, as expected, a list with the one object returned by the service. anyone that have any idea of whats going on?
Ahm - aren't WCF calls asynchronous therefore this would not return a value.
wcfClient1.GetOrders(userId, password)
You need to set up a callback. This is a typical call
public void GetRecord(int iID)//---------------------------------------Get record { svcClient.PERIODGetRecordCompleted += new System.EventHandler(GetRecordCompleted); svcClient.PERIODGetRecordAsync(iID); }
private void GetRecordCompleted(object sender, PERIODGetRecordCompletedEventArgs e)//the call back that receives the data
Never underestimate the power of human stupidity RAH
-
Ahm - aren't WCF calls asynchronous therefore this would not return a value.
wcfClient1.GetOrders(userId, password)
You need to set up a callback. This is a typical call
public void GetRecord(int iID)//---------------------------------------Get record { svcClient.PERIODGetRecordCompleted += new System.EventHandler(GetRecordCompleted); svcClient.PERIODGetRecordAsync(iID); }
private void GetRecordCompleted(object sender, PERIODGetRecordCompletedEventArgs e)//the call back that receives the data
Never underestimate the power of human stupidity RAH
-
the WCF calls must be asynchronous in silverlight, not so in WPF where they can be both synch or asynch, anyhow have resolved the issue, it was a case of service missing the assembly with the interface definitions.
annathor wrote:
not so in WPF
Ahhh I'm only using Silverlight and therefore the skewed view on things. I thought it was too dammed obvious, I'm just glad I didn't go all sarcastic on you :) .
Never underestimate the power of human stupidity RAH