Multiple Trading API calls not working when executed consecutively
I have two completely separate portions of code that execute different API calls. One calls GetCategories and the other calls GetMyeBaySelling. The calls are basically structured like this: //GetCategories eBayAPIInterfaceClient test = new eBayAPIInterfaceClient("eBayAPI", requestURL); //Set request credential object GetCategoriesRequestType getCategoriesRequest = new GetCategoriesRequestType(); GetCategoriesResponseType getCategoriesResponse = test.GetCategories(ref requestCredentials, getCategoriesRequest); //GetMyeBaySelling eBayAPIInterfaceClient listingDataClient = new eBayAPIInterfaceClient("eBayAPI", requestURL); //Set request credential object GetMyeBaySellingRequestType getListingRequest = new GetMyeBaySellingRequestType(); GetMyeBaySellingResponseType getListingResponse = listingDataClient.GetMyeBaySelling(ref requestCredentials, getListingRequest); I can always execute one of these calls multiple times with no problem. But if I execute one of them, then execute the other, I get this error: java.lang.ClassCastException: com.ebay.domain.apisoap.pres.service.hosting.soap.basecomponents.GetMyeBaySellingResponseType incompatible with com.ebay.domain.apisoap.pres.service.hosting.soap.basecomponents.GetCategoriesResponseType Has anyone seen this before? I managed to find a posting on StackOverflow describing the problem and the poster mentioned they had found a solution, they just hadn't posted what it was, but that it was something about changing their HTML bindings in their app.config.
As a temporary workaround, I was able to solve this by creating a separate binding in app.config for the second call execution with the eBayAPIInterfaceClient object. It now references the second binding (which is identical to the first with the exception of the name). Surely I don't have to do this for each distinct call I plan on making? I suppose I won't be making that many so it may not be a big deal but obviously the binding is where the problem lies. I just don't know how to fix it properly.