Tuesday, July 5, 2011

.NET Web Service: System.InvalidOperationException: Missing parameter:

Context:

.NET Web Service
Apache HttpClient

Problem:


When I tried to call the service as follows from my JUnit Test

HttpPost post = new HttpPost("http://localhost:1287/service.asmx/SubmitZip");
post.addHeader("Content-Type", "application/x-www-form-urlencoded");
MultipartEntity entity = new MultipartEntity();
entity.addPart("b64zip", new StringBody(new String(Base64.encodeBase64(IOUtils.toByteArray(submissionStream)))));
post.setEntity(entity);

I got this error:

System.InvalidOperationException: Missing parameter: b64zip.
   at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
   at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
   at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

Solution:


To fix it, I needed to call it as follows:


List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("b64zip", new String(Base64.encodeBase64(IOUtils.toByteArray(submissionStream)))));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));

Apache HttpClient and Charles Web Debugging Proxy

To set Charles Web Debugging Proxy to capture http traffic run from Apache HttpClient:

DefaultHttpClient client = new DefaultHttpClient();
// you can set various parameters for your client here.
// set up the proxy.
HttpHost proxy = new HttpHost("localhost", 8888);
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

Monday, July 4, 2011

RED Scarlet. Canon 5D Mark II. Analog vs. Digital

i was trying to explain to a friend something, something about the RED Scarlet.  the information provided here is as good as my understanding.  read it at your own risk :)

before the advent of digital cameras, traditionally, movies have been shot with 35mm film.  35mm has been dominating for more than a century.  35mm has been unchallenged for a long time until the digital revolution gave rise to the digital camera and digital cinema.  besides the quality, the advantages of digital over film are obvious.  speaking of quality, it was a problem for digital before, but no longer it is.  digital has caught up and is able to produce stunning quality.

when we speak of quality, disregarding the other factors, the simplest comparison is resolution.  what resolution means is the the number of horizontal pixels X the number of vertical pixels.  this is how much detail that you can put in a picture.  what you hear a lot nowadays is HD.  HD comes in 2.5 flavors:  1. 1280x720p, 2. 1920x1080i, 2.5. 1920x1080p.  Not going into too much details, full HD is 1080.  this is the best resolution that you can get at home at the current moment.

since 35mm has no pixels, 35mm film is usually scanned in and processed at 2K (2048x1080) or 4K (4096x2160).  For a long time, digital cameras would not to able to produce films at these levels. 

then comes the RED ONE camera, manufactured by RED, to my knowlege, the first digital camera that could capture at the maximum of 4.5K (4480x2304) and really pushed the envelope of digital cinema and closed the gap.  a lot of the movies have been shot with the RED ONE.  if you go to RED's web site, you can see the long list of movies.  the RED ONE has been sold and in use for a while now.

the RED EPIC is the next generation.  it can capture at a maximum of 5K (5120x2700).  the body has scaled back.  the brain weighs only 5 pounds.  whereas the RED ONE only captures motion pictures, the RED EPIC not only captures motion pictures but also still pictures.  the EPIC comes in different models varying in prices.  what i really like about RED cameras, besides the superb quality, is that they have the modular design, meaning that all the components are interchangable.  why this is good?  you can change or upgrade a certain component without upgrading the whole thing.  they have a lot of accessories.  better yet, they even work with Canon and Nikon lenses using lens mounts.  it has a lot of inputs and outputs.  in short, it's really robust, flexible and extensible.

since the EPIC is quite expensive, it's not for common consumers.  what i'm really waiting for is the SCARLET which is supposed to be cheaper.  i haven't seen the specs on the SCARLET yet, but i will be happy at 3K for a price of $5000 (brain only.)  adding a lens and a component or two, it will end up like $10,000.

you probably have heard of the Canon 5D Mark II.  it's one of Canon cameras that is video capable.  it's very popular.  amazon retails it for around $3200 (body + lens).  it can capture motion pictures at HD.  it's supposed to be very good in low light.  if you want something now and don't care to shoot at more than HD, it's a good one to have.  if you want something to shoot more than HD and are willing to spend more money, i think SCARLET will be awesome.

if you have a lot of money and don't care how you spend it, i would recommend the top model of the EPIC.  since you don't care how you spend your money, get me one too, will you?  :)

Friday, July 1, 2011

That assembly does not allow partially trusted callers

I got this error "That assembly does not allow partially trusted callers" when I was trying to install a Windows Service written in C#.  After searching the Internet for a while and trying different solutions such as [assembly: System.security.AllowPartiallyTrustedCallers()] and others, nothing seemed to help.  My problem turned out to be that I was trying to install the service from a mapped network drive. After I copied the service over to the local drive, I was able to install it successfully.

Copying Music from IPod to Mac

  1. Download Detune from http://www.headlightsoft.com/detune/
  2. Install and run it on the Mac
  3. Connect IPod
  4. Create new folder on the Mac
  5. Highlight, select the songs, and drag them from Detune to the new folder
  6. Done.  That's it.

VirtualBox - Increasing Disk Space for Guest OS

Context:

VirtualBox 4.0.8
Host OS:  Mac OS X 10.6
Guest OS:  Windows XP

Problem:

I need to increase the primary virtual hard drive from the default size of 10GB.  

Solution:

If you simply want to add more space to the guest os, you can easily add additional hard drives by doing settings > storage > add hard disk and designate those as secondary hard drives.  For me, I need to increase the size of the primary hard drive, because Visual Studio 2010 requires things to be installed there.  Fortunately, starting with version 4, VirtualBox has made it really easy.  
  1. Open up Terminal
  2. Run the command VBoxManage modifyhd WindowsXP.vdi --resize 40000  (WindowsXP.vdi is my disk image.  I want to increase it to 40GB.)
  3. Step 2 increases the size of the hard disk, but  to the guest OS, it is still 10GB.  To make Windows XP aware of the new size of 40GB, I need to download GParted  live CD ISO and run it.  To run the GParted ISO, go to settings > storage > Empty (CD icon under IDE Controller) > CD icon (right of CD/DVD Drive: IDE Secondary) > Choose a virtual CD/DVD disk file...
  4. Start the guest OS.  GParted will boot up.
  5. Once I'm in GParted, I can simply drag to increase the size of the partition from 10GB to 40GB.
P.S.  You, reader, may find other detailed solutions elsewhere with pictures if you need more detailed instructions.

If you happen to have vmdk file instead of vdi, you need to convert your vmdk to vdi first by doing this: VBoxManage clonehd --format VDI WindowsXP.vmdk WindowsXP.vdi