Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Need help using an abstract WebMethod

Need help using an abstract WebMethod

Scheduled Pinned Locked Moved C#
helpwcfsecurityquestionworkspace
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Snowblind37
    wrote on last edited by
    #1

    Before I pull out my hair out, throw the computer out the window, step on the neighbours cat, drive my car over the cliff or all of the above......I thought maybe I could ask for some help. The concept is simple....or so it would seem. I want to call a WebMethod with my credentials and get the information about my account back. Hmmm, should be a piece of cake. The problem is that the class created by wsdl.exe is an abstract class with abstract methods. So I created a class that implements those methods using override. Here is the basic setup: The abstract class created by wsdl [System.Web.Services.WebServiceBindingAttribute(Name="AccountsSoap", Namespace="http://address")] public abstract class ServiceAccounts : System.Web.Services.WebService { [System.Web.Services.WebMethodAttribute()] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://address/QueryProfile", RequestNamespace="http://address", ResponseNamespace="http://address", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public abstract AccountProfile QueryProfile(Credentials credentials); } The class to implement [WebService(Name="ServiceAccounts",Description="Provides a callback mechanism",Namespace="http://address/accounts")] public class AccountsImpl : Project.App.Tls.Accounts.ServiceAccounts { [WebMethod(MessageName="QueryProfile",Description="Gets the profile of the specified client.",EnableSession=false)] public override AccountProfile QueryProfile(Credentials credentials) { //What do I put in here? } And finally the call private void sendButton_Click(object sender, System.EventArgs e) { CredentialCache myCache = new CredentialCache(); NetworkCredential netCred = new NetworkCredential("name1", "pwd1", "domain"); ((CredentialCache) myCache).Add(destUri, "NTLM", netCred); ((CredentialCache) myCache).Add(destUri, "negotiate", netCred); ((CredentialCache) myCache).Add(destUri, "digest", netCred); accounts.credentials.Account = "name2"; accounts.credentials.Password = "pwd2"; accountProfile = accounts.QueryProfile(accounts.credentials); } Now, I'm sure you are all wondering what my problem is....My problem is that I don't know what to put in my implementation of QueryProfile() to make it call the webMethod. All of the implementations I have seen say to create a new object o

    U L S 3 Replies Last reply
    0
    • S Snowblind37

      Before I pull out my hair out, throw the computer out the window, step on the neighbours cat, drive my car over the cliff or all of the above......I thought maybe I could ask for some help. The concept is simple....or so it would seem. I want to call a WebMethod with my credentials and get the information about my account back. Hmmm, should be a piece of cake. The problem is that the class created by wsdl.exe is an abstract class with abstract methods. So I created a class that implements those methods using override. Here is the basic setup: The abstract class created by wsdl [System.Web.Services.WebServiceBindingAttribute(Name="AccountsSoap", Namespace="http://address")] public abstract class ServiceAccounts : System.Web.Services.WebService { [System.Web.Services.WebMethodAttribute()] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://address/QueryProfile", RequestNamespace="http://address", ResponseNamespace="http://address", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public abstract AccountProfile QueryProfile(Credentials credentials); } The class to implement [WebService(Name="ServiceAccounts",Description="Provides a callback mechanism",Namespace="http://address/accounts")] public class AccountsImpl : Project.App.Tls.Accounts.ServiceAccounts { [WebMethod(MessageName="QueryProfile",Description="Gets the profile of the specified client.",EnableSession=false)] public override AccountProfile QueryProfile(Credentials credentials) { //What do I put in here? } And finally the call private void sendButton_Click(object sender, System.EventArgs e) { CredentialCache myCache = new CredentialCache(); NetworkCredential netCred = new NetworkCredential("name1", "pwd1", "domain"); ((CredentialCache) myCache).Add(destUri, "NTLM", netCred); ((CredentialCache) myCache).Add(destUri, "negotiate", netCred); ((CredentialCache) myCache).Add(destUri, "digest", netCred); accounts.credentials.Account = "name2"; accounts.credentials.Password = "pwd2"; accountProfile = accounts.QueryProfile(accounts.credentials); } Now, I'm sure you are all wondering what my problem is....My problem is that I don't know what to put in my implementation of QueryProfile() to make it call the webMethod. All of the implementations I have seen say to create a new object o

      U Offline
      U Offline
      User 2028214
      wrote on last edited by
      #2

      Hmmm...off the top of my head try openning the ServiceAccounts class and removing the WebService base class as well as the attributes and the public and abstract modifiers from the methods the get an interface and using it that way?

      S 1 Reply Last reply
      0
      • U User 2028214

        Hmmm...off the top of my head try openning the ServiceAccounts class and removing the WebService base class as well as the attributes and the public and abstract modifiers from the methods the get an interface and using it that way?

        S Offline
        S Offline
        Snowblind37
        wrote on last edited by
        #3

        I would love to modify the class to make it easier for me. The point is that this is the way it is and will be for other people that access this service(others have been able to do this successfully). My job is to find a way to do this easily and document the procedure. There has to be a way. Definately CodeBlind37

        1 Reply Last reply
        0
        • S Snowblind37

          Before I pull out my hair out, throw the computer out the window, step on the neighbours cat, drive my car over the cliff or all of the above......I thought maybe I could ask for some help. The concept is simple....or so it would seem. I want to call a WebMethod with my credentials and get the information about my account back. Hmmm, should be a piece of cake. The problem is that the class created by wsdl.exe is an abstract class with abstract methods. So I created a class that implements those methods using override. Here is the basic setup: The abstract class created by wsdl [System.Web.Services.WebServiceBindingAttribute(Name="AccountsSoap", Namespace="http://address")] public abstract class ServiceAccounts : System.Web.Services.WebService { [System.Web.Services.WebMethodAttribute()] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://address/QueryProfile", RequestNamespace="http://address", ResponseNamespace="http://address", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public abstract AccountProfile QueryProfile(Credentials credentials); } The class to implement [WebService(Name="ServiceAccounts",Description="Provides a callback mechanism",Namespace="http://address/accounts")] public class AccountsImpl : Project.App.Tls.Accounts.ServiceAccounts { [WebMethod(MessageName="QueryProfile",Description="Gets the profile of the specified client.",EnableSession=false)] public override AccountProfile QueryProfile(Credentials credentials) { //What do I put in here? } And finally the call private void sendButton_Click(object sender, System.EventArgs e) { CredentialCache myCache = new CredentialCache(); NetworkCredential netCred = new NetworkCredential("name1", "pwd1", "domain"); ((CredentialCache) myCache).Add(destUri, "NTLM", netCred); ((CredentialCache) myCache).Add(destUri, "negotiate", netCred); ((CredentialCache) myCache).Add(destUri, "digest", netCred); accounts.credentials.Account = "name2"; accounts.credentials.Password = "pwd2"; accountProfile = accounts.QueryProfile(accounts.credentials); } Now, I'm sure you are all wondering what my problem is....My problem is that I don't know what to put in my implementation of QueryProfile() to make it call the webMethod. All of the implementations I have seen say to create a new object o

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Snowblind37 wrote: But since both the ServiceAccounts and the ServiceAccounts.QueryProfile() are both abstract, I cannot create a reference to them. Create an instance of AccountsImpl. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

          S 1 Reply Last reply
          0
          • L leppie

            Snowblind37 wrote: But since both the ServiceAccounts and the ServiceAccounts.QueryProfile() are both abstract, I cannot create a reference to them. Create an instance of AccountsImpl. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

            S Offline
            S Offline
            Snowblind37
            wrote on last edited by
            #5

            I already am creating the AccountsImpl instance. But the AccountImpl.QueryProfile() still needs to return a value that will come from the webMethod QueryProfile(). This is a main part of the complication.

            S 1 Reply Last reply
            0
            • S Snowblind37

              I already am creating the AccountsImpl instance. But the AccountImpl.QueryProfile() still needs to return a value that will come from the webMethod QueryProfile(). This is a main part of the complication.

              S Offline
              S Offline
              Snowblind37
              wrote on last edited by
              #6

              You guys are not going to believe this! When I ran my wsdl.exe I used the server option when I really wanted the client version. It all makes sense now. I had been trying to look from the other side of an abstract class and could not find a way to make it work. And for good reason because an abstract class is designed to give you ways to implement methods with the same name but with different logic......Not to implement a method to use an abstract method to use varying implementations of a method Talk about a trip outside the box. I will learn from now on to always take a walk around the box before I bang my head on the inside. Feeling slightly less CodeBlind today. Happy Coding All!!!!

              1 Reply Last reply
              0
              • S Snowblind37

                Before I pull out my hair out, throw the computer out the window, step on the neighbours cat, drive my car over the cliff or all of the above......I thought maybe I could ask for some help. The concept is simple....or so it would seem. I want to call a WebMethod with my credentials and get the information about my account back. Hmmm, should be a piece of cake. The problem is that the class created by wsdl.exe is an abstract class with abstract methods. So I created a class that implements those methods using override. Here is the basic setup: The abstract class created by wsdl [System.Web.Services.WebServiceBindingAttribute(Name="AccountsSoap", Namespace="http://address")] public abstract class ServiceAccounts : System.Web.Services.WebService { [System.Web.Services.WebMethodAttribute()] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://address/QueryProfile", RequestNamespace="http://address", ResponseNamespace="http://address", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public abstract AccountProfile QueryProfile(Credentials credentials); } The class to implement [WebService(Name="ServiceAccounts",Description="Provides a callback mechanism",Namespace="http://address/accounts")] public class AccountsImpl : Project.App.Tls.Accounts.ServiceAccounts { [WebMethod(MessageName="QueryProfile",Description="Gets the profile of the specified client.",EnableSession=false)] public override AccountProfile QueryProfile(Credentials credentials) { //What do I put in here? } And finally the call private void sendButton_Click(object sender, System.EventArgs e) { CredentialCache myCache = new CredentialCache(); NetworkCredential netCred = new NetworkCredential("name1", "pwd1", "domain"); ((CredentialCache) myCache).Add(destUri, "NTLM", netCred); ((CredentialCache) myCache).Add(destUri, "negotiate", netCred); ((CredentialCache) myCache).Add(destUri, "digest", netCred); accounts.credentials.Account = "name2"; accounts.credentials.Password = "pwd2"; accountProfile = accounts.QueryProfile(accounts.credentials); } Now, I'm sure you are all wondering what my problem is....My problem is that I don't know what to put in my implementation of QueryProfile() to make it call the webMethod. All of the implementations I have seen say to create a new object o

                S Offline
                S Offline
                S Senthil Kumar
                wrote on last edited by
                #7

                I'm no expert in writing WebServices, but isn't AccountsImpl supposed to be the actual implementation of the QueryProfile web method? This is the code that's supposed to do work of querying the profile and returning an instance of AccountProfile, so how does calling it again solve the problem? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                S 1 Reply Last reply
                0
                • S S Senthil Kumar

                  I'm no expert in writing WebServices, but isn't AccountsImpl supposed to be the actual implementation of the QueryProfile web method? This is the code that's supposed to do work of querying the profile and returning an instance of AccountProfile, so how does calling it again solve the problem? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                  S Offline
                  S Offline
                  Snowblind37
                  wrote on last edited by
                  #8

                  You are right Senthil! It is the actual implementation of the WebMethod. This is where I got stumped. It turned out that when I ran my wsdl.exe I specified "server". This gave me the server implementaion of the class which was an abstract class. So on the server side there is an AccountsImpl that implements the abstract method QueryProfile(). This is the class that would do all the work for my call to QueryProfile(). But on the client side all I wanted/needed to do was create a ServiceAccounts object. So when I ran the wsdl.exe without specifying "server" (default is "client") I was given a ServiceAccounts class that was not abstract. The problem then was that I had obtained (through wsdl.exe) the server implementation when I really needed the client implementation. A valuable lesson was learned......and the best part is I still have some hair left, I didn't throw my computer out the window, I petted the neighbour's cat instead of stomping on it and my car is still in the driveway. Regards, Reserving CodeBlind For The Future..............

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups