Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   Webservice inheriting from interface (http://www.velocityreviews.com/forums/t786968-webservice-inheriting-from-interface.html)

Lopamudra 03-14-2007 08:52 AM

Webservice inheriting from interface
 
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 03-14-2007 06:16 PM

Re: Webservice inheriting from interface
 
"Lopamudra" <Lopamudra@discussions.microsoft.com> wrote in message
news:255A68D3-8243-4E84-A143-1332C31B266F@microsoft.com...
> 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?


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




All times are GMT. The time now is 04:58 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.