Before we go too far, we want to look at your claimed solution.
ODE = x*diff(y,x)+y==-sin(x);
yoursol(x) = -(x*sin(x)-cos(x))/x^2;
First, does your solution satisfy the initial conditions?
yoursol(pi/2)
ans =

In fact, no, it does not even satisfy your own boundary condition, so we know your claimed solution is not correct. I won't even bother to see if it "satisfies" the ODE, aince it cannot do so.
Now lets use dsolve to solve the ODE.
sol(x) = dsolve(ODE,y(pi/2) == 0)
sol(x) =

Does this satisfy the ODE?
simplify(subs(ODE,y,sol))
Sorry. It looks like dsolve got it right.