本文整理匯總了Java中javax.xml.ws.Response.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Response.get方法的具體用法?Java Response.get怎麽用?Java Response.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.ws.Response
的用法示例。
在下文中一共展示了Response.get方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleResponse
import javax.xml.ws.Response; //導入方法依賴的package包/類
@Override
public void handleResponse(Response<String> response) {
try {
res = response.get();
} catch (Exception e) {
e.printStackTrace();
res = e.getMessage();
}
}
示例2: testInvokeAsync
import javax.xml.ws.Response; //導入方法依賴的package包/類
@Test
@RunAsClient
public void testInvokeAsync() throws Exception
{
Endpoint port = createProxy();
Response<String> response = port.echoAsync("Async");
// access future
String retStr = response.get();
assertEquals("Async", retStr);
}
示例3: testInvokeAsyncHandler
import javax.xml.ws.Response; //導入方法依賴的package包/類
@Test
@RunAsClient
public void testInvokeAsyncHandler() throws Exception
{
AsyncHandler<String> handler = new AsyncHandler<String>()
{
@Override
public void handleResponse(Response<String> response)
{
try
{
System.out.println("AsyncHandler.handleResponse() method called");
String retStr = response.get(5000, TimeUnit.MILLISECONDS);
assertEquals("Hello", retStr);
asyncHandlerProxyCalled = true;
}
catch (Exception ex)
{
handlerProxyException = ex;
}
}
};
Endpoint port = createProxy();
Future<?> future = port.echoAsync("Hello", handler);
long start = System.currentTimeMillis();
future.get(5000, TimeUnit.MILLISECONDS);
long end = System.currentTimeMillis();
System.out.println("Time spent in future.get() was " + (end - start) + "milliseconds");
if (handlerProxyException != null)
throw handlerProxyException;
assertTrue("Async handler called", asyncHandlerProxyCalled);
}
示例4: handleResponse
import javax.xml.ws.Response; //導入方法依賴的package包/類
@Override
public void handleResponse(Response<T> response) {
if (response.isCancelled()) {
if (logger.isErrorEnabled()) {
logger.error(MESSAGES.WEB_RESPONSE_CANCELED);
}
Exception exception = new MovilizerWebServiceException(
MESSAGES.REQUEST_CANCELLED_ERROR);
futureCallback.onFailure(exception);
futureCallback.onComplete(null, exception);
return;
}
if (response.isDone()) {
try {
if (logger.isTraceEnabled()) {
logger.trace(MESSAGES.HANDLING_WEB_RESPONSE);
}
T resInstance = response.get();
if (logger.isDebugEnabled()) {
logger.debug(String.format(MESSAGES.SUCCESSFUL_WEB_RESPONSE,
resInstance.getClass().toString()));
}
futureCallback.onSuccess(resInstance);
futureCallback.onComplete(resInstance, null);
} catch (ExecutionException | InterruptedException e) {
futureCallback.onFailure(e);
futureCallback.onComplete(null, e);
}
} else {
if (logger.isErrorEnabled()) {
logger.error(MESSAGES.WEB_RESPONSE_NOT_DONE);
}
}
}