Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2007

Tip: Looking for answers? Try searching our database.

Webservice inheriting from interface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lopamudra - 14 Mar 2007 09:52 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.