WCF: standalone methods or a generic ProcessMessage method that accepts xml

My company is developing an application that receives data from another company through TCP sockets and XML messages. This is delivered to one gateway application, which then translates it into several copies of the same internal application on different machines of our organization.

WCF was chosen as the technology for processing internal messages (internally bi-directional). The developers considered two methods.

  • Individual methods, WCF service for each message received by the gateway expression. The gateway application will analyze incoming external messages and call the appropriate WCF service method. incoming XML will be translated into a DataContract DTO and supplied as an argument to the corresponding WCF Method.

  • The internal application exposed the WCF service as one “ProcessMessage” method, which took an Xml string message as an argument. Parse the internal application, then deserialize the resulting xml and process it accordingly.

The lead developer thought option 2 was the best option since it is “easier” to serialize / deserialize xml. I thought the argument did not make sense, because DataContracts is serialized and deserialized by WCF, and with WCF we better print our data. In option 2, someone can call the WCF service and pass any line. I believe that option 1 is a simpler interface and makes the application more convenient and convenient.

- xml - , , .

, .

+3
3

: XML vs Objects XML vs Objects # 2. .

hybrod, :

// Just using fields for simplicity and no attributes shown.
interface WCFDataContract
{
    // Header details
    public int id;
    public int version;
    public DateTime writeDateTime;

    public string xmlBlob;

    // Footer details
    public int anotherBitOfInformation;
    public string andSoemMoreInfo;
    public book andABooleanJustInCase;

}

, xmlBlob, , , . , blob, ( ). .

- , 2 , ;)

0

1 , , .

, / DataContracts, 2 . , xml (, Atom, raw xml ..)

2 ProcessMessage() , , xml ( , ),

1 WCF .

+1

, . , , WCF, DataContract.

Thus, TCP-based XML deserialization is more centralized on the gateway, and your internal applications don't need to worry about it, they just need to expose any WCF services and they can deal with actual objects.

If you force internal applications to deserialize, you can get more maintenance if the format changes or something else.

So, I would say that option 1 (if I did not understand).

0
source

Source: https://habr.com/ru/post/1703067/


All Articles