locked
creating webservice RRS feed

  • Question

  • User442781244 posted

    Hi

    Masters

    I have an website containing N number of userid and their pwd. Now another website want to use these userid and pwd by creating webservices .

    So please suggest how to do it. I dont ve any idea abt WCF within a very short period of time i have to complete it.

    kindly read requirement carefully then suggest.

    if ques is not clear then plz let me know.

    plz help

    its very urgent for me.

    Tuesday, September 24, 2013 5:38 AM

Answers

  • User-386954757 posted

    Hello,

    As I understand  that you have already created website that have lots of users, Now other websiets wants to use your account or Validate though your username and passsowrd from your site.

    To acheve that feature you are going to implemente the WCF  service by using that other thid paty web site can validate username and password.

    Your service will do validation. If i am correct then its very easy to do

    refer the below basic WCF creation help

    http://www.codeproject.com/Articles/42643/Creating-and-Consuming-Your-First-WCF-Service

    http://www.codeproject.com/Articles/406096/A-beginners-tutorial-for-understanding-Windows

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 5:50 AM
  • User-488622176 posted

    See this article for steps and principe : http://www.codeproject.com/Articles/42643/Creating-and-Consuming-Your-First-WCF-Service

    For you :

    [DataContract]
    public class User
    {
        [DataMember]
        public String UserName {get;set;}
        [DataMember]
        public String Password{get;set;}
    }
    
    [ServiceContract]
    public interface IMySecurityService
    {
        [OperationContract]
        User GetUser(string userName, String pwd);   
    }

    Then create serverside a class that implements the IMySecurityService interface : "MySecurityService"

    Your config : 

    <service behaviorConfiguration="WcfSample.Service1Behavior" name="WcfSample.MySecurityService">
    <endpoint address="" binding="wsHttpBinding" contract="WcfSample.IMySecurityService">
    <identity>
     <dns value="localhost"/>
     </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>


    In the "GetUser" method of the "MySecurityService" class, you connect to your dbase, fetch the record matching username & password, read values in a User object (from datareader), and return the User object. If error or not found => return null.
    Recompile your service project & run it (in debugger, with breakpoint on "GetUser" implemenation)

    Then create your client project as shown in example, and connect to the running service to create the service client.

    HTH 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 27, 2013 8:40 AM

All replies

  • User1078371881 posted

    create a webservice and it should have a webmethod to return the userid and pwd. Add this service as web reference to the both websites (your old and newly created), then call this webmethod to get userid and pwd.

    Pls let me know if you need any more.

    Tuesday, September 24, 2013 5:45 AM
  • User442781244 posted

    hi

    g_mani

    thanks for yor reply.

    mani..i am new. IF u dont mind..plz give me step by step clarification what u ve written above.plz mani

    if u can suggest step bt step with code, it would be easir for me to understand.

    plz help mani

    Tuesday, September 24, 2013 5:49 AM
  • User-386954757 posted

    Hello,

    As I understand  that you have already created website that have lots of users, Now other websiets wants to use your account or Validate though your username and passsowrd from your site.

    To acheve that feature you are going to implemente the WCF  service by using that other thid paty web site can validate username and password.

    Your service will do validation. If i am correct then its very easy to do

    refer the below basic WCF creation help

    http://www.codeproject.com/Articles/42643/Creating-and-Consuming-Your-First-WCF-Service

    http://www.codeproject.com/Articles/406096/A-beginners-tutorial-for-understanding-Windows

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 5:50 AM
  • User442781244 posted

    hi

    atul

    could u plz explain little bit more. I am new to WCF..   I am unable to understand. So plz suggest code acoording to my requirement . i dont ve time. little bit modification in code will reduce my time.'plz help atul

    Tuesday, September 24, 2013 5:59 AM
  • User-386954757 posted
    1. Launch Visual Studio 2010.
    2. Click on File -> new -> project, then select WCF service application.
    3. It will create a WCF service application template.

    => Rename "Service1.svc" to whatever you like as per your project name "MyWebService.svc"

    =>MyWebService.svc

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.Text;

    namespace WcfService1
    {
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : IService1
    {
    public string ValidateUser(string strUsername, string strPassword)
    {


    return string.Format("You entered: {0}", strUsername + strPassword);
    }

    }
    }

    =IService1.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.Text;

    namespace WcfService1
    {
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

    [OperationContract]
    string ValidateUser(string strUsername,string strPassword);
    // TODO: Add your service operations here
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class Userinfo
    {
    string strUsername, strPassword;

    [DataMember]
    public string Username
    {
    get { return strUsername; }
    set { strUsername = value; }
    }

    [DataMember]
    public string Password
    {
    get { return strPassword; }
    set { strPassword = value; }
    }
    }
    }


    Browser link  : http://localhost:51042/MyWebService.svc

    if you dont know c# then convert it into VB.net from here http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Tuesday, September 24, 2013 7:32 AM
  • User-386954757 posted

    Hello,

    I have already give you direction as well as sample code. Kindly refer it and go into that direction. Also you can take help from your seniors.

    Wednesday, September 25, 2013 5:37 AM
  • User442781244 posted

    i am alone in project.......thats why i asked for help could u help me???

    Wednesday, September 25, 2013 5:38 AM
  • User-488622176 posted

    See this article for steps and principe : http://www.codeproject.com/Articles/42643/Creating-and-Consuming-Your-First-WCF-Service

    For you :

    [DataContract]
    public class User
    {
        [DataMember]
        public String UserName {get;set;}
        [DataMember]
        public String Password{get;set;}
    }
    
    [ServiceContract]
    public interface IMySecurityService
    {
        [OperationContract]
        User GetUser(string userName, String pwd);   
    }

    Then create serverside a class that implements the IMySecurityService interface : "MySecurityService"

    Your config : 

    <service behaviorConfiguration="WcfSample.Service1Behavior" name="WcfSample.MySecurityService">
    <endpoint address="" binding="wsHttpBinding" contract="WcfSample.IMySecurityService">
    <identity>
     <dns value="localhost"/>
     </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>


    In the "GetUser" method of the "MySecurityService" class, you connect to your dbase, fetch the record matching username & password, read values in a User object (from datareader), and return the User object. If error or not found => return null.
    Recompile your service project & run it (in debugger, with breakpoint on "GetUser" implemenation)

    Then create your client project as shown in example, and connect to the running service to create the service client.

    HTH 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 27, 2013 8:40 AM