0

i am working with MFC application and i don't have knowledge about MFC because i am Donet net developer .

i am trying to hit web service which coded in C# .web service has login method . when i hit from MFC application its work well . after check username and password login method return user code .i want to read this user code in MFC application .

My MFC code is here

 CString clsLogin::login(CString username ,CString password)
     {

CString a1;
    a1.Format("%02X",""); szJson.Replace("byte1str", a1);
    a1.Format("%02X",""); szJson.Replace("byte2str", a1);
    a1.Format("%02X",""); szJson.Replace("byte3str", a1);
    a1.Format("%02X",""); szJson.Replace("byte4str", a1);
    a1.Format("%s",username);szJson.Replace("name1", a1);
    a1.Format("%s",password);szJson.Replace("pass1", a1);

curlcode = CURLE_OK;

char *posturi  = "myurl";
CURL *curl     = NULL;

curl = curl_easy_init();

 if(curl) {

   curl_easy_setopt(curl, CURLOPT_URL,              posturi);
   curl_easy_setopt(curl, CURLOPT_POSTFIELDS,       szJson);
   curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,    strlen(szJson));

   curlcode = curl_easy_perform(curl);


   curl_easy_cleanup(curl);
} else {
    curlcode = CURLE_FAILED_INIT;
}


 return 0 ;

}

please help me

What should i add to this function to get return value from webservice method

C# code is Here

  [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
    public string CheckLogin(string data)
    {

//command to database to check username and password

        return usercode;
    }
Code Rider
  • 2,003
  • 5
  • 32
  • 50
  • Can you please paste your C# code it will be more useful to understand problem? – A B Jan 16 '14 at 07:53
  • i have add it please have a look – Code Rider Jan 16 '14 at 08:01
  • If I am not Wrong, you want to use database code used in `c#` to run for `MFC`? – A B Jan 16 '14 at 08:03
  • yes, i am using database query to check user in c# method , method just return user code from c# and i want to fetch this code in MFC app to check user . – Code Rider Jan 16 '14 at 08:21
  • Then Why don't you try `CLR` i.e. `Common Language Runtime` feature for this. Just by using C# library in your MFC application. – A B Jan 16 '14 at 08:23
  • can you please explain process for this because its first time i am using MFC so i don't know how it use in MFC – Code Rider Jan 16 '14 at 08:29

1 Answers1

0

Its Better to use CLR i.e. Common Language Runtime feature of visual Studio.

Steps Are as Folows:

  1. Change application setting to support CLR Go to *Project -> Properties ->Configuration Properties-> General-> Common Language Runtime Support ->Change to `Common Language Runtime Support (/clr)' *

  2. Add references any Library you want in your application. go to : Project -> Properties ->Common Properties-> Add New Reference Add references as "System.Web.Mvc" and "System.IO"

  3. Add Following code to header :

    using <System.dll> using namespace System; using namespace System::Web::Mvc;

  4. Use your C# code for database.

For further reference use following links: 1. Use of HttepVerbs

Hope It will help you

A B
  • 1,461
  • 2
  • 19
  • 54