Building SalesForce client stubs using CXF and Maven

As part of a project at work we’ve been migrating from using ANT scripts and maintaining our libraries manually to using maven both for the build and for library/dependency management.  As part of that project we have also been updating our libraries which some haven’t been updated in 4 years.  We have also decided to finally move off of Apache Axis for our web services both client and server services.  We decided on using JAX-WS and CXF specifically as the implementation.  The transition was not as smooth as I was hoping and I thought I’d post what worked for our situation.

The first thing is downloading our enterprise wsdl file and generating our client stubs.  In maven there is a cxf plugin for this purpose.  Below is a snippet from our POM.

...
<plugins>
...
<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>${cxf.version}</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-bindings-soap</artifactId>
      <version>${cxf.version}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
     <id>generate-sources</id>
     <phase>generate-sources</phase>
     <configuration>
       <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
       <wsdlOptions>
         <wsdlOption>
           <wsdl>${basedir}/src/main/resources/enterprise.wsdl</wsdl>
           <wsdlLocation>classpath:enterprise.wsdl</wsdlLocation>
           <extraargs>
             <extraarg>-b</extraarg>
             <extraarg>${basedir}/src/main/resources/javabindings.xml</extraarg>
             <extraarg>-autoNameResolution</extraarg>
             <extraarg>-exsh</extraarg>
             <extraarg>true</extraarg>
           </extraargs>
         </wsdlOption>
       </wsdlOptions>
     </configuration>
     <goals>
       <goal>wsdl2java</goal>
     </goals>
   </execution>
  </executions>
</plugin>
...
</plugins>
...

The reason for the dependency of cxf-rt-bindings-soap is because the exsh = true was not working until I included that dependency. The exsh was enabled so I had access to the headers. Unfortunately I was unable to cast to WSBindingProvider so I had to enable this option. I was unable to get the class loader to load the proper jars in the order I needed to avoid this for the container I was using. If you can avoid using exsh I’d recommend doing it, but in my case I had to enable it.

The javabindings.xml file was required for jaxb, so I didn’t need to call getValue or setValue on the SalesForce model objects.

<jaxb:bindings version="2.1" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
   <jaxb:globalBindings generateElementProperty="false"/> 
</jaxb:bindings>

The -autoNameResolution was required for SalesForce or you get name conflicts when attempting to build the client stubs. The version of cxf we were using is 2.4.2. Hopefully this will be helpful to someone else that might be building there web services in a similar manner.

New WordPress theme

ScreenshotI finally had a chance to play with WordPress some more and learn all the in and outs of building a theme.  I just updated this site with my first WordPress theme.  I figured since I was going to start with a new theme I might as well make the theme use HTML5.  If you’re browsing with an older browser the site might look a little square but should render correctly.  I mainly concentrated on the backend and font styles for this theme and I figured when I have a chance I’d work on adding some color to the site.  As it stands right now it’s very grey.  If you’re browsing the site and something looks rendered wrong please let me know.  I only have so many browsers on my computers to test it with.

I did notice that when I implemented the menu some of the built in functions for WordPress render completely differently if you are using the default menu vs using a custom menu.  Ended up adding some additional code in the functions.php to deal with that.  Other than that I think WordPress has done a great job with many of their APIs.

 

OS X Lion, initial impressions

After WWDC I really wanted to Apple’s new OS a try. Since there is no way I can move to a beta OS on my work computer I decided to give Lion at try on my personal MBP. I have a 13″ 2011 model with the i5 chip and 4 GB of ram. Since I have a desktop I can use until Lion ships I felt I really didn’t have much to lose.

I’ve been using it for just about over a week now and I’m pretty happy with it.  Mission Control and full screen apps are just killer. I’ve found that safari is have a few issues in full screen mode so I stopped using it in that mode. The way the gestures work with the multiple desktops are very useful. I was developing the theme for this site using one desktop for Dreamweaver and one for Safari/Firefox/Chrome and it was like having two monitors.

So far the one software I’ve had issues with is XMarks for Safari. I’m guessing support will be there when the OS ships next month. I haven’t had a chance to try out Xcode beyond loading it up and making sure it works, so I won’t comment on that.  So far the OS hasn’t crashed on me at all and I rarely turn off my computer. I mainly put it to sleep when I’m no longer using it.  I hope to do a follow up after the OS ships and it’s no longer a Developer preview. I will say that I will be purchasing this OS as soon as it has been released and for $30 why wouldn’t you.

 

WWDC 2011

Moscone West Convention CenterI had the opportunity through work to attend Apple’s Developer Conference this year.  This is my first time going and it was a lot of fun.  I was really impressed with what Apple announced. Since I’m under NDA I won’t discuss the specifics, but it looks like a lot of work that apple has been working on for a while is starting to come together. The only down side was the amount of time I had to spend waiting in long lines.
Line on Monday Morning for WWDC 2011I monday morning I got in line around 6 am and it was already wrapped around the building, I guess the first person got in line at 1 pm on Sunday. I can’t believe people would wait in line for that long, it’s just not worth it to be that close. There were lines to get in the building the first day but some of the better sessions were wrapped as well. Lines for the party on Thursday…

Speaking of the party on Thursday, as I expected the guy to girl ratio was pretty bad.  Guessing I’d say it was 100:1. It was so bad that the band Apple got to perform made a comment about it.

I learned a lot about various Apple technologies and I can see using many of items discussed in existing and new projects.  I can’t wait until Apple releases everything. If I get a chance, I’ll post more about the technologies that I’ve had a chance to play with so far.  Personally I think Apple is quite ahead of their competition at this point.

Over the air broadcasts

Back in October of 2010 I decided to try to see if I could cancel my cable and switch to Netfix and over the air broadcasts.  Believe it or not my wife was the one who first proposed the idea.  I did some research and started by buying a digital antenna.  I did my research and where I’m located I was going to have a hard time getting reception so I thought I’d buy an inexpensive indoor antenna and see how that went.

I ended up going with the Terk HDTVa HDTV antenna, it got high marks on a lot of review sites and wasn’t that expensive.  None of the TVs in my house have a digital tuner and I never got the rebate the government was giving out during the digital switch over.  So instead I decided to buy a TV Tuner card since I was going to need a DVR anyways.  Since this was an experiment I went with a WinTV-HVR-950Q.

My initial tests were mixed.  From my house I was able to get all the channels, but I needed to adjust the antenna for a select group of stations and adjusted it again to get the remaining stations.  I hoped that putting it up in the attic might solve that issue.  I ended up putting the project on hold until December because of Grad school.  I figured I was going to need to do some major re-working of the wiring in my house to get the antenna up into the attic.

Because I still wanted to keep AT&T U-Verse internet and just ditch the cable portion of the plan, it meant I was going to have to move the Residential Gate way from one location of the house to another.  Because it was coming in to the house through the coax, I was going to need to have some coax going to the U-verse connection on the side of the house and the rest of the coax in the house would need to go to the TVs.  The plan ended up being to have the front bedroom have the coax going to U-verse and then adding a wired network to move that through the rest of the house.  So I decided I was going to need to run some Category 6 cable through the attic that would connect the internet to the TVs as well.

Networking the house ended up being a project just by itself, but it was worth it.  I needed to run two cables from each location: two in the from bedroom with the U-verse gateway, two in the living room and two to the master bedroom.  All the lines terminated in the master bedroom’s walk-in-closet.  From there I used an old 10/100 switch I had lying around from my LAN party days to link it all together.   One bonus to this setup is that it allowed me to centralize my wireless router.  Once the network was in place I needed to move the antenna to the attic and run coax from the antenna to the cable box on the side of the house.  I did this because I hate going up in the attic and if I need to switch the wires I’d rather just go to one place.

I found the compass directions from AntennaWeb and TVFool on where to point my antenna.  TVFool ended up being the more accurate source, but I did make one mistake.  I lined up the antenna with a compass but used the true north instead of the magnetic north.  After a couple of days of fiddling with the antenna and I finally got every station I wanted in.  The only thing left was to decided what I was going to use as a DVR.  I looked at purchasing a DVR, Avsforums was a good resource for information on DVRs.  But since I was trying to do this entire project for as cheap as I could get it, I decided on recycling my old desktop and using it as a DVR.

I tried using the Hauppauge software with Windows XP initially but it was far to slow and choppy when recording.  Since I didn’t have a license for Windows XP with media center and I wasn’t about to use one of my windows 7 laptops as a full time DVR, I decided to go with Ubuntu and putting MythTV on it.  It was a pain to configure and setup, but once it was done it worked very well.  After about one and a half weeks running tests my 5 year old hard drive died.  I pulled out a external backup drive that I was no longer using and through that in instead.  Instead of installing and reconfiguring from scratch I decided to go with Mythbuntu instead.  It still look almost as long to configure but it left me with a much better environment.

The plan was to leave the system running in parallel with U-verse cable for a month and see how it goes, but after two weeks my wife said let’s make the switch.  So far we’ve been off of cable since the end of January without a single complaint.  I never really watched much TV and the shows we couldn’t get through broadcast we got from a combination of Amazon Video on demand and Netflix.  So far I’d say the project has been a success and has almost payed for itself in the savings from not having to pay for cable.  It was a lot of work but in the end I believe it was worth it.