Hy,

I trying to create a windows forms app that also starts a webservice that hosts some webmethods. The webservice is used by different users that connect to it to generate some data. The webservice, in his turn, connects to a public webserver with a certificate from a usb token.

Now why I'm trying to get this to work is:

  • when my webservice access the public webservice the first time it requires authentification with the certificate from the usb token, which pops-up a window to insert the token PIN number.
  • if i host the webservice in a webserver (IIS) the window never pops up because iis is not interactive
  • i can make the app only window forms based but then i'd have to use tcp protocol which i do not trust for file transfers.
  • web service uses http + forms allow me to popup the pin dialog.

But how can i combine them. In development mode i can instanciate the webservice and call it's functions... but that's only local... How ca i create an instance and make it remotely available.

Thanks

Dani AI

Generated

— Short answer: run the HTTP endpoint inside an interactive process or move all smart-card access into a small interactive agent that your network service talks to. The PIN dialog comes from the token middleware and only appears in an interactive user session; IIS and Windows services run non-interactive and will not show that UI.

Self-host inside your WinForms app when you want the PIN prompt to appear directly. Host an HTTP endpoint (HttpListener, a small WCF ServiceHost or an OWIN listener) from the form so the app runs as the logged-on user and can display the token PIN dialog. Required steps you will not want to forget:

  • Reserve the URL namespace for non-admin users (netsh http add urlacl ...).
  • Open the firewall port.
  • Bind to the correct IP/port (or machine name) so other machines can reach it.
    Minimal example (start a WCF host from the form):
    var host = new System.ServiceModel.ServiceHost(typeof(MyService), new Uri("http://+:8000/MyService"));
    host.AddServiceEndpoint(typeof(IMyService), new System.ServiceModel.BasicHttpBinding(), "");
    host.Open();

If you prefer hosting the public API in IIS, use a local interactive helper (tray app) to perform certificate-authenticated calls. The IIS service forwards work to that helper over secure IPC (named pipes or localhost HTTPS), the helper opens the USB token and prompts the user for PIN, then returns results. This avoids Session 0 isolation problems and keeps a hardened, non-interactive front end.

Troubleshooting checklist: confirm the token middleware supports desktop UI for your account, verify URL ACLs (netsh http show urlacl), check firewall rules, run a quick local console client first to confirm token access, and use Process Monitor/Event Viewer to trace failures. As noted, you must expose a TCP/HTTP endpoint; as suggested, self-host WCF is a practical way to do it — the two patterns above show how to preserve the PIN UI while making the service reachable.

Recommended Answers

All 2 Replies

If you want that your WinForm application react as a web service server first you have to write TCP/IP server then implement one of web service protocols you want to use, usually SOAP. For more information about protocols

Well I am not sure if my answer is relevent but I think you are asking about how to host that service so that you can interact with that when it is hosted on IIS.What I did was that I first created a WCF webservice library and then added a WCF service Application to same solution made the reference to webservice library and configured it's end points.You can contact me if you like my id on skype is qadeer37

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.