using custom principal in Workflow - wcf

I have an application that hosts several WCF services. I have created a custom ServiceAuthorizationManager that is working perfectly. I inspect a few elements on the OperationContext.IncomingMessageHeaders to get a username and password. This was to overcome some limitations in our environment that wouldnt allow us to use what was built into the platform. the manager creates a custom IPrincpal, with a few necessary custom objects in it, and places it on the currently running thread, for use later in the WCF business logic. this is Working great.
Problem is that I have a WCF service that is a workflow, and I need to use the same mechanism there. The Manager is being called correctly, however when executing the Thread's currentPrincpal isn't my custom principal, it's a genericprincipal. Investigation shows that the workflow runtime is creating a thread, and not using the thread that the WCF call came in on.
Has anyone run into this issue, and are there any good solutions to it?

If the runtime is in the same appdomain as the manager then you should be able to call
AppDomain.CurrentDomain.SetThreadPrincipal
See here for more information

Related

WCF, DLLIMPORT strange issues

I have a very strange issue that i cannot figure out.
First i have a WCF service 4.0 done in VS2010.
the service have couple methods that return string array, datatable and such.
some of them use function from C++ dll throught [dllimport]
i made a test console to test everything. when i run the WCF from visual studio and use the generated path it works wonderfully.
now here is where it become strange. if i open my local IIS create a new application and point to my VS source code the WCF i can see it perfectly.
now using the http path from IIS local instead i refresh the methods all seems correct. But when i run my test app i can call any unction without any problem EXCEPT anyone using DLLIMPORT functions. they ALL crash and cannot trace even by tracing CES exceptions.
Doing line by line logging show that the exception is really on the call of those functions
the DLL in question is the same and the path is hardcoded for my computer since still in test phase and the folder is c:\DLL\mylib.DLL so nothing to do with shadow copy IIS/visual studio do when you actually run. also DLL reference by name withotu path even if it's in sys32 doesnt work.
Any clue ?
also. 32bit, changing app pool level right access on folder, full admin on machine already too. all tried but unsuccessful.
Edit: adding to all that since i haven't made this clear, it's not my first WCF real setup. i've already made alot of services before and deployed them myself (probably somewhere around 50-60 services). I am asking because i have never seen this issue before and i tried all tricks i knew and could find on the internet and resource people i know.
We have decided to incorporate the whole service in the WPF project locally since it work as long as IIS is not hosting. but this is really not a good thing as this data and work should NOT be done on client side but instead on server side. Right now it's fine since the software that need to use this is not released to public yet so it isn't critical.
Next option will be net TCP/IP windows service hosted on the web server if i don't find anything else.
We decided to go trough the trouble of having to hard code the logic in the main software and get away from web services for this issue. we will have to deal with updating, installing unregister and re register unmanaged DLL by hand somehow but at least it works.
we have added over 5 web services since that happen and no problem with them but again none of them use DLL imports.

creating web service in VB.NET

I have just little background in web and I need to do this task by myself so I will be most grateful for your help
this is what my boss told me to do (as far as I understand) - I have to write a web service server which gets some parameters, check their validity and then insert/update them in a database. All the parameters are delivered together as a packet written in SOAP - WSDL file. I have to do it using vb.NET in Visual Studio 2010. I read a bit about it and if I understand correctly .NET takes care already of the SOAP an WSDL issue, it is transparent to me, isn't it? or should I install or implement anything concerning that? I saw some examples in the net that all you have to do is to implement web_method in the asmx file, is it so? if yes, which parameters will my method get - the whole bunch of 20 parametres supposed to be in the packet? anything I need to declare or to update in order to connect to the DB? Any help will be appreciated - uf the answer is too long I will be happy just to get a pointer to some relevant material I can read and learn.
Thanks a lot
Try reading this MSDN article: it describes how to write a simple Web service by using Visual Basic .NET
Here are the main steps from the linked MSDN article:
Start Visual Studio .NET or Visual Studio.
Create a new Active Server Pages (ASP) .NET Web service project. Name the Web service MathService and point the location to an
appropriate Web server that is running ASP.NET if necessary.
Change the name of the Solution file to MathService for consistency.
Change the name of the default Web service that is created from Service1.asmx to MathService.asmx.
Click Click here to switch to code view in the designer environment to switch to code view.
Change the name of the class from Public Class Service1 to Public
Class MathService.
Define methods that encapsulate the functionality of your service. Each method that will be exposed from the service must be flagged with
a WebMethod attribute in front of it. Without this attribute, the
method will not be exposed from the service.
Click Build on the Build menu to build the Web service.
Browse to the MathService.asmx Web service page to test the Web service. If you set the local computer to host the page, the URL is
http://localhost/MathService/MathService.asmx.

Soap UI no longer triggers breakpoints in my WCF service

I recently made some reference additions to a project in my solution and made some changes to the web.config in order to use another WCF service from within my code without using the 'Add Service Reference' wizard in order to prevent the need to keep updating the reference in case it changes. Since doing this SOAP UI no longer triggers a break point in my service when I use it to test my code responses. It used to work perfectly. What could I have changed that has caused this behaviour?
You can configure what to be started and debugging manually.
Right click on your solution
Properties -> Startup Projects
Check Multiple start-up projects
Action -> Start for your GUI and WCF projects
That will make debugger to attach to these processes and enable break-points.

How to start a process from within a windows service

I want to pop a browser with a given url from within a windows service. Like so:
System.Diagnostics.Process.Start("http://www.venganza.org/");
Works fine when running in a console but not from within the service. No error messages, no exceptions, the Process.Start() command just seem to do nothing. It smells of some security issue, maybe something with the service properties and/or logon options? Annoying stuff this... Anybody? (Oh, and on windows 7/.NET framework 3.5.)
A service should never pop up anything to the user. Don't do this with a service.
You will problably need elevated rights to do this aswell. You will have to sign in as the user.
Even if you manage to do this, don't. This is not what services is ment for and it is really bad practise. If you really want someting to pop up, have a seperate process instead.
It is popping up, but on the Window Station associated with the service.
I would suggest that you tweak your design such that your service doesn't need to interact in this manner. There are ways to get it to appear on an interactive desktop (you'd have to cope with issues such as impersonating the relevant user, targeting the correct desktop if nobody is logged on or if more than one person is logged on, etc.)
Just on a side note Windows services aren't built for interactivity. They are used to process behind-the-scenes type stuff. However, have you tried enabling the Interact with Desktop option on the service itself?

Custom service application - proxy stopped

Ive created a custom service app using samples from Tony Bierman and MS. I can see the application in central admin, I can create a new service app from it, the create page works, the manage page is blank and I don't have a properties page. I havent yet tried using the beast, I just want to get the deployment and admin stuff working first. It deploys ok and I can create an instance.
However, after creating it, I see the Service app has started but the app proxy is stopped.
I dont know if this is a problem or not but I cant find anywhere to start it.
Should I worry?
Turns out that yes, I do need to worry. The problem was I had the proxy package feature receiver scoped to web rather farm. Took me a week to find this :(