473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

WCF-Service-via-IIS7 - Winform-Client-problem

I have a Winforms client with a service referance to a WCF service that have created and is being hosted on IIS7. There is nothing else in the Form, I just added code to Form_Load event to test. In the winforms client, if I call the defualt operation GetData(int) it returns correct value.. Calling my own I always get null.... (No exceptions)

Now, the WCF service is using Linq To SQL DataContext.. In the WCF Test Client my operations work as expected when they are invoked... (as well as the default operations).

Any help would be greatly appreciated!


Expand|Select|Wrap|Line Numbers
  1.         [OperationContract]
  2.  
  3.         Employee GetEmployee(string employeeID);
  4.  
  5.  
  6.  
  7. /////////////////// Sample from Service Code ////////////////
  8.        public Employee GetEmployee(string employeeID)
  9.         {
  10.             Employee emp = new Employee();
  11.  
  12.             using (DataClasses1DataContext dc = new DataClasses1DataContext())
  13.             {
  14.                 try
  15.                 {
  16.                     emp = dc.Employees.Where(e => e.EmployeeID == employeeID).First();
  17.                     dc.Dispose();
  18.                 }
  19.                 catch (Exception msg)
  20.                 {
  21.                     System.Diagnostics.Debug.Print(msg.Message);
  22.                     dc.Dispose();
  23.                 }
  24.             }
  25.             return emp;
  26.         }
  27.  
  28. ///////////////////////// Code in Winform /////////////////////
  29.  
  30.  
  31.         private void Form1_Load(object sender, EventArgs e)
  32.         {
  33.             ServiceReference1.Employee emp = new WindowsFormsApplication1.ServiceReference1.Employee();
  34.  
  35.             ServiceReference1.Service1Client client = new WindowsFormsApplication1.ServiceReference1.Service1Client();
  36.  
  37.             string str = client.GetData(1); // Returns "You Entered 1"
  38.             emp = client.GetEmployee("John Q Public"); // Returns NULL....
  39.  
  40.             client.Close();
  41.         }
  42.  
  43.  
Mar 1 '10 #1
1 2655
Christian Binder
218 Expert 100+
At line 25, where you return the emp-object, does the emp-object have a value or is it already null?
Maybe the disposal of the DataClasses1DataContext-object causes the emp to be null. (By the way: you don't have to call dc.Dispose(), it's done implicitely when using the using-statement.)

Did you specify the [DataContract] and [DataMember] attributes for Employee-class and it's members (properties)?

You could try returning a native type like string or int instead of complex Employee-type (e.g. the Employee's name or the Employee's age)
Mar 3 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: MuZZy | last post by:
Hi, I am starting a new Smart Client project and wanted to employ th enew WF techniques, Communication Foundation in particular, but i can't find a good book - seems like all are scheduled to go...
4
by: SteveW | last post by:
Now that vista and the 3.0 framework are gold, I'm a bit confused, so any clarification would be very helpful. The 3.0 framework is gold and is downloadable etc. What is not 'gold' and...
10
by: ochocki | last post by:
Hi, Reading about WCF I had this feeling that .net remoting has been left behind. There's a lot about webservices but nothing about remoting which suprises me as MS was encouraging to use it in...
8
by: José Joye | last post by:
Hello, Does anyone know a good book about WCF? Thanks, José
0
by: coderecoder | last post by:
Hi, I am using using WCF/WF in a project and wanted to implement a consistent Error Logging and Tracking across various modules. Based on my research I have come up with various options: 1)...
1
by: =?iso-8859-1?Q?Jos=E9_Joye?= | last post by:
I'm currenly playing with WCF framework and I'm looking for a way to configure WCF settings in a dedicated XML file. By default, all the admistrative settings are stored in the standard App.Config...
0
by: bramoin | last post by:
Hi, We are trying to decide if we should use Sockets or WCF for our project. We have two type of clients: 1. Users with IE accessing the server and so we know the answer there is WCF. 2. Processes...
5
by: ....DotNet4Ever.... | last post by:
OK here the big problem... My organization is not yet ready to move to .NET 3.5 and even .NET 3.0 is still seen as something "not quite stable" (don't ask me why). For those reasons the project...
3
by: Sendil kumar | last post by:
Hi All, I'm a developer of C++. Recently I was moved to QA,because of in-adequate resource, to test the WCF functionalities that have been implemented in my new project. I'm new to QA role as weel...
0
by: =?Utf-8?B?Q3JhaWdo?= | last post by:
Background: I am currently using WCF for remoting (using CSLA hosted in IIS) with a binding config entry like this: <binding name ="default" transferMode="Buffered" messageEncoding="Text"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.