Get the process id of the app, which called the service
As you launch the service from Safari, the application will be the one in the foreground.

You can use this Applescript in the "Run AppleScript" action.

tell application "System Events"
    set x to first process whose its frontmost is true and name is "Safari"
    return unix id of x
end tell