user1718433
user1718433

Reputation: 7

Problems deserialize Message Queue (Modified)

I am making a WCF service with MSMQ, the service sends an instance of the Person class, this instance is the content of the message from the queue. When mansaje is sent to the queue is serialized in a way that does not remain as an XML structure, otherwise as binary serialized in a message. I would like to know how to serialize the message so that it is not in binary and can be deserialized as xml or deserialize the message in binary.

00 01 00 01 04 02 23 6E ......#n
65 74 2E 6D 73 6D 71 3A et.msmq:
2F 2F 6C 6F 63 61 6C 68 //localh
6F 73 74 2F 70 72 69 76 ost/priv
61 74 65 2F 6D 69 63 6F ate/mico
6C 61 03 07 56 02 0B 01 la..V...
73 04 0B 01 61 06 56 08 s...a.V.
44 0A 1E 00 82 99 36 68 D...??6h
74 74 70 3A 2F 2F 74 65 ttp://te
6D 70 75 72 69 2E 6F 72 mpuri.or
67 2F 49 50 72 6F 63 65 g/IProce
73 61 72 52 65 67 69 73 sarRegis
74 72 6F 73 2F 50 72 6F tros/Pro
63 65 73 61 72 52 65 67 cesarReg
69 73 74 72 6F 44 0C 1E istroD..
00 82 99 23 6E 65 74 2E .??#net.
6D 73 6D 71 3A 2F 2F 6C msmq://l
6F 63 61 6C 68 6F 73 74 ocalhost
2F 70 72 69 76 61 74 65 /private
2F 6D 69 63 6F 6C 61 01 /micola.
56 0E 40 10 50 72 6F 63 [email protected]
65 73 61 72 52 65 67 69 esarRegi
73 74 72 6F 08 13 68 74 stro..ht
74 70 3A 2F 2F 74 65 6D tp://tem
70 75 72 69 2E 6F 72 67 puri.org
2F 09 01 69 29 68 74 74 /..i)htt
70 3A 2F 2F 77 77 77 2E p://www.
77 33 2E 6F 72 67 2F 32 w3.org/2
30 30 31 2F 58 4D 4C 53 001/XMLS
63 68 65 6D 61 2D 69 6E chema-in
73 74 61 6E 63 65 40 08 stance@.
5F 70 65 72 73 6F 6E 61 _persona
40 06 43 65 64 75 6C 61 @.Cedula
99 07 31 32 33 34 35 36 ?.123456
37 40 06 4E 6F 6D 62 72 [email protected]
65 99 06 52 6F 62 65 72 e?.Rober
74 40 0E 50 72 69 6D 65 [email protected]
72 41 70 65 6C 6C 69 64 rApellid
6F 99 07 53 70 65 6E 63 o?.Spenc
65 72 40 0F 53 65 67 75 [email protected]
6E 64 6F 41 70 65 6C 6C ndoApell
69 64 6F 99 04 48 61 6C ido?.Hal
6C 40 09 44 69 72 65 63 [email protected]
63 69 6F 6E 99 15 55 6E cion?.Un
69 74 65 64 20 53 74 61 ited Sta
74 65 2C 20 46 6C 6F 72 te, Flor
69 64 61 01 01 01 01    ida....

Upvotes: 1

Views: 329

Answers (1)

Phil Patterson
Phil Patterson

Reputation: 1262

In the config file you can specify the serialization format used for the service.

<service name="YourService">
    <endpoint address="msmq.formatname:DIRECT=OS:.\private$\yourMsmq"
              binding="msmqIntegrationBinding"
              bindingConfiguration="XmlBinding"
              contract="YourContract" />

</service>

<msmqIntegrationBinding>
    <binding serializationFormat="Xml" 
             name="XmlBinding" 
             durable="false" 
             exactlyOnce="false">
    </binding>
</msmqIntegrationBinding>

Here's a list of the other values that are possible MsmqMessageSerializationFormat Enumeration

I would like to know how to serialize the message so that it is not in binary and can be deserialized as xml or deserialize the message in binary.

If you are asking how to make sure that the client and server serialize to the same format you will need to make sure the binding configuration for all clients and the server are set to use the same serializationFormat. If a client passes in a binary serialized queue message and the server is set to use the Xml format you will have errors.

Upvotes: 2

Related Questions