Ho creato correttamente un moniker di servizio come client per il servizio WCF. Ma non sono in grado di chiamare alcun metodo sul moniker.Errore di automazione durante il richiamo del metodo su WCF mex Moniker con Excel
Alla fine servizio WCF Ho un metodo fittizio chiamato TestMethod, come segue:
Public Function TestMethod(ByVal TestValue As String) As String Implements ICustomerService.TestMethod
Return "You said.... " & TestValue
End Function
codice seguente crea il 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
Il codice precedente funziona fino al GetObject
chiamata, il che implica che il moniker viene creato correttamente. Ma ricevo un errore non appena provo a chiamare qualsiasi metodo su di esso.
Il metodo WCF funziona perfettamente ok con Microsoft prova WCF client, e altri client WCF. Quindi so che non c'è alcun problema con il servizio stesso.