Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

How can you emulate object serialization on java in C# -


i need call servlet call automation of java applet using c#. java applet calls servlet using url connection object.

url servlet = new url(servletprotocol, servlethost, servletport, "/" + servletname); urlconnection con = servlet.openconnection(); con.setdooutput(true); objectoutputstream out = new objectoutputstream(con.getoutputstream()); // write several parameters strings out.writeobject(param[0]); out.writeobject(param[1]); out.flush(); out.close(); 

the problem need simulate using c#. believe counterpart object httpwebrequest

httpwebrequest myrequest = (httpwebrequest)webrequest.create(servletpath); myrequest.method = "post"; myrequest.contenttype="application/x-www-form-urlencoded"; myrequest.contentlength = data.length; stream newstream=myrequest.getrequeststream(); // send data. newstream.write(param[0],0,param[0].length); newstream.write(param[1],0,param[1].length); newstream.close(); 

how write string serialized java string? there workaround here? according documentation of objectoutputstream in java, serialize object except primitive type. know string class, serialzie object or special case?

i have tried 1 solution, have imported ikvm (http://www.ikvm.net/) java virtual machine in reference , trying use java.io library in java. unforunately, when objectinputstream constructor called, "invalid stream header" thrown.

here altered code:

myrequest.method = "post"; myrequest.contenttype = "application/x-www-form-urlencoded"; myrequest.contentlength = data.length; stream newstream = myrequest.getrequeststream();  // send data. newstream.write(data, 0, data.length); newstream.close();  list<byte> lbyte = new list<byte>(); using (streamreader sr = new streamreader(myrequest.getresponse().getresponsestream())) {     while (sr.peek() >= 0)     {         lbyte.add((byte)sr.read());     } }  byte[] barr = lbyte.toarray(); objectinputstream inputstream = null;  try {     //construct objectinputstream object     inputstream = new objectinputstream(new bytearrayinputstream(barr));      object obj = null;      while ((obj = inputstream.readobject()) != null)     {         string objstr = obj string;     }   } catch (java.lang.exception ex) 

if have control on serialization/deserialization on java side, best bet use cross-platform serialization protocol such protocol buffers. c++, java, , python:

http://code.google.com/p/protobuf/

for .net, jon skeet wrote port:

http://code.google.com/p/protobuf-net/


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -