Calling WCF from VBA through Metadata Exchange Contract RRS feed

  • Question

  • Hi Friends,

    I have created the WCF service and was able to call that services from VBA through Metadata exchange contract with the help of below snippet. The reason why it is working is because [OperationContract]  double Multiply(double n1, double n2);  has primitive data type (int,string, double etc) as return type and argument. But If i have any complex type (like class, Data contracts) as argument or return type it is failing.

    If not possible, Can some one show me the msdn link saying that it is not possible to use WCF moniker call  involving data contracts ?

    ' Create a string for the service moniker specifying the address to retrieve the service metadata from
    mexMonikerString = "service4:mexAddress='http://localhost/servicemodelsamples/service.svc/mex'"
    mexMonikerString = mexMonikerString + ", address='http://localhost/ServiceModelSamples/service.svc'"
    mexMonikerString = mexMonikerString + ", binding=WSHttpBinding_ICalculator, bindingNamespace='http://Microsoft.ServiceModel.Samples'"
    mexMonikerString = mexMonikerString + ", contract=ICalculator, contractNamespace='http://Microsoft.ServiceModel.Samples'"
    ' Create the service moniker object
    Set mexServiceMoniker = GetObject(mexMonikerString)
    WScript.Echo "MEX service moniker: 9 * 81.25 = " & mexServiceMoniker.Multiply(9, 81.25)

    Error it throws is : "Type load exception". Can somebody help me? Thanks


    Thursday, July 4, 2013 9:11 AM

All replies

  • Hi, what do you mean with "use WCF moniker call  involving data contracts ", can you give an example?

    Check a thread hope it helps.

    Friday, July 5, 2013 6:27 AM
  • Hi Nico,

    For ex if I have Data contracts of class. For instance, In the below example you can see that my operational contract involves complex type like data class object.

    You can refer my question to check how i am using moniker string from VBA. Please let me know if you have any question.

        void SubmitData(Data data);

    public class Data
    public int Id;
    public DateTime LockTime;
    public DateTime LoginTime;
    public DateTime LastDefenitionDate;
    public string NTLogin;
    public string SystemName;


    Friday, July 5, 2013 9:14 AM
  • Hi Nandakumar,

    For WCF service that uses complex class, you might consider using the "Typed Contract" approach mentioned in the MSDN reference. That way, the standard .NET service proxy and data contract types are exposed to VBA application via COM interfaces. But, the drawback is that the client need to explicitly register the wrapped COM component before using the service.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 2, 2013 1:49 AM