The question is vague, your Service X is a mystery, we know nothing about it.
Usually tools that read credentials from the terminal don't use stdin for this. The service may or may not use stdin. It may provide an option to read credentials from stdin. It may provide an option to read credentials from a file.
Note: from now on I will use servicex as the command because X in your Service X is an operand, so with options it should weirdly look like Service -a -b --optionc X. I doubt such syntax was your intention.
If servicex reads credentials from stdin by default, this should work:
printf '%s\n' "your username" "your password" | servicex
If it reads credentials from stdin only when told to do so, something like:
printf '%s\n' "your username" "your password" | servicex --credentials-from-stdin
In both cases it may be better to read credentials from a file that no other user can read:
<secret_file servicex --credentials-from-stdin
Or the service may provide an option to read credentials from a file (leaving stdin for another purpose or unused):
servicex --credentials-from-file secret_file
But most likely the service uses the terminal device directly to ask for credentials and to read them. In this case expect is the right tool. Compare this answer of mine or this one. A vague sketch of a solution to your vague problem may be:
expect -c '
log_user 0
spawn servicex
expect "Service X: Username:"
send "your username\n"
expect "Service X: Password:"
send "your password\n"
interact
'