Archive for the 'software development' Category

h1

Rails ActionWebService SOAP error “No valid method call - missing method name”

Wednesday, June 6th, 2007

For a Salesforce.com integration project, I need to create a SOAP server to accept messages from Salesforce. Seeing as there is no way directly import a wsdl into ActionWebService, I instead used wsdl2ruby from the soap4r distribution to generate server stubs. Then, I used ActionWebService to emulate the same service. I had problems with using the default layout, so I changed my structure to use a delegated structure:

class NotificationServiceController < ApplicationController
  web_service_dispatching_mode :delegated
  web_service_scaffold :invoke
  web_service :notifications, NotificationService.new
end
class NotificationServiceApi < ActionWebService::API::Base
  inflect_names false
  require_soap_action_header false
  api_method :notifications,
             :expects => [Notifications],
             :returns => [:bool]
end
class NotificationService < ActionWebService::Base
  web_service_api NotificationServiceApi
  def logger
    RAILS_DEFAULT_LOGGER
  end
  def notifications(organization_id, action_id, session_id, enterprise_url, partner_url, notification)
    my_object_id = notification.sObject.id
    ack = false
    begin
      ack = so_something(my_object_id)
    rescue Exception => e
      logger.error("Error processing payment: #{e.message}")
    end
    ack
  end
end

But STILL SOMETHING WAS WRONG. I was getting “No valid method call - missing method name” with the Salesforce outbound message queue reporting “org.xml.sax.SAXParseException: Content is not allowed in prolog.” MMmmmmm helpful. The stack trace was showing that rails was trying to process the request as XMLRPC not SOAP, which was all wrong.

The stack trace looked something like this:

RuntimeError (No valid method call - missing method name!):
    /usr/lib/ruby/1.8/xmlrpc/parser.rb:476:in `parseMethodCall'
    /usr/lib/ruby/1.8/xmlrpc/marshal.rb:63:in `load_call'
    /usr/lib/ruby/1.8/xmlrpc/marshal.rb:32:in `load_call'
    /vendor/rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb:36:in `decode_request'
    /vendor/rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb:32:in `decode_action_pack_request'
    /vendor/rails/actionwebservice/lib/action_web_service/protocol/discovery.rb:20:in `discover_web_service_request'
    /vendor/rails/actionwebservice/lib/action_web_service/protocol/discovery.rb:18:in `discover_web_service_request'
    /vendor/rails/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb:49:in `dispatch_web_service_request'
    (eval):1:in `notifications'
..........

Then, I came across patch 7077 (indirectly via this and then this), so, using my new best friend Piston I checked out Rails 1.2.3 into vendor/rails, and patched with the diff in the change. It was not entirely smooth - the xmlrpc.rb file could not be patched, but I merged the change manually.

All done! Works!

One thing I did discover the hard way though is that you need to have the whole stack of definitions with the same naming scheme for this to work. That is, if you’ve got a NotificationServiceController, you need to ensure that you have a NotificationService and a NotificationServiceApi defined and in use - no other class names will work. No Reuse of API Definitions, which is a bit of a bugger.

h1

DhtmlCalendar and Piston

Wednesday, June 6th, 2007

Over the weekend I decided to try (again) to find a Rails plugin for a Dhtml Calendar. The previous one I tried relied on an Engine, and for some totally unreasonable errrrrrrrr reason, I don’t like that. So I came across this: http://dry.4thebusiness.com/info/dhtml_calendar. At first it was all sunshile, lollipops and rainbows, but I soon realised that the plugin did not like Firefox.

This was, of course, a right pain. A quick test in IE determined it worked fine. In Firefox, it popup worked, but when you select a date the select boxes did not get updated. I waded through the javascript that comes with the plugin, and it seemed ok, but it simply WAS NOT firing in Firefox.

After some Javascript mangulation (that’s my word but you can use it if you want) I figured out that it wasn’t picking up the HTML form. So, even though the documentation says:

“Note: :form_name is optional unless your form is named. If it is named then supply the name of the form.”

I included it anyway.

And it worked. Yay.

Also, in the past I have used svn:externals to include external plugin into my project, and at the most inopportune time the external site as either (and I have had both of these happen):

  1. The external site is inaccessible at deployment time, meaning that your site is offline, or
  2. The external site updates the codebase to suit a new Rails version that you have not upgraded to, meaning that your site is broken and once again, offline

After doing that once or twice, I gave up on svn:externals and just exported the remote source and checked it into my repository, which is a bit shit because it removes the link to the origin of the code. This time I used Piston.

Piston fixes this. It checks out the remote code as an svn export but it stores the synchronization information as svn properties so that it can later be updated, or locked, or even merge the remove changes wth your own changes. Spiffy!

h1

New Job, more code, lots of ‘life’ things

Thursday, November 16th, 2006

So it turns out that sometimes when someone calls a job a Project Managment role, they actually mean Sales. The interview is no help, because it’s all agreement and “we want to go that way” stuff. But you walk in the door and it’s something else.

Not fun.

So anyway, I’ve got another job.

And I’m married now. It’s been a busy coupla months!

The good thing is that I am away from phone calls long enough now to actually do some coding, and it”s a nice change. (truth be told, in the final days at the old place I was debugging Mambo just for something different.

On the plus side, I met some nice people at the old place, namely the PPQ girls and boys. If you’re not in Queensland, you’ve got no chance of knowing who they are, and if you are and you want a personalised plate, they’re who you have NO CHOICE but to use ;) But they’re tops.

Anyway, wine in hand, Ruby on Rails open in Editplus, and I’m home.

Aaaaaahhhhhhhhhh.

h1

gem, rake, webricks hangs - resolved! (damn you windows)

Sunday, September 3rd, 2006

You know you’re in for a fun day when you go to the code that you were working on yesterday and it stops working today.

In this case, I tried to start webrick to check my site, and the damn thing would not start. It would get as far as “=> Booting WEBrick…” and then hang. Ok, fine. Google a bit, maybe it’s the firewall? stop the firewall, no good.

Then, I tried to upgrade rails. ‘gem install’ hangs, before it says “upgrading source index”. Hrm. Must be something wrong with ruby. Try “gem list -r” which does not work on this machine but does work on my other workstation. Ok, got to be a ruby problem - upgrade ruby. no good. upgrade again. no good.

Then I uninstalled, rebooted, and reinstalled. “gem install” works! hooray! I install all the dependencies I need, and try to start webrick. Same bloody issue.

At this point, it’s fairly clear that it’s not a ruby or rails issue, it’s got to be a windows issue. I google for (out of desperation) “webrick hang” and I see, 4 down, a blog entry called WEBrick Server Hangs in Windows XP - have a look and it recommends running the following command to flush the Winsock Catalogue:

netsh winsock reset

And everything is fixed. Rake runs, webrick runs, gems still work. Bye bye 3 hours of my life. Thanks Windows. You’re a champ.

h1

Ruby, SOAP4R and WSDL

Wednesday, July 26th, 2006

For PeopleHub, we interface with a service provider to process payments with the banks. They, conveniently, have started to provide SOAP services, which is awesome. So, the question for me then, was how to integrate with them.

For some reason, I had trouble getting documentation on SOAP4R. The website itself is quite sparse, and there wasn’t much to see, until I found Ruby + SOAP4R + WSDL at brendanwilson.com. Brendan, much kudos to you.

Basically, using SOAP without using the WSDL to generate code is a right pain the arse. Visual Studio does some nice intgrated stuff that generates code for you, as does the Apache stuff for Java. So, in ruby land, I was lost. Of course, Rails does have ActiveWebService and ActiveResource, but these were for producing services and using REST service from Rails respectively - no good for ad-hoc stuff.

The only thing I would caution the reader about is that although Ruby comes with a version of SOAP4R as part of the standard library, it DOES NOT come with the wsdl2ruby util from the distribution. Follow all of Brendan’s suggestions and you’ll be laughing.

h1

Friggin Mambo

Sunday, July 2nd, 2006

I know Mambo has been pretty popular in the past. Personally I never warmed to it, because once I got past the fancy veneer it was excruciatingly difficult for a newbie to discover how to write a >1 page module.

Apparently, I am not alone in that difficulty. For the last week I’ve been trying to get a bit of Mambo work done at my new job and it seems that Mambo developers are so scarce that anyone who is worth their salt has a job in it while no-one else knows diddly about it.

Personally I’d be happier if I could get the sites redeveloped in ANYTHING, but that’s a bit hard when the customer actually likes the admin side of Mambo and sees no reason to change. Can’t blame them for that, really…

Anyway, what a PITA. Thanks to my buddy over at albinoirishman.org though, things might come good. But why is this ‘big thing’ from a year ago now nothing but a blip on the radar? I guess from the standpoint of a CMS-only website there are new frameworks out there like Drupal, but ferchrissakes, you’d think people would want to cash in those skills for which they worked so hard. Although, from what I’ve seen, it’s not worth the pain.

h1

Software Designer != Interface Designer

Sunday, June 18th, 2006

What is it about we IT folk that makes us so crap at interface design? Personally, I can sit down and crack out some sweet code without too much drama, but man I am shit at making the UI any good.

It’s not that it doesn’t work - it’s just that it’s not particularly pretty. Or intuitive.

One of the guys at my new work is case in point for this. He’s made a CMS style thing in dotnet for the internal projects and he had it up and going nice and quick and he can put a new version in a template in a day or two. Unfortunately it’s the biggest hunk of shit to use ever. If you update a page, when you go back to the menu it puts a javascript alert on the screen saying “Page Updated” Thanks for letting me know it’s updated - but did you really need to interrupt me to do it?

As a reminder for those who don’t remember, the Javascript ‘alert’ function is a modal box with a message that you MUST click before doing anything else. So when you’re going through updating all this content it’s

  1. Select page to change
  2. Edit content
  3. Click save
  4. Try to select next page but there’s that stupid alert again
  5. Click alert
  6. Swear
  7. See (1)

You know, nothing personal, good coder, but what a magnificently moronic choice for a way to tell the user something has happened - interrupting them.

For me, I don’t really want to be a UI designer. It’s too subjective for me; English, for example, was always secondary to Physics. But I’d like to think I get some of those things right…

On that topic - I need a new design for the PeopleHub Payments website. If you know someone, let me know.

h1

New job and no task tracking make Dan something something

Monday, May 29th, 2006

So the big news is a new job for me! It’s pretty crazy, being the second week and all, but I’m still in the steep end of the learning curve. So I’ll let that discussion pass for now.

The thing that is really killing me though, is no JIRA. I had gotten so used to having JIRA there to organise myself/others in, that without it I am stuck with (gasp) actual to-do lists. The humanity! There’s an installation of Gemini somewhere that is disused; which as far as I can tell is a feature-clone of JIRA, but, well, it’s a bit of a mess really. Needs a good ol’ DELETE FROM TASKS WHERE 1=1 I think.

The upshot of this is that everyone in dev land is a bit unsure from day to day what is supposed to be happening, which inevitably leads to meetings. Oh meetings; stealer of time, destroyer of fun.

Gemini seems ok, don’t get me wrong, it’s just that to the untrained eye (aka non-technical folk) it’s a bit complicated. Which, seeing as the only way to placate the meeting monster is by making reports, that’s not good. I don’t want to trade the time I spent in meetings with the time generating reports. I’d like it if someone wanted to know how that thing that has to be done by the end of the week, you know, that thing, was going, they could just check.

Maybe JIRA is complicated to the untrained eye too. I dunno. But save me from meetings!

h1

The importance of open discussion in software development

Thursday, May 18th, 2006

I jsut finished reading an interview with Zed Shaw on O’Rielly called and I have to say it was very enlightening. It was interesting and encouraging to ‘hear’ him say: My motto here is “If I KMFU (Know My F*ing Users) they won’t have to RTFM.”

I think that this principle is so often overlooked in the programming world - and not just the Open Source world either. I can’t count the number of times that I’ve had a go at some program or other and just been lost without the docs. I do try to keep it simple for my stuff but sometimes you kinda get caught up in some idea (yours or someone else’s) and you end up implementing some crap that does the job, but that’s about it. It doesn’t ‘just work.’

This relates to something else I read today, called The Art of No. As professional coders on deadlines that usually ‘cannot move,’ there seems to be a strong inclination to say ‘no’ to any change request or feature enhancement. While this makes the deadline less distant, it makes the client/your superior/the user more distant and lowers your rapport with them all. After all, they’re paying you! So, the article above says “ask why,” so you open a dialogue into the problem and see the other side of the story.

I’ve found that telling them that “you’ll see what you can do” works wonders too. This has the following benefits:

  1. You can talk about why they want it done in a non-meeting format; the less structured the meeting the easier it is to get points across because you are less limited in time
  2. It gives you a chance to make sure that the feature they are asking for is not somehting that you were expected to build anyway
  3. You can discuss the impact on the timeline
  4. By not saying ‘no,’ you can get more work for yourself/company and thereby invoice more hours

This last point is important - none of us can work for free, but customers can sometimes forget that. Bring it back to the bottom line. Underlying this has to be a strong spec of some kind, or a time-and-materials (per hour) agreement though - otherwise there’s gonna be pain when you get to talking about what was supposed to be delivered at what tie for what cost. Get your ducks in a row at the start, and everything else is a lot simpler.