views:

1368

answers:

7

I am tasked with writing an application to connect to the DoubleClick DART API and download ad creatives.

The API is currently Java only, but they are working on (eventually) releasing a SOAP version.

As a C# developer, I'd like to write the application in C# and access the Java API, until the SOAP API is available.

Can I do this? If so, how?

If not, I will learn Java, write the application, then redo it when the SOAP API is available, but this isn't the preferred course of action.

Thanks for the help.

+1  A: 

Is this a web-services API, or a JAR file that you've been provided? In the latter case, J# may be an option, and there's some other bridging options in this thread: http://www.velocityreviews.com/forums/t140810-java-c-interop.html

Don Werve
A: 

As an aside may I recommend writing your web service in a RESTful way, rather (or in conjunction with) then SOAP? The benefit will be interoperability between any language that you may want to consume your service in the future, rather then only ones that can generate code based on WSDL. Just a thought.

Gandalf
+1  A: 

Yes, you can do this and we had to do something pretty similar a while back.

The Doubleclick API is Java based and is essentially a collection of methods to interrogate the database.

What you need to do is wrap these methods inside a web service using something like Axis2 and then deploy the web service to a Tomcat server (all of this is open source). That exposes the web service and you can then call the web service from anything you like.

So in your case, you add a web service reference inside Visual Studio and then your C# class will call the web service which invokes the Doubleclick Java method.

The actual Java code is minimal (aprox. 10 lines) since all it does is a call and then formats the output. It takes longer to deploy than it does to write the code!

Our Java development environment is Eclipse and I blogged about it here.

nzpcmad
A: 

I would say that using a J# layer might be a good option. I've only used it once a while back, but it did the trick for me.

deeringc
A: 

IKVM.NET might be your solution. It is a Java Virtual Machine which translates Java bytecode to .NET IL.

What you can do is to compile the Java API (provided as jar or source files) using ikvmc.exe into a .NET assembly and then reference this assembly from your C# project.

IKVM does have limited support for Java user interfaces (AWT), but since it is an API, this shouldn't be relevant.

I haven't tried this by myself, so I can't guarantee that this really works.

See http://weblog.ikvm.net/story.aspx/faq

Meinersbur
A: 

We actually went with a slightly different way of doing this.

  1. The C# web service now calls the Java class with javaw.exe (using Process) and passes in an id (GUID).
  2. The GUID is used as a filename for an XML file that is written by the java class.
  3. If the process (javaw) ends without error, the web service then opens the (GUID).xml file and retrieves the data.

While this is not the optimal method, it works for this process in the short term, and in the long term, when a SOAP solution becomes available, the web service is easily updated.

Paige Watson
A: 

Forget the Java DART API and switch to this new WebService API approach:

http://doubleclickadvertisers.blogspot.com/2009/06/webservices-api-jun-2nd-2009-release.html

aalvaradoh
This is what I have been waiting for!!!
Paige Watson