tags:

views:

41

answers:

1

Hi!

I know this question is been asked before here but still I'm not sure what to select.

My service will be called from many 3 party system in the enterprise. I'm almost sure the information the service will collect (MyBigClassWithAllInfo) will change during the products lifetime. Is it still a good idea to expose objects?

This is basically what my two alternatives:

    [ServiceContract]
public interface ICollectStuffService
{
    [OperationContract]
    SetDataResponseMsg SetData(SetDataRequestMsg dataRequestMsg);
}

// Alternative 1: Put all data inside a xml file
[DataContract]
public class SetDataRequestMsg
{
    [DataMember]
    public string Body { get; set; }
    [DataMember]
    public string OtherPropertiesThatMightBeHandy { get; set; } // ??
}
// Alternative 2: Expose the objects
[DataContract]
public class SetDataRequestMsg
{
    [DataMember]
    public Header Header { get; set; }
    [DataMember]
    public MyBigClassWithAllInfo ExposedObject { get; set; }
}

public class SetDataResponseMsg
{
    [DataMember]
    public ServiceError Error { get; set; }
}


The xml file would look like this:

<?xml version="1.0" encoding="utf-8"?> <Message>   <Header>     <InfoAboutTheSender>...</InfoAboutTheSender>   </Header>   <StuffToCollectWithAllTheInfo>   <stuff1>...</stuff1> </StuffToCollectWithAllTheInfo> </Message>


Any thought on how this service should be implemented?

Thanks Larsi

A: 

If the information is going to change during the lifetime but you are under the gun to get something up there I would simply create a message that had a list of variant types that could be sent along with a message type version number.. Your bus can view the version number and route it appropriately. That way customers that are stuck with older versions of the message will not have to change the message interface they are using.

Shaun F
Well, you got it absoulutt correct (about the gun). I'm not sure what you meen by variant types? Are suggesting I use some general field1, field2, field3, together with a messagetype field? Currently my service will collect around 30 fields, and I expect it to grow.
Larsi
Yeah. So what you expose to the world will be something akin to a hashmap. Then once you marshall that sort of open xml structure you can validate the fields, types, etc based on the message version that is being passed in.
Shaun F