How to publish the WebServicesClientProtocol.Invoke method

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi:

I need your help, please read the following code:


* The actual WebService
Dim proxy As Microsoft.Web.Services2.WebServicesClientProtocol
= New CompanyProfileWS.CompanyProfileServiceWse


** The BusinessObject Base Class
Public Class ServiceProxy
Inherits Microsoft.Web.Services2.WebServicesClientProtocol

Public Shadows Function Invoke(ByVal methodName As String, ByVal
params As Object()) As Object()
Return MyBase.Invoke(methodName, params)
End Function
End Class

public class BusinessObjectBaseClass
Private m_Proxy as
Microsoft.Web.Services2.WebServicesClientProtocol
Private m_InnerDataSet as DataSet

public sub New(ws as
Microsoft.Web.Services2.WebServicesClientProtocol)
m_Proxy = ws
m_InnerDataSet = new DataSet
end sub

Public Overridable Sub RetrieveSchemaInfo()
Dim results() As Object = DirectCast(m_Proxy,
ServiceProxy).Invoke("RetrieveSchemaInfo", New Object(-1) {})
Dim xn As XmlNode = CType(results(0), XmlNode)

LoadDataSetFromXMLDocument(m_InnerDataSet,
XMLNodeToXMLDocument(xn))
End Sub
end class


And here is what i'm trying to do:

The actual WebService proxy will be create* and pass into the
BusinessObject class inherited from BusinessObjectBaseClass**
In the BusinessObjectBaseClass i need to invoke a method in the
WebService, since it is the base class, i don't know the
actual type of the WebService that passed in, so i've to use invoke to
call the webmethod, since the invoke method is protected,
i try to publish it using the ServiceProxy class, but when i cast the
actual web service to ServiceProxy it give me the
InvalidCastException

Any idea ? Please Help.

Thanks
JCVoon
.



Relevant Pages