当前位置: 首页>>代码示例>>Java>>正文


Java WebServiceTransportException类代码示例

本文整理汇总了Java中org.springframework.ws.client.WebServiceTransportException的典型用法代码示例。如果您正苦于以下问题:Java WebServiceTransportException类的具体用法?Java WebServiceTransportException怎么用?Java WebServiceTransportException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WebServiceTransportException类属于org.springframework.ws.client包,在下文中一共展示了WebServiceTransportException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClient_Error_Exception

import org.springframework.ws.client.WebServiceTransportException; //导入依赖的package包/类
/**
 * Tests that the client throws an exception when receiving an error
 * message.
 *
 * @throws IOException
 *             if there is any problem loading the entity schema file
 */
@Test(expected = WebServiceTransportException.class)
public final void testClient_Error_Exception() throws IOException {
    final MockWebServiceServer mockServer; // Mocked server
    final ResponseCreator responseCreator; // Creator for the response

    // Creates the response
    responseCreator = ResponseCreators.withError("Error");

    // Creates the server mock
    mockServer = MockWebServiceServer.createServer(client);
    mockServer.expect(RequestMatchers.anything())
            .andRespond(responseCreator);

    // Calls the server mock
    client.getEntity("http:somewhere.com", entityId);
}
 
开发者ID:Bernardo-MG,项目名称:spring-ws-security-soap-example,代码行数:24,代码来源:TestDefaultEntityClientExceptionSoap.java

示例2: createAndConfigureWebServiceTemplate

import org.springframework.ws.client.WebServiceTransportException; //导入依赖的package包/类
private WebServiceTemplate createAndConfigureWebServiceTemplate(final SaajSoapMessage responseMessage,
		QName webServiceIdentifier, HttpServletRequest httpServletRequest) {
	WebServiceTemplate webServiceTemplate = new WebServiceTemplate(webServiceMessageFactory) {
		@Override
		protected Object handleError(WebServiceConnection connection, WebServiceMessage request) throws IOException {
			HttpResponse httpResponse = ((HttpComponentsConnection) connection).getHttpResponse();
			String statusAndCode = httpResponse.getStatusLine().getReasonPhrase() + " - "
					+ httpResponse.getStatusLine().getStatusCode();
			Charset charset = httpResponse.getEntity().getContentEncoding() != null
					&& httpResponse.getEntity().getContentEncoding().getValue() != null ? Charset
					.forName(httpResponse.getEntity().getContentEncoding().getValue()) : Charset.defaultCharset();
			String response = httpResponse.getEntity() != null ? StreamUtils.copyToString(httpResponse.getEntity()
					.getContent(), charset) : "N/A";
			throw new WebServiceTransportException("[Status: " + statusAndCode + "] [Reponse " + response + "]");
		}
	};
	webServiceTemplate.setMessageSender(createAndInitWebServiceMessageSender(webServiceIdentifier));
	// In case the target endpoint returns a clean SoapFault, the normal response callback is abandoned and the
	// FaulMessageResolver is invoked. In this case we want to return the fault unaltered to the client, so we set
	// it here as the response.
	webServiceTemplate.setFaultMessageResolver(new FaultMessageResolver() {
		@Override
		public void resolveFault(WebServiceMessage message) throws IOException {
			responseMessage.setSaajMessage(((SaajSoapMessage) message).getSaajMessage());
		}
	});

	List<ClientInterceptor> interceptors = new ArrayList<>();
	interceptors.add(new HttpRequestHeaderTransfererInterceptor(HttpRequestHeaderTransfererInterceptor
			.extractHeaders(httpServletRequest)));

	if (config.getCustomClientInterceptors(webServiceIdentifier) != null) {
		interceptors.addAll(config.getCustomClientInterceptors(webServiceIdentifier));
	}

	LOG.debug("Using interceptors:" + Arrays.toString(ClassUtils.toClass(interceptors.toArray())));

	webServiceTemplate.setInterceptors(interceptors.toArray(new ClientInterceptor[0]));
	return webServiceTemplate;
}
 
开发者ID:koen-serneels,项目名称:ws-proxy,代码行数:41,代码来源:ForwardingClient.java

示例3: expressionValid

import org.springframework.ws.client.WebServiceTransportException; //导入依赖的package包/类
protected void expressionValid(String expression, String errorMessage) {
	throw new WebServiceTransportException(errorMessage);
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:4,代码来源:WebServiceTransportExceptionGenerator.java


注:本文中的org.springframework.ws.client.WebServiceTransportException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。