What is this part on my dishwasher?

I was installing a used dishwasher today and noticed this part. It is supposed to be plugged in there somehow. I have no idea what it is but when I turn the water on, water comes spraying out of it. Any ideas?

Here it is unplugged: http://nimb.ws/chvY1W
and here it is with the thingy plugged in: http://nimb.ws/zs7YZc

and the black thing that plugs in has wires coming out of it and going somewhere. It seems to be a sensor of some sort…no?

The black thing is almost certainly a solenoid, an electrically operated device that moves a plunger in or out. The whole assembly is a water flow valve that can be switched open or shut via the solenoid. As to the specific name of the valve and its function in this dishwasher, I dunno.

I’m no expert, but have worked on a couple of these more often than have ever hoped to. I’ve never seen a washer with more than one inlet valve, so that is the source for the water, no doubt.

Where does the water spray out? My first guess at the picture was it was the fill valve as noted above. Why was it off? The wires should have some type of plug to go into a harness or fitting someplace that has the mating plug.

Solenoid.

Water inlet solenoid valve. Take the valve itself apart and make sure there’s no obstruction (piece of gunk) preventing it from opening/closing properly. I see this type of issue over and over and very rarely is it the solenoid.