Tom
Tom

Reputation:

Using WCF with Excel 2003?

Does anyone know or can find some sample code showing how to call a WCF service using Excel 2003?

Upvotes: 4

Views: 2454

Answers (5)

Damian
Damian

Reputation: 4763

You might want to look at using the WCF Service Moniker which lets you invoke a WCF Service from VBA without installing anything on the Excel client machine other than the .NET Framework.

Dim addr As String
addr = "service:mexAddress=""net.tcp://localhost:7891/Test/WcfService1/Service1/Mex"","
addr = addr + "address=""net.tcp://localhost:7891/Test/WcfService1/Service1/"","
addr = addr + "contract=""IService1"", contractNamespace=""http://tempuri.org/"","
addr = addr + "binding=""NetTcpBinding_IService1"",bindingNamespace=""http://tempuri.org/"""

Dim service1 As Object
Set service1 = GetObject(addr)

MsgBox service1.GetData(12)

I've written out a complete step-by-step example.

/Damian

Upvotes: 1

Cwoo
Cwoo

Reputation: 355

REST services also work quite nicely with Excel.
If you use the "WebHttpBinding" you can import the data to excel using File -> Open or via Import External data -> Xml.
Isn't quite perfect with 2003 though (much better with 2007).

Upvotes: 0

Michael Dausmann
Michael Dausmann

Reputation: 4540

If you want to call WCF web services from Excel2003 and you dont want to use VSTO, you need a COM compatible option (No .Net).

Although it is Tooooootally deprecated (and uncool) you can achieve this using a basicHttpBinding on the server and the Soap Toolkit

If you dont want to do that, you may be able to do the calls using a .Net assembly and use COM Interop to call it from Excel.

Upvotes: 2

JP Alioto
JP Alioto

Reputation: 45117

I don't have the perfect winner for you, it's probably going to be difficult. Things got a lot better developing for Office 2007. But, given that, you should check out Visual Studio Tools for Office. Here are some examples using VSTO with Excel 2003. Here is an article on how to call WCF from an Office 2007 application. You should be able to adopt that with some success. GL. :)

Upvotes: 2

Mitch Wheat
Mitch Wheat

Reputation: 300559

This article targets accessing Web Services in Excel Using Visual Studio Tools for the Microsoft Office System, and the information should apply similarly to a WCF service.

Upvotes: 2

Related Questions