http - OpenRasta can't properly deserialize an entity on PUT -
http - OpenRasta can't properly deserialize an entity on PUT -
i'm experiencing unusual behavior when handling http set in openrasta handler. handler method signature looks this:
public customerresource put(customerform customerform)
and here relevant resourcespace
configuration:
resourcespace.has.resourcesoftype<customerlistresource>() .aturi("/customers") .handledby<customerhandler>() .renderedbyaspx("~/views/customer/customerlistview.aspx") .and.asjsondatacontract().formediatype("application/json;q=0.3") .and.asxmlserializer().formediatype("application/xml;q=0.2"); resourcespace.has.resourcesoftype<customerresource>() .aturi("/customers/{id}") .handledby<customerhandler>() .renderedbyaspx("~/views/customer/customereditview.aspx") .and.asjsondatacontract().formediatype("application/json;q=0.3") .and.asxmlserializer().formediatype("application/xml;q=0.2"); // back upwards post , set /customers resourcespace.has.resourcesoftype<customerform>() .withouturi .renderedbyaspx("~/views/customer/customereditview.aspx") .and.asjsondatacontract().formediatype("application/json;q=0.3") .and.asxmlserializer().formediatype("application/xml;q=0.2");
customerform
looks this:
[xmlroot("customer", namespace = clientsettings.namespace)] public class customerform : formbase, icustomer { [xmlelement("contact-info")] public contactinfo contactinfo { get; set; } [xmlattribute("id")] public int id { get; set; } }
contactinfo
looks this:
[xmlroot("contact-info", namespace = clientsettings.namespace)] public class contactinfo { [xmlelement("email")] public string email{ get; set; } [xmlelement("first-name")] public string firstname{ get; set; } [xmlelement("last-name")] public string lastname{ get; set; } [xmlelement("mobile-phone-number")] public string mobilephonenumber { get; set; } }
my problem when customerform
set server, openrasta unable deserialize properly. deserialize contactinfo
set null
although sent client. have digged in irequest.entity.stream
ensure xml need indeed there, , is:
<?xml version="1.0" encoding="utf-8"?> <customer id="1" xmlns="urn:namespace"> <contact-info> <email>5867ca8a5a5548428c4bc90c1f7e41d6@example.com</email> <first-name>0440a6d5f071478d8571bac1301552bc</first-name> <last-name>49069fb41eb141c79326dc64fa034573</last-name> <mobile-phone-number>59980075</mobile-phone-number> </contact-info> </customer>
how can irequest.entity.stream
contain necessary info while deserialized customerform
object received in put(customerform)
method doesn't? have tests ensure serialization , deserialization works , have post(customerform)
in exact same handler works. it's when http method set customerform
has contactinfo
set null
.
i've thoroughly read debug output openrasta , says is:
27-[2011-07-15 11:09:15z] information(0) operation customerhandler::put(customerform customerform) selected codec score of 0 27-[2011-07-15 11:09:15z] information(0) loaded codec openrasta.codecs.xmlserializercodec 27-[2011-07-15 11:09:15z] verbose(0) switching total object media type reading. 27-[2011-07-15 11:09:15z] stop(1) exiting pipelinerunner 27-[2011-07-15 11:09:15z] start(1) entering pipelinerunner: executing contributor operationinterceptorcontributor.wrapoperations 27-[2011-07-15 11:09:16z] stop(1) exiting pipelinerunner 27-[2011-07-15 11:09:16z] start(1) entering pipelinerunner: executing contributor operationinvokercontributor.executeoperations 27-[2011-07-15 11:09:16z] verbose(0) ignoring constructor, next dependencies didn't have registration:openrasta.operationmodel.interceptors.ioperationinterceptor[]
the weirdness have spotted missingmethodexception
thrown firstchanceexception
(but never bubbles up) right after step, stack trace of short have no thought problem might be:
2011-07-15t13:09:16.036 appdomain.firstchanceexception system.missingmethodexception: fellow member not found. @ system.defaultbinder.bindtomethod(bindingflags bindingattr, methodbase[] match, object[]& args, parametermodifier[] modifiers, cultureinfo cultureinfo, string[] names, object& state)
i have no thought why missingmethodexception
beingness thrown , why doesn't bubble if don't subscribe appdomain.firstchanceexception
event, might related why customerform
isn't deserialized correctly. however, since deserialize correctly on http post, have doubts.
ideas?
sounds wacky have tried moving id top of customerform object?
[xmlroot("customer", namespace = clientsettings.namespace)] public class customerform : formbase, icustomer { [xmlattribute("id")] public int id { get; set; } [xmlelement("contact-info")] public contactinfo contactinfo { get; set; } }
openrasta uses (awful) .net info contract xml serializer sensitive element positions. wrote our own serialiser reverts traditional 'dot net' xml serializer.
http deserialization put openrasta
Comments
Post a Comment