First off, I am still learning and this question may be way off because of my lack of knowledge of web services and WCF.
I have a class and I am wanting to create a data contract.
For example, I have my WCF service in one namespace and then I have a class in another namespace and I want to pass this class to a WCF method.
My question is where does this class need to reside Should it be included in the same namespace as the service contract Does it need to be referenced in the .svc file And what effect does the svcutil have with data contracts, does it need to be part of the generated proxy
Thanks in advanced for you help!
Russ

DataContracts & svcutil & generated proxy oh my!!
wPa
madd
Thanks for the reply!
Like I said I am still a beginner with web services, wdsl, soap and WCF.
After looking at your reply, I think what I was trying to ask was about the class definition. Does the class definition need to be in the same namespace as the interface and interface implementation Which I believe you are saying yes. So if I have classes defined in another namespace I will need to move them to the same namespace as the WCF service in order to pass them to the methods
Which raises another question, what is the difference between the namespace around the class definition and the namespace defined in the [DataContract(Namespace="mySpace")] atrribute or where can I find out the difference
Thanks,
Russ
Memo.CPP
You don't need to have the same namespace in the servicecontract and the datacontract. However, the datacontract definition in both the client and the server need to have the same ns otherwise it won't be speaking the same language, so to speak.
If you're using the datacontract in one of your OperationContracts, then it will show up in your proxy.
So you can do this:
[ServiceContract(Namespace="urn:ScottsReallyCoolApp")]
interface IScott
{
[OperationContract(Name = "Yo", Action = "urn:ScottsReallyCoolApp/Yo", ReplyAction = "urn:ScottsReallyCoolApp/YoResponse")]
string Yo(MyData input);
}
[DataContract(Namespace="urn:YoMyData")]
class MyData
{
[DataMember]
public string Hi;
[DataMember]
public int blah;
}
And you'll have an envelope that looks like this:
<s:Body>