Use primitive types as parameters.

Topics: General Discussion Forum, Service Factory Modeling Edition Forum
Jul 30, 2008 at 12:10 AM
Edited Jul 30, 2008 at 12:20 AM
I am trying to learn the WSSF-Modeling Edition, and i was wondering if there is a way to use primitive types as parameters through the models. Is it also possible to return primitive types through the models?
Jul 30, 2008 at 5:36 PM
You have to create message contracts. However, the message contracts may have primitive message parts.
Jul 30, 2008 at 6:47 PM

I had added a message contracts, but it would not let leave the IsWrapped property to false if it contained more than one part. I now know that its because if it was not wrapped, it would not be compliant with basicprofile 1.1.

In either case i really apreciate your response. :)

Jul 30, 2008 at 6:58 PM
John is correct, in the Service Contract Model you can add Messages that can contain either primitive or data contract message parts (referencing Data Contract Model elements). These messages should then be linked to and from Operations to represent request and response types respectively. Try going through the hands on lab to get some guided experience in WSSF:

Jul 30, 2008 at 7:20 PM
I went through the hands on lab, I had asked the wrong question i believe. I was trying to have the primitive parts unwrapped however, as i had noted in my previous post, the model validation will not allow you to create non- Basic Profile 1.1 compliant code.
Jul 30, 2008 at 7:28 PM
Is it possible to create Base DataContracts that as contracts could inherit through the DSL Model?
Jul 30, 2008 at 9:43 PM
If I didn't understand wrong, you would like to create a base DataContract so that other ones could inherit from it. Meaning, all descendent types would inherit members from the base type. The DataContractModel allows you to create a DataContract and link it to other ones..but it would be a composite relation, not inheritance.
Jul 31, 2008 at 3:22 PM

You understood me correctly. I would've thought that this would be a need. Is having a composite relation recomended over having inheritance?

Thank you very much for your posts, they are very helpful.
Jul 31, 2008 at 8:38 PM
You are welcome! 

No, I wouldn't say that one is recommended over the other. Composite vs inheritance is a choice that is more determined by the scenario you are dealing with than with a practice itself. There is always a certain type of relation that is simply more appropiate than the other in a specific scenario. Hence, I agree that this could be required.

If inheritance is a need in your case, a possible workaround would be to create the data contracts involved and then manually apply the inheritance in the target project after generating the code. Keep in mind that a future code generation would, of course, overwrite those manual changes.

Jul 31, 2008 at 9:23 PM
Hi again, to avoid overwritting your changes a better approach would be to make use of the partial class C# feature ( You can create a separate class file and as long as you keep the same class name and namespace, the compiler should build a single class. So let's say you have a Person base class from which you would like to inherit to create an Employee class. You can create both DataContracts using the factory, generate the code and then create a separate file to define the inheritance between both. Code generation doesn't care of existing files, so everything should work fine. (Thanks Nico!)



    public partial class Employee: Person