Category: Computers

Getting SOAPUI to Pass Back a Value froma Request Using a Mock Service

If need a Mock Service to reply to a SOAP request with a value from that request, here’s the Groovy script to do it. (Groovy is a scripting language that can be run in the Java JVM. SOAPUI has it built in.)

1) Select your Mock Service in SOAPUI
2) Select the Mock Service operation
3) Select the appropriate Mock Service response
4) Click the “Script” tab at the bottom of the response editor window
5) Paste the following code into the script editing pane, substituting your values

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context)
def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)
def id = String.valueOf(holder.getNodeValue("THE NODE CONTAINING THE VALUE YOU WANT TO REPLY WITH HERE")
Context.setProperty("PARAMETER NAME HERE", id)

So basically you’re pulling the value from the node you define in line 3, into the variable called “id”. You’re then assigning the value of “id” to the parameter you define in line 4. You then insert the parameter into your response message and viola!

For example if the node you wanted to pull the value from was a node called “Name”, and the parameter you wanted to use was “nameid” then your code would look like this :

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context)
def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)
def id = String.valueOf(holder.getNodeValue(“Name”))
context.setProperty(“nameid”, id)

You’d then put ${nameid} into your MockService response.

View iPhone Contents in Preview.app

From MacOSXHints.com:

“I discovered this by accident. If your iPhone is connected to your Mac via USB, there will be a menu item in Preview, File » Import from [your] iPhone. This menu item will allow you to see, delete, and import media directly from the iPhone.”

Newspapers Online Since 1981

Even back in 1981 newspapers were experimenting with online editions. They’ve had 18 years to get it right. Why can’t they come up with a profitable business model?

Wake a Sleeping Mac with Airport Extreme

While reading the ArsTechnica review of MAC OS 10.6 I came across this neat feature. You can wake a sleeping Mac (to gain SSH access for example) as long as the “Wake for Ethernet network administrator access” option is checked in the Engery saver settings. The newest Airport Extreme and Time Capsule hardware is capable of waking a 10.6 Mac that your trying to connect to remotely.

[ I don’t like to leave my Mac Pro turned on 24 hours a day, especially during the summer in my un-air-conditioned house. But I do want to have access to the files on my Mac when I’m elsewhere—at work, on the road, etc. It is possible to wake a sleeping Mac remotely, but doing so requires being on the same local network.

My solution has been to leave a smaller, more power-efficient laptop on at all times on the same network as my Mac Pro. To wake my Mac Pro remotely, I ssh into the laptop, then send the magic “wake up” packet to my Mac Pro. (For this to work, the “Wake for Ethernet network administrator access” checkbox must be checked in the “Energy Saver” preference pane in System Preferences.)

Snow Leopard provides a way to do this without leaving any of my computers running all day. When a Mac running Snow Leopard is put to sleep, it attempts to hand off ownership of its IP address to its router. (This only works with an AirPort Extreme base station from 2007 or later, or a Time Capsule from 2008 or later with the latest (7.4.2) firmware installed.) The router then listens for any attempt to connect to the IP address. When one occurs, it wakes up the original owner, hands back the IP address, and forwards traffic appropriately.

You can even wake some recent-model Macs over WiFi. Combined with MobileMe’s “Back to My Mac” dynamic DNS thingamabob, it means I can leave all my Macs asleep and still have access to their contents anytime, anywhere. ]

Moore’s Law Misunderstood

While reading the ArsTechnica review of MAC OS 10.6 (Snow Leopard) I came across this tidbit.

[ Moore’s Law is widely cited in technology circles—and also widely misunderstood. It’s most often used as shorthand for “computers double in speed every year or so,” but that’s not what Gordon Moore wrote at all. His 1965 article in Electronics magazine touched on many topics in the semiconductor industry, but if it had to be summed up in a single “law”, it would be, roughly, that the number of transistors that fit onto a square inch of silicon doubles every 12 months.

Moore later revised that to two years, but the time period is not what people get wrong. The problem is confusing a doubling of transistor density with a doubling of “computer speed.” (Even more problematic is declaring a “law” based on a single paper from 1965, but we’ll put that aside for now. For a more thorough discussion of Moore’s Law, please read this classic article by Jon Stokes.) ]

Interesting stuff.

Merging 2 HFS Partitions using DiskUtil

As a Mac user, you’re probably aware of Mac OS X’s “Disk Utility” program for mounting volumes, repairing permissions, creating disk images, etc. However, the command line version of the tool, “diskutil” is also very handy and has functions that aren’t available in the GUI application.

Let’s say you have 2 HFS+ partitions; 1 called “Music” on disk0s1 and the other called “Photos” on disk0s2. Then, at some point decide that you don’t want those 2 partitions separated anymore and want to combine them into one partition called “Music_and_Photos.” It’s easy with the “diskutil” tool.

Open a command line and type :

“diskutil mergePartitions hfs+ Music_and_Photos disk0s1 disk0s2”

The partition disk0s1 (Music) and the partition disk0s2 (Photos) would at this point now be merged as disk0s1 (Music_and_Photos)

Keep in mind that only HFS partitions can be merged without data loss, and that the partitions being merged must be “next to each other” in the partition map. (Meaning that if you tried to merge disk0s1 and disk0s3 that s2 which is in the middle would also be merged.) If you don’t know where each partition’s place is in the partition map, simply type “diskutil list” on the command line to find out.

More info on DiskUtil can be found HERE.

Snow Leopard – Re-Enable Font Smoothing for LCD Monitors

From MacOSXHints.com

“You can force OS X to use LCD font smoothing on all displays with this Terminal command:

defaults -currentHost write -globalDomain AppleFontSmoothing -int 2

The number 2 here corresponds to Medium – Best for Flat Panel. You may also use 1 for light smoothing, and 3 for strong smoothing, as per the original OS X font smoothing options.”