How do I call WCF client from Excel 2003 VBA?
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 Stringaddr = "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 ObjectSet service1 = GetObject(addr)MsgBox service1.GetData(12)
I've written out a complete step-by-step example.
/Damian
I tried for quite a while to call a SOAP based wcf service from excel vba without any luck.
Instead I changed my service to REST binding (webHttpBinding). That way I could load the data stright into an xml map like it was any other xml file. Worked well for me, but I was only trying to import some data.
As for SOAP; an answer in this question mentions the Web Services Toolkit all the examples I could find suggested to use.
I wouldn't use VSTO in this case. COM Interop is probably the best way to go, so long as you don't want any security in your SOAP messages.
- Write WCF client, with necessary binding
- Expose assembly for COM Interop
- Reference exposed assembly in Excel VBA