Beak’s Blog
Random comments about technology and life in Mexico

Archive for the 'Technology' Category

Testing a SOAP interface using the Apache Axis2 Plugin

Monday, November 17th, 2008

There’s a lot of information online about using various frameworks to add SOAP functionality to a Grails application, but not much for performing a simple test of your new SOAP service.

Before starting this sample, it is necessary for you to create a Book domain object as described in the Grails Quick Start tutorial.  Create one or two books for testing purposes.

After you initialize your data and have your application up and running, we can proceed.  Let’s create a SOAP service to access this data.  For this example, I utilized the Apache Axis2 plugin instructions to create my service.

To test, we can use the command line utility curl.  To do so, we first need to create a simple XML document to pass to our service.  Create a file called availableBooks.xml

<soap:Envelope
  xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  xmlns:axis="http://ws.apache.org/axis2">
  <soap:Header/>
  <soap:Body>
    <axis:availableBooks />
  </soap:Body>
</soap:Envelope>

We can now try passing this document to our service:

curl --header "Content-type: application/soap+xml" -i \
    --data @availableBooks.xml -X POST http://localhost:8080/soap-proto/services/test

The default plugin configuration will give you this error:
Please enable REST support in WEB-INF/conf/axis2.xml and WEB-INF/web.xml

You can’t just follow the instructions here because the Grails plugin framework has changed the location of this parameter.  Locate the file Axis2GrailsPlugin.groovy, and update the disableREST parameter:

    "disRest"(org.wso2.spring.ws.beans.ParameterBean) {
        name = "disableREST"
        value = "false"
        locked = "false"
    }

You may have to perform a “grails clean” and a restart of your application for this setting to take effect.

Retry your curl command from earlier.  You should now get the desired response (formatted for readability):

HTTP/1.1 200 OK
Content-Type: multipart/related;
  boundary=MIMEBoundaryurn_uuid_6A2C4C79E6979D3E371226968077707;
  type="application/soap+xml";
  start="<0.urn:uuid:6A2C4C79E6979D3E371226968077708@apache.org>";
  action="urn:availableBooksResponse"
Transfer-Encoding: chunked
Server: Jetty(6.1.4)
--MIMEBoundaryurn_uuid_6A2C4C79E6979D3E371226968077707
Content-Type: application/soap+xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <0.urn:uuid:6A2C4C79E6979D3E371226968077708@apache.org>

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
  xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:getBookByIdResponse xmlns:ns="http://ws.apache.org/axis2">
      <ns:return xmlns:ax21="http://ws.apache.org/axis2/xsd" type="Book">
        <ax21:author>John</ax21:author>
        <ax21:id>1</ax21:id>
        <ax21:name>HOWTO Program</ax21:name>
        <ax21:version>0</ax21:version>
      </ns:return>
    </ns:getBookByIdResponse>
  </soapenv:Body>
</soapenv:Envelope>
--MIMEBoundaryurn_uuid_6A2C4C79E6979D3E371226968077707--

You can try the same thing if you need to pass a parameter by modifying the XML request:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  xmlns:axis="http://ws.apache.org/axis2">
   <soap:Header/>
   <soap:Body>
      <axis:getBookById>
        <axis:id>1</axis:id>
      </axis:getBookById>
   </soap:Body>
</soap:Envelope>

Please note that we need to set the content type header for curl to “application/soap+xml”.  Without setting it, your application won’t know how to deal with the XML document.  Here are some common errors for other content types that I tried.  They don’t work with axis2, but they may work for other SOAP libraries:

"application/xml": <faultstring>The endpoint reference (EPR) for the Operation not
found is /soap-proto/services/test and the WSA Action = null</faultstring>
"text/xml" - <faultstring>com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [1,0]</faultstring>

I’ve included those error messages because it was near impossible to find the reason for them elsewhere.  Hopefully they help solve your problem.

If you are looking for a way to test your SOAP API through a Grails application, you can do so by creating a simple Controller:

class TestController {
def index = {
def soapRequest = """
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:axis="http://ws.apache.org/axis2">
<soap:Header/>
<soap:Body>
<axis:availableBooks />
</soap:Body>
</soap:Envelope>
"""
def soapUrl =
new URL("http://localhost:8080/my-project/services/test")
def connection = soapUrl.openConnection()
connection.setRequestMethod("POST" )
connection.setRequestProperty("Content-Type" ,
"application/soap+xml" )
connection.doOutput = true
Writer writer = new OutputStreamWriter(connection.outputStream)
writer.write(soapRequest)
writer.flush()
writer.close()
connection.connect()
def soapResponse = connection.content.text
render(soapResponse)
}
}

Change the XML document as necessary. Notice the “application/soap+xml” content type being set here as well.

Hopefully someone else benefits from my experience piecing together this puzzle.  If so, let me know by leaving a comment.

Grails documentation is not the holy grail

Monday, November 17th, 2008

Well, I obviously haven’t had much to write about this year.  That is probably going to change.  A new client I am working with is using Groovy and Grails and I’m in the process of learning them both.  It’s been about 4 weeks, and one thing is clear – beyond the introduction tutorial, the Grails documentation sucks.

The documentation at grails.org is available online in Wiki format.  This means that the community can help to make it suck less.  However, whoever wrote the Wiki software obviously thought that useless Ajax functionality was more important than important things like edit timestamps and revision comments.

Nonetheless, I’ll do my part to update the documentation when I find it outdated, missing essential information, or just plain wrong.

Besides the first tutorial on creating a Grails application, the grails.org website has not been the primary source of information for me to learn about Grails.  Most of my information comes from nabble.com and markmail.org, usually found with numerous Google searches.  I’ll also recommend the Pragmatic Bookshelf Groovy Recipes book, it’s a great resource for example code.

Ok, time for me to stop complaining and get back to work.

Did you feel the earth move?

Tuesday, October 23rd, 2007

Well, Google finally improved their 3 year old Google Map images for the Riviera Maya, as well as added 54 new countries. I guess the Earth must have shifted a bit since they last photographed the area — all of my custom street map images no longer lined up!

Unfortunately, whatever day the aerial view images were taken, there were some serious clouds hanging over Playa del Carmen’s downtown area. Nonetheless, the new map images appear much clearer than the old ones. Plus, they provide great views of the two brand new shopping centers built here in the last year (Centro Maya and Plaza Las Americas). All in all, I think I like images.

I have regenerated my map images and re-geo-coded all my locations over at In The Roo, my interactive map of Playa del Carmen. If you haven’t been there in a while, please click on over. My street map coverage has been extended and I’ve also added many little tweaks here and there.

iPhone in Mexico?

Sunday, August 5th, 2007

I was almost certain that I’d make it back to the US for the holidays before being inundated with people wanting to show me their wonderful new iPhones.  Unfortunately, at least one of the $600 cell phones made it’s way to the Riviera Maya, and was forced upon me 2 nights ago.

Is it wrong that I almost laughed when it crashed within 2 minutes of being demo’ed to me?

I guess not.  I’m used to Apple products crashing… My iPod Nano locks up every five or so times that I turn it on.  Playing audio files for an hour a few times a week must be extremely difficult for … an audio device.  I would imagine that a combined phone/mp3/camera/video player/photo gallery/email client/instant messenger/game system must be a little more challenging to pull off.

In all honesty, it’s probably the heat and humidity of the tropical environment here that causes these types of problems.  However, it’s fun to rip on people for spending more than $150 on a glorified cell phone.  :)

Fun with Google APIs

Friday, December 1st, 2006

During my free time, I’ve been spending some time getting to know the Google Gadgets and Google Maps API. I’ve decided that I needed to start putting this knowledge to use, and therefore decided to finally get started working on one of my pet projects.

According to the Guinness Book of Records, Playa del Carmen is currently the world’s fastest growing town (by a rate of 26 percent per annum). Paper maps of streets, restaurants, bars and hotels in the area are outdated long before they hit the tourists. And, unfortunately, this area (by area, I mean Mexico) does not yet have a wonderful resource like Yahoo! Yellow Pages to easily find and display this information.

So, when I’m out taking my frequent walks, I’m going to try and take my handy Garmin GPS unit with me and try to start plotting some of the area’s attractions. Who knows, maybe one of these days Google or Yahoo! will wake up and realize that Mexico needs this type of service as well, and they’ll pay me lots of money to provide them with the data I’ve collected.

Currently, my work in progress demonstrates how to add custom overlays (street names) on the satellite images of the area. This is where the I’ve spent a bulk of my time thus far (it’s isn’t obvious yet!), since Google has made it a painstaking process to piece together the image tiles and make a map to work with.

Another piece of my project is the use of markers. I’ve added some markers showing some bars, restaurants and hotels. In the future, I hope to use different colored markers for each attraction, and possibly toggle the display based on user preferences.

I’d like to discuss my accomplishments and hurdles, but it’s late. I’ll hopefully get around to that in future installments. Until then, check out my progress at In The Roo Google Map – Playa del Carmen.

Yet another blogger’s opinion of IE7

Thursday, October 19th, 2006

So, IE7 was released today. Aren’t you excited? Yeah, me neither. But, I decided to download it and see if it sucked less than IE6. There are already thousands of reviews of IE7 out there, so I figure one more wouldn’t hurt.

Even before I got to use the new browser, I was put off by the fact that it took about 10 minutes to install and also required the typical post-Microsoft-install reboot. And, I noticed that it disabled my virus scanner when it started installing — doesn’t that mean that any application can do that?

Anyhow, on to my first impressions…

A slimmed down, cleaner user interface. It’s not really a shock as other MS products have been going down this path for a number of years. However, I’m not convinced that this is a good thing.

Tabs. I didn’t like them when Opera introduced them, but over the years, I’ve grown to love them in Firefox. Now I find it irritating when my browser opens new windows unless I explicitly tell it to do so. IE7′s tabs blend too much into the UI, so it’s almost difficult to see them. I like how IE7 has a nice little tab that you can click on to open a tab.

RSS. I didn’t play with this, but it’s cool that it’s finally supported.

Anti-phishing security. Again, I didn’t play with it, but hopefully it’ll help the average Joe.

Login and form completion. IE7 must have remembered my preference to not ask to store passwords for IE6. However, I couldn’t figure out how to convince it to start asking again. The options were set correctly under the “AutoComplete Settings” dialog, they just weren’t working. Since I didn’t have any special settings configured already, I just used the new “Reset Internet Explorer settings” feature under the Advanced tab to get rid of any IE6 preferences that might have been lingering. That seemed to fix the problem for a few sites. Saving a login/password for some restricted access sites like SharePoint doesn’t appear to be an option.

View Page Source. Why is there still no keyboard command to do this? As a web developer, this is extremely frustrating.

Internet Options. Instead of trimming the browser UI, they should have cleaned this configuration section up. I’m a tech guy, and I hate trying to find how to change options in their options menu. I pretty much just leave things alone unless some reason or another forces me to find how to tweak an option. (See Login and Form completion above).

Crashes and shutdown delays. After 3 hours of moderate use, I’m happy to say that it hasn’t locked up yet. Although it has become unresponsive and/or slow, and has forced me to close the window. Sometimes clicking on the close window icon takes 15 seconds for IE7 to give up and die.

First-run start page. It asks you some configuration questions when you start, then sets the home page to MSN. Fine, but I changed it to a blank page because MSN takes too long to load. 2 hours later, it decided to change back to the First-run page again. How often is this going to happen?

Speed. I haven’t clocked anything, but page loads appear noticably slower than Firefox and IE6.

Page load icon. The rotating “e” has been replaced with a spinning circle on the tabs. It gives up waiting for pages that take a long time to load. You can only tell that the connection is still open by looking at the bottom status bar that says “Waiting for …”

Although I’m happy Microsoft has finally updated it’s antiquated IE6 browser, I guess I’m just underwhelmed with this latest version. This took how many months to deliver?

However, now that Microsoft is once again developing IE, I hope they continue to enhance it and get compliant with all of the existing web standards instead of waiting another 5 years for their next major overhaul. We can only hope.

A few reasons many people don’t switch to Linux

Sunday, October 8th, 2006

As I mentioned in a previous article, I was anxious to get a new machine down here so I could once again have a serious development environment. I’m happy to say that I’ve now been up and running with Fedora Core 5 for close to two weeks. It wasn’t all fun and games.

First off, I had been using RedHat and Fedora Core versions of Linux for more than 5 years. I wanted to try something new, just to see what was out there. I heard wonderful things about Ubuntu, so I thought I would give that a shot. After verifying that the install would work with my hardware, by using the LiveDVD, I installed Ubuntu 6.0.6 and got to work. I am not sure exactly what I did wrong, but when I tried to install new applications using their package manager, I kept running into dependency mismatches that were not automatically resolved.

I honestly spent 2 days trying to get my system up and running with Eclipse, Postgres, IntelliJ, Apache ant, and the Sun JDK 1.5. It did not go smoothly, and things just constantly felt broken. Probably the biggest decision to bail was the fact that with a fresh install, Ubuntu did not recognize my dual core CPU. I wasn’t about to go down the path of recompiling the kernel for smp support. If I had more time, I would have attempted another install, in case I had selected a wrong option or something, but I had work that needed to be done.
So, I downloaded the FC5 DVD and got to work. After installing and applying all of the latest updates, I was ready to roll. The installer even recognized the 2 CPUs and installed a pre-compiled smp kernel. Nice!

Unfortunately, I soon discovered, that the brand new Shuttle I had custom built did not include the built-in internal 802.11g adapter. The nice folks at Shuttle offered to fix the problem for me after 7 days of phone tag. Their solution involved me sending the machine back so they could install the adapter. I explained that this was not an option as I am now living in Mexico, and shipping packages to/from the US was too much of a gamble. Well, at least they will refund my money… it’s been over 10 days and I still haven’t seen a credit, so I’ll be bugging them again this week.

Unfortunately, due to setup of our network, the router is located in our bedroom, and all our computer equipment is out in our living room. Therefore, I had a few options… 1) Run a long cable across the apartment to hook into the LAN connector (my wife would kill me), 2) Move my computer into bedroom (there’s not enough room, and my wife would kill me), 3) Buy a USB wireless adapter (can I find one in this part of Mexico?), or 4) Bridge my Windows XP machine so that I could access the network.

I decided option 3 was going to be the best, but I needed to find an adapter first. So, in the meantime, I was stuck with option 4. Suprisingly, Windows XP made the process quite simple, I’m quite pleased to say. Unfortunately, sharing a wifi connection bridged through another machine is probably a speed demons worst nightmare!

Eventually, a Belkin F5D7050 USB wireless adapter was located at the local Sam’s Club. Thanks NAFTA!

I had a bad feeling about Linux and USB and wireless cards playing nicely together. My fears soon became a reality. I spent the next 3 days trying to find a driver that would work with my adapter. The wireless chip on the card is supposedly a rt2500 (Ralink Tech 2500), although I can only access the card by using an unsupported legacy driver for the rt73. I was able to hobble along for a few days with using a tool called ndiswrapper to load the Windows driver… however, besides the fact that it didn’t work with wireless encryption, the stupid thing would cause a total system lockup after a few hours of use.

Luckily, I stumbled upon the Rt2x00 SerialMonkey website. These guys took over the maintenance of the Ralink proprietary driver when Ralink open sourced it. They are currently in the process of rewriting, from scratch, the drivers for all of the Ralink chips. Excellent. After I solved a few problems, namely compiling the driver on Fedora Core (it involves a manual patch), and finding the mislabeled firmware for my chip on Ralink’s site, I was up and running. It’s now been 2 days without a lockup.

Although I’m up and running with the SerialMonkey driver, I’m sad to report that any high volume network traffic (bittorrent) will cause the driver to freak out and unload. Luckily, I don’t need that to do my work.
I love the stability and reliability of Linux, the massive amount of open source and free software available; however, I am not shocked that more people haven’t made the switch just yet. Although things like the LiveDVD from Ubuntu will help some people get a feel for Linux, getting the system functional and easy to maintain still needs some work. I am positive that things will continue to get better. I look forward to it.

Software Patents and Open Source Software

Saturday, July 8th, 2006

Here is an interesting story from Bruce Perens regarding 2 lawsuits regarding patents and Open Source Software.

Software Patent Lawsuits Against Open Source Developers

Linux, I miss you

Thursday, July 6th, 2006

Last November, when my wife and I moved to Mexico, we packed our Honda Civic with some basic necessities: clothing, a digital camera, multiple Spanish dictionaries, books, a laptop, etc. Space was our limiting factor, so we decided that we’d only pack things that we truly thought we’d need for our 6 month stay. Unfortunately, I had to say goodbye to my computer lab, consisting of a few Linux desktops and a few Windows XP desktops. Not only that, I had to go back to sharing a computer. One of many sacrifices we had to make for the experience of living in a foreign country for half a year.

Fast forward to the present…

Sharing a computer with my wife, who is also a programmer and an avid internet research junky, was not much fun. Therefore, we have since purchased another laptop to ease our time sharing problem.
However, things are far from perfect.

I have been developing websites, internet applications, and software for the past 15 years. Most of that time has been programming on Unix and Linux machines. There were a few months, here and there, where I developed Windows applications, using Visual C++. However, I’ve always felt much more productive developing software in a *nix environment.

My Dell laptop is currently running Windows XP. It functions fine for web surfing, watching movies, photo and video editing, and keeping track of our ever dwindling finances. However, I just can’t seem to be very productive as a software developer on it. It feels like I only spend 40% of my time being productive. I’m not exactly sure what all of my issues are, but a few off the top of my head:

  • Rebooting after installing or removing software. Why is this still necessary?
  • Lack of a robust command prompt. Considering Windows is cut-and-paste friendly in most of their apps, why is it so difficult to add this functionality to the command prompt? Why does the copy feature (Mark) select a box region, and not work like every other cut-and-paste app? Why can’t I resize the app like every other app out there?
  • Starting and stopping services. I hate digging through the control panel to find the service admin tool. There’s probably a command line way of doing this, but I haven’t discovered it yet.
  • No virtual desktops. In a normal day, I’m probably switching between 7-10 active applications. Finding the one I want using Alt-tab or the taskbar repeatedly eats away my valuable time.

Yes, I know there are many add-on applications I can install to fix some of these issues, but the ones I’ve tried all seem kludgy.

For instance, I installed cygwin. Cygwin’s default terminal uses the command prompt, so I still can’t cut-and-paste. I assume I could set up xterm to do this, but after a few months, I still haven’t gone through the effort to find out how. Due to cygwin’s psuedo-paths and real Windows paths, setting up applications and scripts is a nightmare. All in all, cygwin has probably introduced as many problems as it has solved.

There are probably some real solutions out there, if I chose to find them. However, going out and finding them contributes to my 60% of unproductive time.

I’m just waiting for my next trip back to Chicago (in August), when I’ll retrieve one of my Linux desktops and end this misery.