javax.xml.ws.http.HTTPException Java Examples
The following examples show how to use
javax.xml.ws.http.HTTPException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DispatchImpl.java From cxf with Apache License 2.0 | 6 votes |
private void checkError() { if (error != null) { if (getBinding() instanceof SOAPBinding) { SOAPFault soapFault = null; try { soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding)getBinding(), new Exception(error.toString())); } catch (SOAPException e) { //ignore } if (soapFault != null) { throw new SOAPFaultException(soapFault); } } else if (getBinding() instanceof HTTPBinding) { HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR); exception.initCause(new Exception(error.toString())); throw exception; } throw new WebServiceException(error.toString()); } }
Example #2
Source File: TestRailClient.java From testrail-jenkins-plugin with Apache License 2.0 | 6 votes |
private TestRailResponse httpPostInt(String path, String payload) throws UnsupportedEncodingException, IOException, HTTPException { TestRailResponse result; PostMethod post = new PostMethod(host + "/" + path); HttpClient httpclient = setUpHttpClient(post); try { StringRequestEntity requestEntity = new StringRequestEntity( payload, "application/json", "UTF-8" ); post.setRequestEntity(requestEntity); Integer status = httpclient.executeMethod(post); String body = new String(post.getResponseBody(), post.getResponseCharSet()); result = new TestRailResponse(status, body); } finally { post.releaseConnection(); } return result; }
Example #3
Source File: TestRailClient.java From testrail-jenkins-plugin with Apache License 2.0 | 6 votes |
private TestRailResponse httpPost(String path, String payload) throws UnsupportedEncodingException, IOException, HTTPException { TestRailResponse response; do { response = httpPostInt(path, payload); if (response.getStatus() == 429) { try { Thread.sleep(60000); } catch (InterruptedException e) { log(e.toString()); } } } while (response.getStatus() == 429); return response; }
Example #4
Source File: RESTApiClusterManager.java From hbase with Apache License 2.0 | 6 votes |
private String getFromURIGet(URI uri) { LOG.trace("Executing GET against {} ...", uri); final Response response = client.target(uri) .request(MediaType.APPLICATION_JSON_TYPE) .get(); int statusCode = response.getStatus(); final String responseBody = response.readEntity(String.class); if (statusCode != Response.Status.OK.getStatusCode()) { LOG.warn( "request failed with status code {} and response body {}", statusCode, responseBody); throw new HTTPException(statusCode); } // This API folds information as the value to an "items" attribute. LOG.trace("GET against {} completed with status code {} and response body {}", uri, statusCode, responseBody); return responseBody; }
Example #5
Source File: XMLProviderArgumentBuilder.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
Example #6
Source File: RESTApiClusterManager.java From hbase with Apache License 2.0 | 5 votes |
/** * Issues a command (e.g. starting or stopping a role). * @return the commandId of a successfully submitted asynchronous command. */ private long doRoleCommand(String serviceName, String roleName, RoleCommand roleCommand) { URI uri = UriBuilder.fromUri(serverHostname) .path("api") .path(API_VERSION) .path("clusters") .path(clusterName) .path("services") .path(serviceName) .path("roleCommands") .path(roleCommand.toString()) .build(); String body = "{ \"items\": [ \"" + roleName + "\" ] }"; LOG.trace("Executing POST against {} with body {} ...", uri, body); WebTarget webTarget = client.target(uri); Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON); Response response = invocationBuilder.post(Entity.json(body)); final int statusCode = response.getStatus(); final String responseBody = response.readEntity(String.class); if (statusCode != Response.Status.OK.getStatusCode()) { LOG.warn( "RoleCommand failed with status code {} and response body {}", statusCode, responseBody); throw new HTTPException(statusCode); } LOG.trace("POST against {} completed with status code {} and response body {}", uri, statusCode, responseBody); return parser.parse(responseBody) .getAsJsonObject() .get("items") .getAsJsonArray() .get(0) .getAsJsonObject() .get("id") .getAsLong(); }
Example #7
Source File: XMLProviderArgumentBuilder.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
Example #8
Source File: XMLHandlerProcessor.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #9
Source File: XMLProviderArgumentBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
Example #10
Source File: XMLHandlerProcessor.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #11
Source File: DefaultAsyncCompletionHandlerTest.java From parsec-libraries with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = HTTPException.class) public void testWrongStatusCodeFail() throws Exception { Set<Integer> expected = new HashSet<>(); expected.add(200); when(mockResponse.getStatusCode()).thenReturn(500); DefaultAsyncCompletionHandler<String> handler = new DefaultAsyncCompletionHandler<>(String.class, expected); handler.onCompleted(mockResponse); }
Example #12
Source File: DefaultAsyncCompletionHandler.java From parsec-libraries with Apache License 2.0 | 5 votes |
@Override public T onCompleted(Response response) throws Exception { if (expectedStatusCodes.contains(response.getStatusCode())) { if (response.hasResponseBody()) { if (tClass == String.class) { return tClass.cast(response.getResponseBody()); } else { return objectMapper.readValue(response.getResponseBody(), tClass); } } return null; } else { throw new HTTPException(response.getStatusCode()); } }
Example #13
Source File: XMLHandlerProcessor.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #14
Source File: XMLHandlerProcessor.java From hottub with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #15
Source File: XMLProviderArgumentBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
Example #16
Source File: XMLHandlerProcessor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #17
Source File: XMLProviderArgumentBuilder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
Example #18
Source File: XMLHandlerProcessor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #19
Source File: XMLProviderArgumentBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
Example #20
Source File: XMLHandlerProcessor.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #21
Source File: XMLProviderArgumentBuilder.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
Example #22
Source File: XMLHandlerProcessor.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
final void insertFaultMessage(C context, ProtocolException exception) { if(exception instanceof HTTPException) { context.put(MessageContext.HTTP_RESPONSE_CODE,((HTTPException)exception).getStatusCode()); } if (context != null) { // non-soap case context.setPacketMessage(Messages.createEmpty(binding.getSOAPVersion())); } }
Example #23
Source File: XMLProviderArgumentBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }