Hi,
I have a webservice which inherits additionally from an interface. This
webservice provides implementation for the methods in the interface as well
as provides addtiional methods.
One of the methods of my assembly takes as parameter a type of the
interface. My webservice instance should be passed as the value for this
parameter. However, I am getting an Invalid Cast Exception.
I have posted the code below:
MyWebservice.asmx:
using myInterfaceAssembly; //Contains the interface
public class MyWebservice : System.Web.Services.WebService, myInterface {
public MyWebservice()
{ }
[WebMethod]
public string getUserName(string userID) {
return ("xxx"); //Simplified the code for posting in forum
}
}
myWebform.aspx:
MyMethod signature:
MyMethod(System.Web.UI.Page ,
myInterfaceAssembly.myInterface);
MyMethod call:
MyMethod(this, new MyWebservice()); //Call to my method,
passing webservice instance
This cast is cuasing issue. Any inputs?
Regards
Lopa
John Saunders - 14 Mar 2007 19:16 GMT
> Hi,
>
[quoted text clipped - 36 lines]
>
> This cast is cuasing issue. Any inputs?
I'm really not sure what you're doing here. Are the web site and the web
service on the same machine? Are they in the same application?
If not, then perhaps the web site has a Web Reference to the web service? If
so, take a look at the Reference.cs file under the Web Reference (you need
to do Show All Files in order to see it). Look at the definition of the
proxy class for the web service, and I bet you'll find that it does not show
your interface.
Interfaces are one of the many platform-specific features that don't
translate into web services. If this is what you're trying to do, then you
need another way of doing it.
John