Web Service Proxy Generator
.NET Web Service Proxy Generator Method Not Found
Gravatar is a globally recognized avatar based on your email address. .NET Web Service Proxy Generator Method Not Found
  EllisG
  All
  Feb 25, 2020 @ 06:21pm

Experts, How to resolve the "method not found error"? Please see attached images. Many thanks, Ellis

Gravatar is a globally recognized avatar based on your email address. re: .NET Web Service Proxy Generator Method Not Found
  Rick Strahl
  EllisG
  Feb 25, 2020 @ 11:53pm

You can't pass Long or Int64 values directly from FoxPro. You'll need to use a ComValue object to represent those values and use loBridge.InvokeMethod() to call the method.

Class ComValue

You'll have to do this for any types that FoxPro and COM can't automatically convert. Looks like you have a bunch of Int64 parameters, so you'll have to do something like the above for each of those.

Also, I can't tell what the Logon type is, but it is likely an object so you have to create that first and assign properties to that object.

loBridge = loProxy.oBridge    && wwDotnetBridge instance
loService = loProxy.oService  && actual .NET object reference

*** Create a Logon object and set properties
loLogon = loBridge.CreateInstance("Service1.Logon")
loLogon.Username = "bill"
loLogon.Password = "seekrit"

*** Create a Int64 Parameter to pass to method
LOCAL loVal, loVal2 as Westwind.WebConnection.ComValue
loVal = loBridge.CreateComValue()
loVal.SetInt64(11)

loVal2 = loBridge.CreateComValue()
loVal2.SetInt64(9132223131231213412)

*** Call method that takes Int64 parameter
loBridge.InvokeMethod(loService,"ControlDevice",loLogon, loVal,.t., loVal2)  

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: .NET Web Service Proxy Generator Method Not Found
  EllisG
  Rick Strahl
  Feb 26, 2020 @ 06:26am

Many thanks Rick! Any thoughts why wwdotnetbrige.prg is crashing during loBridge.InvokeMethod()? Debugger shows lnx = 1 and laParms.Count = 16.

SUSPEND
DO wwDotNetBridge
SET PROCEDURE TO service1proxy ADDITIVE

*** Load Proxy Class and Dependencies
DO service1proxy

*** Create Proxy Instance & specify .NET version
loProxy = CREATEOBJECT("Service1Proxy","V4")

loBridge = loProxy.oBridge    && wwDotnetBridge instance
loService = loProxy.oService  && actual .NET object reference

*** Create a Logon object and set properties
loLogon = loBridge.CreateInstance("Service1.Logon")
loLogon.LogonType = 0
loLogon.Username = "admin"
loLogon.Password = "admin"

*** Create a Int64 Parameter to pass to method
LOCAL loVal, loVal2, loVal3, loVal4, loVal5, loVal6, loVal7 as Westwind.WebConnection.ComValue
loVal = loBridge.CreateComValue()
loVal.SetInt64(2)
loVal2 = loBridge.CreateComValue()
loVal2.SetInt64(3)
loVal3 = loBridge.CreateComValue()
loVal3.SetInt64(4)
loVal4 = loBridge.CreateComValue()
loVal4.SetInt64(6)
loVal5 = loBridge.CreateComValue()
loVal5.SetInt64(2)
loVal6 = loBridge.CreateComValue()
loVal6.SetInt64(0)
loVal7 = loBridge.CreateComValue()
loVal7.SetInt64(0)

*** Call method that takes Int64 parameter
loBridge.InvokeMethod(loService,"ControlDevice",loLogon, loVal, .t., loVal2, .t., loVal3, .t., loVal4, .t., loVal5, .t., loVal6, .t., loVal7, .t., .t.) 

MESSAGEBOX(loProxy.cErrorMsg)

*=====================================================================================================
*=====================================================================================================
#IF .F.  && For reference, here is the ControlDevice function from Server1Proxy.prg to show parameters
************************************************************************
*  ControlDevice
****************************************
FUNCTION ControlDevice(LD as Logon,nSiteID as Int64,nSiteIDSpecified as Boolean,nControllerID as Int64,nControllerIDSpecified as Boolean,nControlType as Int64,nControlTypeSpecified as Boolean,nControlIndex as Int64,nControlIndexSpecified as Boolean,nControlOperation as Int64,nControlOperationSpecified as Boolean,ref_nErrorCode as Int64,ref_nErrorCodeSpecified as Boolean,list as Int64Array,ref_ControlDeviceResult as Boolean,ref_ControlDeviceResultSpecified as Boolean) as Void
LOCAL loException as Exception, lvResult as Void

THIS.lError = .F.
this.cErrorMsg = ""

lvResult = .F.
TRY	
	lvResult = this.oBridge.InvokeMethod(this.oService, "ControlDevice", LD,nSiteID,nSiteIDSpecified,nControllerID,nControllerIDSpecified,nControlType,nControlTypeSpecified,nControlIndex,nControlIndexSpecified,nControlOperation,nControlOperationSpecified,ref_nErrorCode,ref_nErrorCodeSpecified,list,ref_ControlDeviceResult,ref_ControlDeviceResultSpecified)
	
CATCH to loException
	THIS.GetErrorDetail(loException)
ENDTRY

RETURN lvResult
ENDFUNC
*   ControlDevice
#ENDIF
Gravatar is a globally recognized avatar based on your email address. re: .NET Web Service Proxy Generator Method Not Found
  Rick Strahl
  EllisG
  Feb 26, 2020 @ 11:40am

InvokeMethod() only supports up to 10 parameters.

Not really sure why it's failing there based on what you're saying here, but I'm guessing the type of the parameter object is not correct. Either way InvokeMethod() is not going to work with 16 parameters.

For that many parameters you need to use InvokeMethod_ParameterArray().

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: .NET Web Service Proxy Generator Method Not Found
  Rick Strahl
  EllisG
  Feb 26, 2020 @ 11:48am

Actually I take that back - it looks like InvokeMethod() is supposed to be able to handle more parameters and automatically call InvokeMethod_ParameterArray(). I can't see why this is breaking but I'm going to take a look.

In the meantime it might still be useful to call InvokeMethod_ParameterArray() directly.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: .NET Web Service Proxy Generator Method Not Found
  EllisG
  Rick Strahl
  Feb 26, 2020 @ 06:07pm

Thanks Rick, I changed my program to use InvokeMethod_ParameterArray(), yet the method is being executed again from wwdotnetbridge.prg and unable to find the Control Device method? What am I doing wrong?

*SUSPEND
DO wwDotNetBridge
SET PROCEDURE TO service1proxy ADDITIVE

*** Load Proxy Class and Dependencies
DO service1proxy

*** Create Proxy Instance & specify .NET version
loProxy = CREATEOBJECT("Service1Proxy","V4")

loBridge = loProxy.oBridge    && wwDotnetBridge instance
loService = loProxy.oService  && actual .NET object reference

*** Create a Logon object and set properties
loLogon = loBridge.CreateInstance("Service1.Logon")
loLogon.LogonType = 0
loLogon.Username = "admin"
loLogon.Password = "admin"

*** Create a Int64 Parameter to pass to method
LOCAL loVal, loVal2, loVal3, loVal4, loVal5, loVal6, loVal7 as Westwind.WebConnection.ComValue
loVal = loBridge.CreateComValue()
loVal.SetInt64(2)
loVal2 = loBridge.CreateComValue()
loVal2.SetInt64(3)
loVal3 = loBridge.CreateComValue()
loVal3.SetInt64(4)
loVal4 = loBridge.CreateComValue()
loVal4.SetInt64(6)
loVal5 = loBridge.CreateComValue()
loVal5.SetInt64(2)
loVal6 = loBridge.CreateComValue()
loVal6.SetInt64(0)
loVal7 = loBridge.CreateComValue()
loVal7.SetInt64(0)

*** Call method that takes Int64 parameter
*loBridge.InvokeMethod(loService,"ControlDevice",loLogon, loVal, .t., loVal2, .t., loVal3, .t., loVal4, .t., loVal5, .t., loVal6, .t., loVal7, .t., .t.) 

DIMENSION aParams[16]
aParams[1] = loLogon
aParams[2] = loVal
aParams[3] = .T.
aParams[4] = loVal2
aParams[5] = .T.
aParams[6] = loVal3
aParams[7] = .T.
aParams[8] = loVal4
aParams[9] = .T.
aParams[10] = loVal5
aParams[11] = .T.
aParams[12] = loVal6
aParams[13] = .T.
aParams[14] = loVal7
aParams[15] = .T.
aParams[16] = .T.

loBridge.InvokeMethod_ParameterArray(loService,"ControlDevice",@aParams) 

MESSAGEBOX(loProxy.cErrorMsg)

Gravatar is a globally recognized avatar based on your email address. re: .NET Web Service Proxy Generator Method Not Found
  Rick Strahl
  EllisG
  Feb 27, 2020 @ 11:40am

Ok, that's a different error and it's due to the message signature not matching the parameters passed. .NET has to match your method call to the exact signature of a method, so this error can be misleading. The error should be more like can't find the ControlDevice() with these parameters you passed.

Make sure you count your parameters and they match up EXACTLY to the parameter signature of the method you're calling (from Reflector).

It shouldn't really make a difference but can you try - instead of using the array - using a ComArray to pass the parameters:

loParms = loBridge.CreateArray("System.Object")
loParms.AddItem(loLogin)
loParms.AddItem(val1)
loParms.AddItem(.T.)
...

lvResult = loBridge.InvokeMethod_ParameterArray(loService,"ControlDevice",loParms)

Again make sure the parameters passed match the exact parameter signature of the method as shown in Reflector.

+++ Rick ---

© 1996-2020