How to handle multipart POST using a URI template of form /prefix/{suffix} in OpenRasta? -


i'm trying handle post of multipart document in openrasta uri template declaration of /content/{contentid}, fails. configuration is

resourcespace.has.resourcesoftype<content>().aturi("/content/{contentid}").handledby<contenthandler>().renderedbyaspx("~/views/contentview.aspx").and.asjsondatacontract(); 

the handler method follows:

public operationresult post(string contentid, ienumerable<imultiparthttpentity> entities) {...} 

i'm using following curl command test

./curl -v -f mypartname=@./hello.txt http://localhost:10247/content/id-1 

the post works fine if remove "{contentid}" uri template , modify handler accordingly.

any ideas on how resolve? log file follows below. --roland

4-[2011-10-10 02:27:47z] verbose(0) starts pre-executing request. 4-[2011-10-10 02:27:47z] verbose(0) incoming host request http://localhost:10247/content/id-1 4-[2011-10-10 02:27:47z] verbose(0) adding communication context data 4-[2011-10-10 02:27:47z] warning(0) contributor call bootstrappercontributor had null action. 4-[2011-10-10 02:27:47z] start(1) entering pipelinerunner: executing contributor httpmethodoverridercontributor.overridehttpverb 4-[2011-10-10 02:27:47z] stop(1) exiting pipelinerunner 4-[2011-10-10 02:27:47z] start(1) entering pipelinerunner: executing contributor authenticationcontributor.authoriserequest 4-[2011-10-10 02:27:47z] stop(1) exiting pipelinerunner 4-[2011-10-10 02:27:47z] start(1) entering pipelinerunner: executing contributor uridecoratorscontributor.processdecorators 4-[2011-10-10 02:27:47z] stop(1) exiting pipelinerunner 4-[2011-10-10 02:27:47z] start(1) entering pipelinerunner: executing contributor resourcetyperesolvercontributor.resolveresource 4-[2011-10-10 02:27:51z] stop(1) exiting pipelinerunner 4-[2011-10-10 02:27:51z] verbose(0) rewrote path. 4-[2011-10-10 02:27:51z] start(1) entering openrastarewriterhandler: rewriting original path     4-[2011-10-10 02:27:51z] start(1) entering openrastaintegratedhandler: request http://localhost:10247/content/id-1         4-[2011-10-10 02:27:51z] verbose(0) incoming host request http://localhost:10247/content/id-1         4-[2011-10-10 02:27:51z] verbose(0) adding communication context data         4-[2011-10-10 02:27:51z] start(1) entering pipelinerunner: executing contributor handlerresolvercontributor.resolvehandler         4-[2011-10-10 02:27:51z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:51z] start(1) entering pipelinerunner: executing contributor operationcreatorcontributor.createoperations             4-[2011-10-10 02:27:51z] verbose(0) created operation named signature contenthandler::get(string contentid)             4-[2011-10-10 02:27:51z] verbose(0) created operation named post signature contenthandler::post(string contentid, ienumerable`1 entities)         4-[2011-10-10 02:27:51z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:51z] start(1) entering pipelinerunner: executing contributor operationfiltercontributor.processoperations             4-[2011-10-10 02:27:51z] verbose(0) found 1 operation(s) matching name.             4-[2011-10-10 02:27:51z] verbose(0) found 0 operation(s) matching [httpoperation] attribute.             4-[2011-10-10 02:27:51z] verbose(0) no resource or no uri name. not filtering.         4-[2011-10-10 02:27:51z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:51z] start(1) entering pipelinerunner: executing contributor operationcodecselectorcontributor.processoperations             4-[2011-10-10 02:27:51z] information(0) operation contenthandler::post(string contentid, ienumerable`1 entities) selected 2 required members , 0 optional members, codec multipartformdatakeyedvaluescodec score 1.5.         4-[2011-10-10 02:27:51z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:51z] start(1) entering pipelinerunner: executing contributor operationhydratorcontributor.processoperations             4-[2011-10-10 02:27:51z] information(0) operation contenthandler::post(string contentid, ienumerable`1 entities) selected codec score of 1.5             4-[2011-10-10 02:27:51z] information(0) loaded codec openrasta.codecs.multipartformdatakeyedvaluescodec             4-[2011-10-10 02:27:51z] information(0) codec supports ikeyedvaluesmediatypereader. processing parameters.             4-[2011-10-10 02:27:51z] verbose(0) seeking next available part             4-[2011-10-10 02:27:51z] verbose(0) skip preamble. atpreamble true.             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) preamble found: true of size 0             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) skip preamble. atpreamble false.             4-[2011-10-10 02:27:51z] verbose(0) preamble found: false of size 0             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) seeking next available part             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) not null             4-[2011-10-10 02:27:51z] verbose(0) key mypartname not assigned.             4-[2011-10-10 02:27:51z] verbose(0) key mypartname not assigned.         4-[2011-10-10 02:27:51z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:51z] start(1) entering pipelinerunner: executing contributor operationinterceptorcontributor.wrapoperations         4-[2011-10-10 02:27:51z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:51z] start(1) entering pipelinerunner: executing contributor operationinvokercontributor.executeoperations             4-[2011-10-10 02:27:51z] verbose(0) ignoring constructor, following dependencies didn't have registration:openrasta.operationmodel.interceptors.ioperationinterceptor[] first chance exception of type 'system.invalidoperationexception' occurred in openrasta.dll             4-[2011-10-10 02:27:52z] error(0) error of type system.invalidoperationexception has been thrown             4-[2011-10-10 02:27:52z] error(0) system.invalidoperationexception: operation not ready invocation.             4-[2011-10-10 02:27:52z] error(0)    @ openrasta.operationmodel.methodbased.methodbasedoperation.invoke() in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\methodbased\methodbasedoperation.cs:line 56             4-[2011-10-10 02:27:52z] error(0)    @ openrasta.operationmodel.interceptors.operationwithinterceptors.<invoke>b__0() in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\interceptors\operationwithinterceptors.cs:line 47             4-[2011-10-10 02:27:52z] error(0)    @ openrasta.operationmodel.interceptors.operationwithinterceptors.invoke() in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\interceptors\operationwithinterceptors.cs:line 52             4-[2011-10-10 02:27:52z] error(0)    @ openrasta.operationmodel.operationexecutor.execute(ienumerable`1 operations) in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\operationexecutor.cs:line 14             4-[2011-10-10 02:27:52z] error(0)    @ openrasta.pipeline.contributors.operationinvokercontributor.executeoperations(icommunicationcontext context) in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\pipeline\contributors\operationinvokercontributor.cs:line 29             4-[2011-10-10 02:27:52z] error(0)    @ openrasta.pipeline.pipelinerunner.executecontributor(icommunicationcontext context, contributorcall call) in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\pipeline\pipelinerunner.cs:line 192         4-[2011-10-10 02:27:52z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:52z] error(0) aborting pipeline , rendering errors.         4-[2011-10-10 02:27:52z] error(0) error has occurred , processing of request has stopped.  exception: system.invalidoperationexception: operation not ready invocation.    @ openrasta.operationmodel.methodbased.methodbasedoperation.invoke() in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\methodbased\methodbasedoperation.cs:line 56    @ openrasta.operationmodel.interceptors.operationwithinterceptors.<invoke>b__0() in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\interceptors\operationwithinterceptors.cs:line 47    @ openrasta.operationmodel.interceptors.operationwithinterceptors.invoke() in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\interceptors\operationwithinterceptors.cs:line 52    @ openrasta.operationmodel.operationexecutor.execute(ienumerable`1 operations) in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\operationmodel\operationexecutor.cs:line 14    @ openrasta.pipeline.contributors.operationinvokercontributor.executeoperations(icommunicationcontext context) in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\pipeline\contributors\operationinvokercontributor.cs:line 29    @ openrasta.pipeline.pipelinerunner.executecontributor(icommunicationcontext context, contributorcall call) in c:\users\hochmuth\repositories\openrasta-core\src\openrasta\pipeline\pipelinerunner.cs:line 192         4-[2011-10-10 02:27:52z] verbose(0) pipeline in rendernow mode.         4-[2011-10-10 02:27:52z] start(1) entering pipelinerunner: executing contributor operationresultinvokercontributor.runoperationresult             4-[2011-10-10 02:27:52z] information(0) executing operationresult operationresult: type=internalservererror, statuscode=500.         4-[2011-10-10 02:27:52z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:52z] start(1) entering pipelinerunner: executing contributor responseentitycodecresolvercontributor.findresponsecodec             4-[2011-10-10 02:27:52z] information(0) selected codec htmlerrorcodec out of 2 codecs entity of type servererrorlist , negotiated media type text/html; q=0.5.         4-[2011-10-10 02:27:52z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:52z] start(1) entering pipelinerunner: executing contributor authenticationchallengercontributor.challengeifunauthorized         4-[2011-10-10 02:27:52z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:52z] start(1) entering pipelinerunner: executing contributor responseentitywritercontributor.writeresponse             4-[2011-10-10 02:27:52z] verbose(0) codec htmlerrorcodec selected.             4-[2011-10-10 02:27:52z] start(1) entering responseentitywritercontributor: generating response entity.                 4-[2011-10-10 02:27:52z] verbose(0) setting content-length 2159             4-[2011-10-10 02:27:52z] stop(1) exiting responseentitywritercontributor             4-[2011-10-10 02:27:52z] verbose(0) writing http headers.             4-[2011-10-10 02:27:52z] verbose(0) writing http header content-length:2159             4-[2011-10-10 02:27:52z] verbose(0) writing http header content-type:text/html         4-[2011-10-10 02:27:52z] stop(1) exiting pipelinerunner         4-[2011-10-10 02:27:52z] information(0) pipeline finished.     4-[2011-10-10 02:27:52z] stop(1) exiting openrastaintegratedhandler 4-[2011-10-10 02:27:52z] stop(1) exiting openrastarewriterhandler 4-[2011-10-10 02:27:52z] verbose(0) request finished. thread '<no name>' (0x1f68) has exited code 0 (0x0). 

from log, can see multipart codec being used in key/value processsing mode. in mode, content of multipart being parsed instead of assigning ienumerable, , issue codec.

i've added bug fix issue @ https://github.com/openrasta/openrasta-core/issues/32

in meantime, can let multipart codec deserialize content needed (which can use mapping dto or input parameters names of form entities, openwrap let assign form data standard properties , ifile or stream files).

alternatively, depending on needs, can unregister key/value mutlipart codec overriding dependency registrar , let object-only registration work normal.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -