views:

35

answers:

3

I have a WCF webservice running that has 2 endpoints (mex and wsHttpBinding). The webservice is hostend on the address: http://localhost:2412/Service1.svc and its contact is named "WcfService1.IService1"

I want to call this service from VBA in Excel. To that, I use the folowing code:

mexMonikerString = "service:mexAddress='http://localhost:2412/Service1.svc/mex'"
mexMonikerString = mexMonikerString + ", address='http://localhost:2412/Service1.svc'"
mexMonikerString = mexMonikerString + ", binding=WSHttpBinding_IService1"
mexMonikerString = mexMonikerString + ", contract=IService1"

Set service = GetObject(mexMonikerString)

When I try to execute this code I recieve the folowing Excel error message: Run-time error '-2147221020 (800401e4)'

Does anybody know what the cause of this error is and how I can resolve it?

+2  A: 

You can try to publish WCF service in your IIS.

NetSide
+1  A: 

Have a look at Calling WCF Services from Excel VBA clients using the WCF Service Moniker. It has a section on debugging that shows the same error code you are receiving and how to get the actual error description('Interface not found' in this case).

DaveB
Using the debuging method described in link solved the problem. There was a problem with the specification of the WCF interface
MuSTaNG
I have now also wrote an article about (debugging) WCF services and VBA code, in which I introduce an alternative to using the Visual Studio debugger http://pieterderycke.wordpress.com/2010/10/05/using-a-service-moniker-to-communicate-between-legacy-com-applications-and-new-net-applications/
MuSTaNG