I successfully created a service moniker as client for my WCF service. But I'm unable to call any method on the moniker.
At the WCF service end I have a dummy method named TestMethod, as follows:
Public Function TestMethod(ByVal TestValue As String) As String Implements ICustomerService.TestMethod
Return "You said.... " & TestValue
End Function
Following code creates the Moniker in Excel.
Public Sub WCFMexMonkierDemo()
' Create a string for the service moniker including the content of the WSDL contract file
Dim mexMonikerString As String
mexMonikerString = "service:mexAddress='http://localhost/CustomerService.svc/mex'" & _
", address='http://localhost/CustomerService.svc'" & _
", binding=CustomerServices.CustomerService" & _
", bindingNamespace='http://tempuri.org/'" & _
", contract=ICustomerService" & _
", contractNamespace='http://tempuri.org/'"
' Create the service moniker object
Dim mexMoniker, result
Set mexMoniker = GetObject(mexMonikerString)
result = mexMoniker.TestMethod("client call") '<-- error on this line
'Set result = mexMoniker.TestMethod("client call")
MsgBox result
Set mexMoniker = Nothing
Set result = Nothing
End Sub
The above code works upto the GetObject
call, which implies that the moniker is successfully created. But I get an error as soon as I try to call any Method on it.
The WCF method works perfectly ok with Microsoft WCF Test Client, and other WCF clients. So I know there is no problem with the service itself.