I am working on an event receiver in SP2010 environment. It is a 2 sp servers and 1 SQL topology. Both sp servers run exactly same services and service applications. Both have MS office installed. There are 2 AAM setup http://server01 (default) and http://server02. (intranet)
In the event receiver I need to call the excelservice. In Visual studio 2010 I add a web reference URL "http://server01/_vti_bin/excelservice.asmx". After deploy the solution and tested on "http://server01/sites/abc/xxxxx". The program is working as expected.
However, when test with "http://server02/sites/abc/xxxxx". My program logged an error "The request failed with HTTP status 401: Unauthorized.". The event receiver is triggered by a site collection admin account.
I have two findings:
- Login server01 and server02, open the browser and browse "http://server01/_vti_bin/excelservice.asmx", both server's browser is returning correct result.
- On server02, I added a record in HOSTS file "hkserver01 127.0.0.1" on hkserver02 to force the web service request go locally, my program will work.
So it seems my program will not work "cross-server" or the web service will return 401 for non-local request. Why?