I have implemented Continuation
concept with the Asynchronous WSDL class, in a controller of page. So, I facing difficulties while writing test classes for the same.
For my requirement I have generated(from WSDL file) WSDL classes(one for Synchronous and other class for Async) and I am using generated AsyncWSDL class in my implementation. My webservice method will return an instance of a class generated inside the WSDL class. And there is some code inside generated WSDL classes to parse the response.
For the synchronous webservice callout test classes, we have to use Test.setMock()
and we can return the desired object as response.
For Async with Continuation, I know that we have to set the test response with Test.setContinuationResponse()
and use Test.invokeContinuationMethod()
to call the callback method.
Here the setContinuationResponse()
method signature is setContinuationResponse(String requestLabel, System.HttpResponse mockResponse)
, and HttpResponse.SetBody()
will accept String as parameter. But I want to return an object(instance of a inner class of WSDL class) as response, which will be actually returned by WebServiceCalloutFuture.getValue()
method of Future instance in Async WSDL classes. If I generate desired class instance and pass the classInstance.toString()
to setBody()
, then I am getting error at the WebServiceCalloutFuture.getValue()
method inside Async WSDL class.
Is there any way to set the desired Class instance as response to my continuation call response? Please assist on this.