简体   繁体   中英

Error in Calling some service in WCF Client

When I call this service method:

StaffServiceClient _Service = new StaffServiceClient();
Table_StaffInfo item = _Service.GetStaffById(10);

I get an error:

An error occurred while receiving the HTTP response to http://localhost:8008/StaffService . This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

but when i call another service method:

StaffServiceClient _Service = new StaffServiceClient();
List<spStaffList_Result> list = _Service.GetStaffList().ToList();

the program works.

Your method GetStaffById failed internally. Maybe it has problems with receiving data (unlikely if just an int) maybe it has problems sending data (does your type Table_StaffInfo feature DataContract / DataMember attributes?) or it simply threw an exception.

You will need to debug your service. Put a breakpoint in the method and see where it takes you.

For starters, ignore the int parameter and just put a return null; in the method. If that works, it has nothing to do with your connection or server setup and you need to debug your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM