Click here to Skip to main content
15,910,121 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a php website and a smartcard, the implementation with smartcard is in C# i.e reading and writing files from smartcard and card insertion or removal handler. now i have to execute c# code and show the data on php website and i also have to write back data on smartcard from php. andy one know suitable way to interact php and c#
Posted
Comments
sri senthil kumar 3-May-13 8:07am    
Am not sure about this, but i have an suggestion if they are kept as service then you can give a ajax call and get the response and again process them in php. May be it can help you.
Member 10005154 3-May-13 8:28am    
how many services i have to create i.e one on php and other on c#
sri senthil kumar 3-May-13 8:37am    
only for the C# is enough i hope because ur application is built on Php right? if so making C# code alone as web service is enough.
Member 10005154 3-May-13 8:47am    
i have to get data from smartcard and show on website and i also have to save data on smartcard (data i get from website) can i do this with one service.
sri senthil kumar 6-May-13 5:17am    
Yes, single service can have multiple methods. so I hope there wont be any issue with that.

1 solution

the implementation with smartcard is in C# i.e reading and writing files from smartcard and card insertion or removal handler -> From what I can see here is the smartcard will contact / exchange date on some devices (card insertion / removal handler).

You need to implement on card insertion / removal handler as middle man in order to connect / exchange data with your PHP website. From c# you can create some web request to your PHP site.

some example here :
//Create request from your card insertion / removal handler to your PHP site
WebRequest objRequest = HttpWebRequest.Create("https://targetwebsitephp.com");
objRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
objRequest.Proxy = WebRequest.DefaultWebProxy;
objRequest.Proxy.Credentials = CredentialCache.DefaultCredentials;
objRequest.UseDefaultCredentials = true;

WebResponse objResponse = (WebResponse)objRequest.GetResponse();

using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
    string str = sr.ReadToEnd();
    sr.Close();
    //... Do stuff with str
}


Maybe you can give us more info regarding your planning with your system.
 
Share this answer
 
Comments
Member 10005154 4-May-13 9:22am    
this is my card insertion handler

private static void channel_ChannelCardInsertionStateChangedEvent(object sender, SmartCard.Runtime.Remoting.Channels.ChannelCardInsertionEventArgs e)
{
if(e.Inserted)
{
if(APDUClientChannel.IsNetCard(e.ReaderName))
{
if(APDUClientChannel.ContainsService(e.ReaderName,"TransactionSampleService"))
{
//here i have to read some files that are on card and after read i have to send these files to website. the card contain patient data i.e prescription details or test results and on the website i have a doctor which reads the data from card and prescribe new medicine or other test, now what ever things doctor suggests or changes then i have to write back on the smartcard. i hope you could get.

}
else
Console.WriteLine("Card in the reader {0} does not contain {1}",e.ReaderName,"TransactionService");

}
else
{
Console.WriteLine("Card in the reader {0} is not a Gemalto.NET Smart card",e.ReaderName);
}
}
else
{
Console.WriteLine("Please insert your SmartCard...");
}
}
}
nureza_fachry 4-May-13 23:48pm    
I just have some thought, why dont you just store some basic info on card instead of all test result (more detail patient info). If I`m not mistake that most of card have limitation memory / storage. So all the Main Info you can store on web application instead of on card it self.

Anyway,
if(APDUClientChannel.ContainsService(e.ReaderName,"TransactionSampleService"))
{
//1.Read and write to get data form card
//2.Create request to web application using sample that I give before
//3.When you crate request, you can get response from web application
//4.Based on response from web application you can take action.
//then the rest you should be able to do

}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900