尝试调用 JSON Web 服务时出现异常。我是新手,我想知道我在哪里搞砸了。
例外
GET com.sun.jersey.api.client.UniformInterfaceException: GET http://www.mcruiseon.com:8081/mCruiseOnCarPool4All/carpool4all/AcceptedSubscriptionList/Request/143683759/-1087322127在 com 返回响应状态 500 Internal Server Error。 sun.jersey.api.client.WebResource.handle(WebResource.java:686) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client .WebResource$Builder.get(WebResource.java:507) 在 test.carpool4all.SingleProviderTest.testPost(SingleProviderTest.java:70)
Junit 客户端 (SingleProviderTest)
// AcceptedSubscriptionList
service = client.resource(UriBuilder.fromUri(
"http://localhost:8081/mCruiseOnCarPool4All/carpool4all/AcceptedSubscriptionList/Request/" + identityHash
+ "/" + journeyList[i].getProviderHash()).build());
//Line # 70 Below
SubscribeJourneyConcrete[] acceptdList = service.type(MediaType.APPLICATION_JSON).get(
SubscribeJourneyConcrete[].class);
assertNotNull(acceptdList);
assertTrue(acceptdList.length > 0);
泽西岛网络服务
@Path("/AcceptedSubscriptionList")
public class AcceptedSubscriptionListService {
private ClientSession clientSession ;
private static final SessionManager sessionManager = SessionManager.getInstance() ;
@Context
UriInfo uriInfo;
@Context
Request request;
@GET
@Path ("Request/{identityHash}/{providerHash}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public Response getJourneyList(@PathParam("identityHash") String identityHash,
@PathParam("providerHash") String providerHash) {
AcceptedSubscriptionListRequest request = new AcceptedSubscriptionListRequest(providerHash) ;
AcceptedSubscriptionListResponse response ;
clientSession = sessionManager.getClientSession(identityHash) ;
clientSession.getSendQueue().sendRequest(request) ;
try {
response = (AcceptedSubscriptionListResponse)clientSession.waitAndGetResponse(request) ;
} catch (WaitedLongEnoughException e) {
return Response.serverError().build() ;
} catch (UnableToResolveResponseException e) {
return Response.serverError().build() ;
}
return Response.ok(response.getAcceptedSubscriberList()).build();
}
网络服务加载正常
信息:找到根资源类:com.mcruiseon.carpool4all.VehicleListService 类 com.mcruiseon.carpool4all.SubscriberListService 类 com.mcruiseon.carpool4all.JourneyListService 类 com.mcruiseon.carpool4all.RegistrationService 类 com.mcruiseon.carpool4all.SearchService 类 com。 mcruiseon.carpool4all.AddJourneyDetailsService 类 com.mcruiseon.carpool4all.AcceptedSubscriptionListService 类 com.mcruiseon.carpool4all.AcceptSubscriptionService 类 com.mcruiseon.carpool4all.AddVehicleDetailsService 类 com.mcruiseon.carpool4all.SubscribeToThisJourneyService 类 com.mcruiseon.carpool4all.AddUserDetailsService