serialization,nservicebus,assembly-signing , NServiceBus use type full name in EnclosedMessageTypes metadata


NServiceBus use type full name in EnclosedMessageTypes metadata

Question:

Tag: serialization,nservicebus,assembly-signing

NServiceBus includes meta Header with message "NServiceBus.EnclosedMessageTypes". It puts AssemblyQualifiedName of serialized type in there.

e.g.: MyNamespance.MyType, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7777777777777777

Can I make NServiceBus use just type FullName instead?

eg: MyNamespance.MyType instead of AssemblyQualifiedName.

Use Case: Some legacy part of the system code requires assemblies signed. I don't want to sign all assemblies for this reason. So as a hack assemblies self signed only in legacy application. But when messages from shared contracts packages serialized in legacy application NServiceBus cannot deserialize them without signed assembly.

'NServiceBus.MessageDeserializationException: An error occurred while attempting to extract logical messages from transport message 99999999-9999-99999-9999-999999999999 ---> Newtonsoft.Json.JsonSerializationException: Type specified in JSON 'MyNamespance.MyType, MyAssembly' was not resolved. Path '[0].$type', line 9, position 999.'

Answer:

The answer lies in IMutateTransportMessages or more specifically in this case IMutateOutgoingTransportMessages

It allows changing headers, so I could strip PublicToken, so assembly looks unsigned.

public class EnclosedMessageTypeMutator : IMutateOutgoingTransportMessages
{
    public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage)
    {
        var header = transportMessage.Headers["NServiceBus.EnclosedMessageTypes"];
        header = header.Substring(0, header.LastIndexOf("=", StringComparison.InvariantCulture) + 1) + "null";
        transportMessage.Headers["NServiceBus.EnclosedMessageTypes"] = header;
    }
}

And don't forget to register it:

   components.ConfigureComponent<EnclosedMessageTypeMutator>(DependencyLifecycle.InstancePerCall);

Related:


Read nested json objects that have been serialized via gson library


java,json,serialization,gson,deserialization
I am storing an object in shared preferences. To do this I am serializing the object using the gson library and a typeadapter before storing them. Here's what my object looks like in json: { "id": 0, "name": "Sensor 2D:D3:5C", "address": "00:07:80:2D:D3:5C", "device": { "mAddress": "00:07:80:2D:D3:5C" }, "temp": "31342e37" }...

While Conditions for Deserializing Multiple Objects in Java


java,serialization
I am currently preparing for an evaluation for a Job Offer i have. So the company has given some practice assignments and their respective Solutions. I am facing a bit of dilemma on how to deserialize multiple objects from a Serialized file. Initially when i was solving on my own,...

Why does NServiceBus on Azure append “.events” to my Topic names?


azure,nservicebus,nservicebus5
I have an Azure Topic called "response1" and I would like to subscribe to messages sent to the topic using NServiceBus. My problem is that instead of subscribing to response1, NServiceBus creates a new Topic on azure called response1.events and subscribes to that. Why does NServiceBus add ".events" to some...

Produce different serialized JSON for a given class in different scenarios


c#,json,serialization,asp.net-mvc-5,json.net
Update 1: for reasons I won't go into, I want to avoid having anything other than the properties to be persisted in my entity objects. This means no extra properties or methods... I have an entity called Entity1 with (say) 10 public properties. In one place in my code I...

Coherence config default override path


java,serialization,override,weblogic12c,oracle-coherence
I've already spent more than 2 days trying to make this work without any result. The server is WebLogic 12c with embedded Coherence server. It is important to mention that I do not run Coherence in standalone mode, instead it starts automatically alongside the application server that has access to...

WCF singleton service with multiple endpoints?


wcf,serialization,singleton,wcf-endpoint
I have a singleton wcf service (InstanceContextMode.Single) i.e MyService with multiple endpoints namely netmsmq and http. The call to netmsmq works fine but when I call it as : Binding bin = new BasicHttpBinding(); EndpointAddress end = new EndpointAddress("http://localhost/WcfService1/MyService.svc"); var obje = new ChannelFactory<IMyService>(bin, end); obje.Open(); var factory = obje.CreateChannel();...

How can I create a txt file that holds the contents of an array in JavaScript?


node.js,matlab,serialization,ar.drone
I have several arrays that contain data that I would like to export, each array to a txt file, in order to be analyzed using MATLAB. Let's say my array is: var xPosition = []; // some algorithm that adds content to xPosition // TODO: export array into a txt...

Invalid cast when passing serializable object to activity


java,android,serialization
I have a complex object (which includes further objects and hashmaps). All objects implement Serializable. In the first activity I do: public void secondActivity(MyObject o) { Intent intent = new Intent(this, SecondActivity.class); intent.putExtra("myobject", o); startActivity(intent); finish(); } Then, in the second activity I'm doing: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);...

What elements does jQuery serialize affect?


jquery,serialization
I'm digging through the jquery production file and it doesn't seem that there's a definitive list of elements jquery will serialize. IE how does it know to serialize inputs and selects? I am curious because I have a common function to serialize my forms, that first does some checkbox value...

Need help to understand deserialization with ArrayList in Java


java,serialization,arraylist,casting,deserialization
I want write an ArrayList to a file and then read it back again. The list is going to hold Integer objects. Serialization seems to be working fine but I'm having trouble deserilaizing. More specifically I can'get the casting right. The serialization: ObjectOutputStream ou = new ObjectOutputStream(new FileOutputStream(new File("load.dat"))); ArrayList<Integer>...

Remove '@class' in XStream for Java primitive types


java,serialization,restlet,xstream
I have this field in a POJO that is serialized into JSON: @XStreamAlias("tags") List<String> tags; My problem is that the output looks like this: "tags": [ { "@class": "linked-list", "string": [ "test", "test2" ] } ], In what way that the output would look like this: "tags": [ "test", "test2"...

Prevent GSON from serializing JSON string


java,json,serialization,gson
I'm new to gson, and have newby question which I have not found an answer to, so please bear with me. StackOverflow and google were not my friend :( I have a java class "User", and one of its properties, "externalProfile" is a Java String containing already serialized JSON. When...

Error when serialize List


c#,serialization,windows-runtime,windows-phone-8.1
A am developing a Windows Phone Runtime application and a I have data in a string list. But when I suspend my app the error occurs Error trying to serialize the value to be written to the application data store and Additional information: Data of this type is not supported....

Error during deserializing XML


c#,xml,serialization,deserialization
Class that I am serializing: public class StyleProperties { [XmlAttribute] public string Name; [XmlAttribute] public string Description; [XmlAttribute] public StyleType Type; public ShapeStyleProperties ShapeStyle; public TextStyleProperties TextStyle; } Part that is responsible for serializing data: XmlSerializer serializer = new XmlSerializer(typeof(StyleProperties)); PPT.Presentation pres = Globals.ThisAddIn.Application.ActivePresentation; CustomXMLParts parts = pres.CustomXMLParts; //var serializer...

Serialize data-attributes


jquery,arrays,serialization,multidimensional-array
I have a drag and drop system, and each dropped item receives three data-attributes. data-id data-order data-content Now I should put these attributes into a multidimensional array. It should look like this: data-order = "0" [data-id = "1", data-content = "blabla"]; data-order = "1" [data-id = "2", data-content = "another...

django - “Incorrect type. Expected pk value, received str” error


django,serialization,foreign-keys,django-rest-framework
I my django-rest-framework I have the following models: Basically every ride has one final destination and can have multiple middle destinations. models.py: class Destination(models.Model): name=models.CharField(max_length=30) class Ride(models.Model): driver = models.ForeignKey('auth.User', related_name='rides_as_driver') destination=models.ForeignKey(Destination, related_name='rides_as_final_destination') leaving_time=models.TimeField() num_of_spots=models.IntegerField() passengers=models.ManyToManyField('auth.User',...

deserialize a list of Guid c#


c#,list,serialization,guid
Can anyone help me to deserialize this xml file into a list of Guid ? <?xml version="1.0" encoding="UTF-8"?> <content> <0>124179e5-82b9-c551-1e88-515ec3bbe4e3</0> <1>5c8246d3-5b9f-16bb-89dc-515ec4674170</1> <2>9d7f4701-81e3-3c90-c743-515ec9580852</2> <3>ea8d97bd-243b-b917-bc15-51764c2b2f34</3> </content> Thanks in advance....

Partial deserialization of a huge binary file - Java


java,serialization
This is my first question to StackOverflow. Please let me know if the question is not clear and need any more details. I have a class which has three attributes like this: class SampleClass { long [] field1; float[] field2; float[] field3; } A huge SampleClass object is built(with about...

ManyToMany Through Field Serialization


python,json,django,serialization,django-rest-framework
I am having problems serializing my items/orders with quantity. Results I am getting: { "id": 1, "_current_status": null, "orderitem_set": [ { "item_id": 2, "quantity": 5 }, { "item_id": 1, "quantity": 1 } ], "items": [ { "id": 2, "name": "Blue Shoe", "description": "Sweet blue shoe bro", "weight": "99.99", "price": "99.99"...

C# Protobuf .NET Using Preexisting Byte Array


c#,networking,serialization,protobuf-net,objectpool
So I am working with Protobufs in .NET and I am trying to incorporate them with a buffer pool and AsyncSocketEventArgs pool. The buffer pool assigns sections of a huge byte array to the event args. So, the problem, I can't figure out a way to have Protobufs serialize directly...

Include a method when object is serialized in JMS


symfony2,serialization,jmsserializerbundle
I have a method that returns a value: /** * @ORM\Table() * @ORM\Entity(repositoryClass="PersonRepository") */ class Person { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; public function getFoo(){ return $this->id + 1; } //setters & getters } I would like to include the...

How to serialize only a very few properties in a Java class


java,serialization
Recently in an interview I was asked a question: There are 100 properties in a Java class and I should be able to serialize only 2 of the properties. How is this possible? Marking all the 98 properties was not the answer as it is not efficient. My answer was...

Why serialization is not required for InProc session mode


c#,asp.net,asp.net-mvc,session,serialization
I am using the state service session provider for my mvc application and if I don't serialize the type which I am going to store in session, application throws an error that class must be marked as Serializable. But if I switch to InProc session mode, session works even if...

Jersey serializing null values to json : How to skip


java,json,spring,serialization,jersey-2.0
I am using Jersey 2.4 with spring. When I am returning a response from a method with an annotation @Produces(MediaType.APPLICATION_JSON) on it, it also serialize the null values to json. I don't want to serialize the fields that contains the null values. Is there any solution for the same?...

Need help converting JSON to C# Objects


c#,asp.net,json,object,serialization
I'm currently trying to convert a JSON string into C# objects and currently am experiencing trouble during my debugging. Below is a sample of the JSON along with my classes. Classes public class Timeline_RootObject { public List<Timeline_Frame> frames { get; set; } public int frameInterval { get; set; } }...

Deserializing Json data to c# for use in GridView - Error Data source is an invalid type


c#,json,gridview,serialization,.net-4.5
I am relatively new to working with C# (v5.0) and Json data (Newtonsoft.Json v6.0) and am seeking assistance in resolving an error when attempting to populate a .Net 4.5 GridView control. My sample Json data as returned by a web service is: { PersonDetails: [ { Book: "10 ", FirstName:...

Why does NServiceBus on Azure not use my specified endpoint name?


azure,nservicebus,nservicebus5
I have a console app that uses NServiceBus to publish a message to an Azure topic. However, NServiceBus creates a new topic with a different name, instead of the one I specified. Why is this? More details My message configuration looks as follows. This means that messages of Type 'TheResponse'...

Gson not deserializing JSON data


java,json,serialization,gson
I am trying to get some weather information from Yahoo APIs. This is my JSON: JSON This is my DTO: public class forecast implements Serializable { private static final long serialVersionUID = -520652416977871134L; private String text; private String high; private String day; private String code; private String low; private String...

Unable to extract values from object array, to which javascript array was deserialized


c#,arrays,object,serialization
var serializedArray = new JavaScriptSerializer().Deserialize<object[]>(filter); The content of the variable filter is [["Title","contains","foo"],"and",["Name","contains","foo"]]. Content of serializedArray is "object[3]","and","object[3]". Content of serializedArray[0] is object[3] which are "Title", "contains", "foo". serializedArray can be used with index operator, and foreach is applicable. But not for serializedArray[0]. Funny enough, both the serializedArray and serializedArray[0]...

TypeError: object is not JSON serializable in DJango 1.8 Python 3.4


python,json,django,python-3.x,serialization
I'm using DJango 1.8 and Python 3.4 When the below view is being ran, Django throws Type Error - Object is not JSON Serializable Views.py from django.http import HttpRequest,HttpResponse from django.http import JsonResponse from json import dumps def get_stats(request): if request.method == "POST": srch_dropV = request.POST['srch_dropAJ'] else: srch_dropV = ''...

Save GoogleApiClient on Activity restart in Bundle


android,serialization,parcelable,google-cast
My application has a function of theme change (i.e. Activity is restarting). Is it possible to save somehow GoogleApiClient with its all callbacks state and parameters into Bundle in onSaveInstanceState() so that I don't need to rebuild it every time? I'm using Google Cast Api Client (for Chromecast devices). mApiClient...

Why does Java serialization take up so much space?


java,serialization
I tried serializing instances of Byte and Integer and was shocked by how much space they took up when they were received on the other end. Why is it that it only takes 4 bytes to make an Integer, but it takes up over 10 times that many bytes upon...

reconstruct python method with kwargs with marshal and types?


python,serialization,deserialization,marshalling,unmarshalling
I am using the marshal module to serialize some Python methods, and reconstruct them using types module (Is there an easy way to pickle a python function (or otherwise serialize its code)?). I am having trouble getting it to work with optional kwargs. E.g. import marshal import types def test_func(x,...

Performance degradation of fast-serialization


java,performance,serialization
This question is particular to the Fast-Serialization library. https://github.com/RuedigerMoeller/fast-serialization I am using FSTLongOffheapMap (version 2.29) on windows 7, jdk 1.7 to store some objects. I tested the latency of storing an object and the 99.99 percentile comes to about 100 micros. This is excellent considering I ran it on windows...

Python - Load multiple Pickle objects into a single dictionary


python,serialization,pickle
So my problem is this... I have multiple Pickle object files (which are Pickled Dictionaries) and i want to load them all back up, but essentially merge each dictionary into a single larger dictionary. E.g. I have pickle_file1 and pickle_file2 both contain dictionaries. I would like the contents of pickle_file1...

Serialization - not working


java,serialization
I create class with methods like a How to serialize an object into a string and it every say error "java.lang.ClassCastException: java.lang.String cannot be cast to Myclass" My codes: 1) import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.xml.bind.DatatypeConverter; public class Serialization { public static...

Non-intruisive Boost serialization of labelled enums C++


c++,serialization,boost
I would like to serialize struct A where I could save the tag name of the enum expressions instead of its integer in a non intruisive way (without having to change struct A). enum e_fruit { apple, banana, coconut }; struct A { e_fruit fruit; int num; }; namespace boost...

NoClassDefFoundError with Kryo


java,serialization,classpath,kryo
I am looking for Kryo custom Serialization and De serialization example. How to check the the correctness of the Kryo read and write function. I have written some code to check, but it return exception. Any help would be appreciable. Thanks in advance. import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.KryoSerializable; import com.esotericsoftware.kryo.Serializer; import...

Serialize byte array in JSON.NET without $type


c#,json,serialization,json.net
I would like to serialize all my contract with $type reference using TypeNameHandling.Objects. However when using this flag, all byte arrays (byte[]) are serialized using $value+$type. I still want Base64 encoding but without $type. For example, for the following contract: class MyClass { public byte[] MyBinaryProperty {get;set;} } I get:...

Using Gson to serialize strings with \n in them


java,serialization,gson
\n in a string is effective in printing the text following \n in next line. However, if the same string is serialized using Gson, then \n is no more effective in printing it in next line. How can we fix this ? Sample program given below. In the program below,...

JSON parsing using .NET deserialize() with nested “list”


javascript,c#,json,parsing,serialization
EDIT: Simplified the classes { "name": "Final Five", "bio": null, "noPlayers": "0", "roster": { "players0": { "playerId": "3516", "name": "Gate", "role": "Mid Lane", "isStarter": 1 }, "players1": { "playerId": "3826", "name": "Veritas", "role": "AD Carry", "isStarter": 1 }, "players2": { "playerId": "4054", "name": "Novel", "role": "Support", "isStarter": 1 }, "players3":...

Serialize/Deserialize class containing byte array property into XML


c#,.net,xml,serialization,.net-4.0
My data class that will be serialized into XML look like this: [XmlType(TypeName = "SPCFileInfo")] [Serializable] public class SPCFileInfoProtocol { [XmlElement("CompanyCode")] public string CompanyCode { get; set; } [XmlElement("FileName")] public string FileName { get; set; } [XmlElement("FileVer")] public int FileVer { get; set; } [XmlElement("FileSize")] public long FileSize { get;...

Python: Serializing/de-serializing huge amount of data


python,serialization
I have a (very large) dataset. Something in the order of 250,000 binary vectors, each of size 800. The dataset resides in a (.txt ascii coding) file, in 'compressed representation'. Meaning, every line in that file represents how a vector looks, rather than 800 characters of zeroes and ones. For...

Is Java SerialVersionUid of 1L ok? Or does it need to be unique?


java,serialization,serialversionuid
I have two java classes which implement Serializable. I set both of them to have a serialVersionUid of 1L. A coworker said that all classes must have a unique serial version uid and that the jvm will treat classes as equal if they have the same serial version uid. I...

XML writer with repeating elements in node.js


javascript,json,xml,node.js,serialization
I'm trying to serialize an XML from a given object in node.js. I would like to serialize an array as some elements with the same name, i.e. the same element should be repeated. Example: var objectToSerialize = { SomeElement: { Data: [3, 5, 2] } }; serialize(objectToSerialize); Requested result: <RootElement>...

Serialization error using a jdbc-message-channel


serialization,spring-integration
I'm using a channel backed by a jdbc-message-store but I'm having a serialization error when storing the message. The message payload is a simple String. Here's my config and stacktrace: <bean id="auditMessageStoreQueryProviderBean" class="org.springframework.integration.jdbc.store.channel.MySqlChannelMessageStoreQueryProvider" /> <bean id="auditMessageStore" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore"> <property name="dataSource" ref="auditMessageStoreDataSource" /> <property...

Is it possible to configure an NServiceBus endpoint (on Azure transport) to accept a simple string as input?


azure,nservicebus,azureservicebus,nservicebus5
We have an NServiceBus endpoint that monitors an Azure Service Bus Queue (using Azure as a transport). But not all the clients that send messages to the queue are .NET-based. Can an NServiceBus endpoint be configured to accept a simple string as input? I've tried intercepting messages with a class...

WCF Service hosted in a Windows Service - Wrong / Expected Namespace


c#,xml,wcf,serialization,datacontractserializer
I have a WCF Service that I've installed that keeps throwing an unexpected namespace exception upon startup. The odd part is that it works just fine if I host it via IIS or in visual studio via the WCFSvcHost. I'm unable to find any namespace declaration in the designer when...

Why do I need to specify an xml namespace when I do serialization?


c#,asp.net,.net,wcf,serialization
I do not quite understand the reason why I need to specify an xml namespace for an object when I serialize the object to the wire. By default, the xml namespace for this object will be the CLR namespace of this object, this is enough for us to differentiate two...

Saving FileSystemInfo Array to File


c#,arrays,xml,file,serialization
I'm attempting to save an array of FileInfo and DirectoryInfo objects for use as a log file. The goal is to capture an image of a directory (and subdirectories) at a point in time for later comparison. I am currently using this class to store the info: public class myFSInfo...