This is my Blog.

It's full of opinions on a wide range of stuff.

How To Fix Generating XMPie API Java Stubs With Metro

As a number of you are aware, I have spent quite a bit of time wrestling with XMPie uProduce SOAP API with the CXF service framework in Java. I finally (and with quite a lot of disappointment on my part) gave up trying to get that to work. CXF just does not want to play nice and I cant seem to make the XJB bindings work correctly with it and the mish-mash WSDL coming from uProduce

Anyway... with that rant over, I tried to be objective and switched to using Metro - ok, out of the box I still had a whole heap of problems, exactly as I did with CXF. However, I have managed to wangle it!

Step 1

You will need access to an XMPie server with the API's installed and working. For the sake of this example i just wget'd the WSDL file so the generation code was not so bloated.

Step 2

You'll need an XSD XJB binding file which looks like this:

<bindings xmlns:xjc="" xmlns="" xmlns:xsd="" version="2.0">


  <bindings scd="~xsd:complexType">
    <class name="ComplexTypeType"></class>

  <bindings scd="~xsd:simpleType">
    <class name="SimpleTypeType"></class>

  <bindings scd="~xsd:group">
    <class name="GroupType"></class>

  <bindings scd="~xsd:attributeGroup">
    <class name="AttributeGroupType"></class>

  <bindings scd="~xsd:element">
    <class name="ElementType"></class>

  <bindings scd="~xsd:attribute">
    <class name="attributeType"></class>

Save this as xsd.xjb (or whatever you like, just make sure the name is reflected in the command below)

Step 3

Actually generate the code! Your command might look different, but heres mine:

  wsimport -b \
    -b src/xjb/xsd.xjb \
    -keep \
    -s src/java \
    -d target \
    -p com.xmpie.wsapi.icp \

You should then see something like the following in your finder (or other OS file browser if not on mac):

These are the class files created for the InteractiveCampaign WSDL - all 128 of them!

Anyway, I have run out of time for today, but will try and get another blog up soon about how to use this in a client application from a java CLI.

blog comments powered by Disqus