How to publish the WebServicesClientProtocol.Invoke method

J

JC Voon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top