我在尝试调用JSON Web服务时遇到异常。我是新手,我想知道我在哪里搞砸了。
异常
获取com.sun.jersey.api.client.UniformInterfaceException:GET http://www.mcruiseon.com:8081/mCruiseOnCarPool4All/carpool4all/AcceptedSubscriptionList/Request/143683759/-1087322127返回的响应状态为500内部服务器错误 在com.sun.jersey.api.client.WebResource.handle(WebResource.java:686) 在com.sun.jersey.api.client.WebResource.access $ 200(WebResource.java:74) 在com.sun.jersey.api.client.WebResource $ Builder.get(WebResource.java:507) at 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);
Jersey webservice
@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();
}
网络服务正在加载
信息:发现的根资源类: class com.mcruiseon.carpool4all.VehicleListService class com.mcruiseon.carpool4all.SubscriberListService class com.mcruiseon.carpool4all.JourneyListService class com.mcruiseon.carpool4all.RegistrationService class com.mcruiseon.carpool4all.SearchService class com.mcruiseon.carpool4all.AddJourneyDetailsService class com.mcruiseon.carpool4all.AcceptedSubscriptionListService class com.mcruiseon.carpool4all.AcceptSubscriptionService class com.mcruiseon.carpool4all.AddVehicleDetailsService class com.mcruiseon.carpool4all.SubscribeToThisJourneyService class com.mcruiseon.carpool4all.AddUserDetailsService