Parent class serialization in RPC

I am using Java and we i want to make a RPC call to another service.

Class BaseClass {
    // some other fields with getter setter;
    private String type;
}

Class Type1Class extends BaseClass {
    // some fields with getter setter;
}

Class Type2Class extends BaseClass {
    // some fields with getter setter;
}


// Some function inside the class.
public String doSomething(BaseClass obj) {
    String result = "";
    if(obj.getType().equals("Type1")){
        Type1Class obj1 =(Type1Class) obj;
        // do something here 
    } else {
        Type2Class obj2 =(Type2Class) obj;
        // do something here 
    }
    return result;
}

Now from other service, i am calling this function as RPC.

Type1Class obj = new Type1Class();    
serviceClass.doSomething(obj);

Now in regular java class(without any RPC call), this will work. But when calling the same thing as RPC, i am getting the error, Cannot cast BaseClass object to Type1Class object.

I think the problem is when the Type1Class object is sent over the network, it is serialized using Jackson(All the fields of the class are present). Now on the other service, once deserialization happens, it make an object of BaseClass instead of Type1Class. Now when type is "Type1", then, when i try to cast in Type1Class object it doesn't work because original object created after deserialization is of actually Baseclass not Type1Class (Object type is not preserved over RPC call) whereas in Normal Java call, original Object is still Type1Class object (call by reference) and it works. How can i solve this in RPC calling?