Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Using namespaces in WCF service

 
 
Old 05-07-2007   #1 (permalink)
StanB


 
 

Using namespaces in WCF service

Suppose I have this service:

================
namespace BillEntry
{
[ServiceContract(
Name = "BillEntryService",
Namespace = "http://BillEntry")]

interface IBillEntryService
{
[OperationContract]
void ProcessEntry (Employee[] list);
}

[DataContract(Namespace = "http://BillEntry")]
[KnownType(typeof(Manager))]
public class Employee
{
private int pk;
[DataMember]

public int Pk
{
get { return pk; }
set { pk = value; }
}
}

[DataContract(Namespace = "http://BillEntry")]
public class Manager : Employee
{
private int level;
public string Level
{
get { return level; }
set { level = value; }
}
}
}
=====================

I generate service proxy with 'n' option

/n:http://BillEntry, BillEntry

Two questions I don't understand here.

1. Why does svcutil generate TWO sets of Employee and Manager classes, one
set in the default namespace, second one in BillEntry namespace?

Second question is related to the first one, but this is where I stuck with
this:

One the client side, there are two sets of classes, in the default namespace
and in the BillEntry namespace, but ProcessEntry has Employee parameter
from BillEntry namespace

void ProcessEntry (BillEntry.Employee[] list)

so I have to create not Employee or Manager object but BillEntry.Employee
and BillEntry.Manager.

So far so good, everything compiles. However it fails on method call because
WCF expects
not 'BillEntry.Employee' but 'Employee'!


My first thought was to change [KnownType(typeof(Manager))]
to [KnownType(typeof(BillEntry.Manager))] but that didn't make any
difference

I don't know how can I fix this. I do need this 'BillEntry' namespace
generated by proxy so I can explicitly say 'BillEntry.Manager' versus just
'Manager', but I feel that I am doing something wrong here...

Another strange thing was that it was working fine, but then I changed
something in the service interface and svcutil began generating two sets of
classes, I had to change client code, it compiles, but blows up on this
method call....








My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Imported namespaces .NET General
Creating a cmdlet using csc.exe - missing namespaces PowerShell
Puzzled about namespaces PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46