Error Compiling Salesforce Metadata API with WSC

July 1st, 2010

This might not be relevant right now but you may find it useful in the near future. I’m tinkering with an app that spits out documentation for an org. I really hate doing documentation and am quite lazy so I thought I’d write something to allow my computer to do my work for me.

I ran into a small issue when trying to compile the Metadata WSDL with the Force.com Web Services Connector so I thought I’d post my fix.

So to use the Metadata API with the WSC, first download the Metadata WSDL from your org and the latest WSC jar from the project. Now issue something like the following to generate the stub code from the WSDL:

java -classpath wsc-19.jar com.sforce.ws.tools.wsdlc metadata.wsdl metadata.jar

Unfortunately this results in an error similar to:

-dir/com/sforce/soap/metadata/Encoding.java:12: ‘} ‘ expected UTF-8,


The error is thrown because the WSDL contains some hyphens that is making the compiler puke. You can fix the issue by replacing the hyphens in the Metadata WSDL with underscores, saving the WSDL and then compiling the stub code again.

Here’s the offending portion of the Metadata WSDL.


Categories: Code Sample, Java, Salesforce

Leave a comment

Comments Feed3 Comments

  1. Phil

    Related bug report:
    http://code.google.com/p/sfdc-wsc/issues/detail?id=2

  2. Wes

    Most interesting Mr D. And what’s “and I’m lazy” all about? You are the very antithesis.

  3. Abhinav

    Helpful post, it saved my time :)

Leave a comment

Feed

http://blog.jeffdouglas.com / Error Compiling Salesforce Metadata API with WSC

WordPress Appliance - Powered by TurnKey Linux