本文整理汇总了Java中org.apache.cxf.message.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于org.apache.cxf.message包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSoapClient
import org.apache.cxf.message.Message; //导入依赖的package包/类
public <T> T createSoapClient(Class<T> serviceClass, URL endpoint, String namespace)
{
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
Bus bus = new ExtensionManagerBus(null, null, Bus.class.getClassLoader());
factory.setBus(bus);
factory.setServiceClass(serviceClass);
factory.setServiceName(new QName(namespace, serviceClass.getSimpleName()));
factory.setAddress(endpoint.toString());
factory.getServiceFactory().getServiceConfigurations().add(0, new XFireCompatabilityConfiguration());
factory.setDataBinding(new AegisDatabinding());
@SuppressWarnings("unchecked")
T soapClient = (T) factory.create();
Client client = ClientProxy.getClient(soapClient);
client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(600000);
policy.setAllowChunking(false);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
conduit.setClient(policy);
return soapClient;
}
示例2: sendErrorResponse
import org.apache.cxf.message.Message; //导入依赖的package包/类
private void sendErrorResponse(Message message, int responseCode) {
Message outMessage = getOutMessage(message);
outMessage.put(Message.RESPONSE_CODE, responseCode);
// Set the response headers
Map<String, List<String>> responseHeaders =
(Map<String, List<String>>)message.get(Message.PROTOCOL_HEADERS);
if (responseHeaders != null) {
responseHeaders.put("WWW-Authenticate", Arrays.asList(new String[]{"Basic realm=realm"}));
responseHeaders.put("Content-length", Arrays.asList(new String[]{"0"}));
}
message.getInterceptorChain().abort();
try {
getConduit(message).prepare(outMessage);
close(outMessage);
} catch (IOException e) {
log.error(e.getMessage()+" "+ e.getCause());
}
}
示例3: handleMessage
import org.apache.cxf.message.Message; //导入依赖的package包/类
/**
* Handles the {@link Connection} in the given {@link Message}.
* @see DBConnectionResponseInterceptor
*/
@Override
public void handleMessage(final Message message) throws Fault {
final Connection con = (Connection) message.getExchange().getInMessage().getContextualProperty(
DBConnectionContextProvider.PROPERTY_CONNECTION);
if(con != null) {
try {
final int responseCode = (int) message.get(Message.RESPONSE_CODE);
if(Family.familyOf(responseCode).equals(Family.SERVER_ERROR)) {
con.rollback();
}
else {
con.commit();
}
con.close();
}
catch(final SQLException e) {
LOGGER.error("Can't commit/rollback/close db connection because of an SQLException.", e);
}
}
}
示例4: createContext
import org.apache.cxf.message.Message; //导入依赖的package包/类
@Override
public ServiceContext createContext(Message message) {
ServiceContext serviceContext = null;
// get the current HttpServletRequest for building the service context
// instance.
HttpServletRequest request = (HttpServletRequest) message.getContextualProperty(PROPKEY_HTTP_REQUEST);
try {
// now we can create a service context
serviceContext = ServiceContextFactory.getInstance(request);
// done!
} catch (PortalException e) {
_log.warn("Failed creating service context: " + e.getMessage(), e);
}
// return the new instance.
return serviceContext;
}
示例5: createSoap
import org.apache.cxf.message.Message; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T createSoap(Class<T> serviceClass, URL endpoint, String namespace, Object previousSession)
{
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(serviceClass);
factory.setServiceName(new QName(namespace, serviceClass.getSimpleName()));
factory.setAddress(endpoint.toString());
List<AbstractServiceConfiguration> configs = factory.getServiceFactory().getServiceConfigurations();
configs.add(0, new XFireReturnTypeConfig());
factory.setDataBinding(new AegisDatabinding());
T service = (T) factory.create();
Client client = ClientProxy.getClient(service);
client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(600000);
policy.setAllowChunking(false);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
conduit.setClient(policy);
if( previousSession != null )
{
copyCookiesInt(conduit, previousSession);
}
return service;
}
示例6: configureMessage2
import org.apache.cxf.message.Message; //导入依赖的package包/类
@Test
public void configureMessage2() throws IllegalArgumentException {
final UserImportEntry entry = Mockito.mock(UserImportEntry.class);
Mockito.when(entry.getId()).thenThrow(new RuntimeException());
final BatchTaskVo<UserImportEntry> importTask = new BatchTaskVo<>();
importTask.setEntries(Collections.singletonList(entry));
final Message message = Mockito.mock(Message.class);
final UserFullLdapTask task = new UserFullLdapTask() {
@Override
protected Message getMessage() {
return message;
}
};
final Exchange exchange = Mockito.mock(Exchange.class);
Mockito.when(message.getExchange()).thenReturn(exchange);
final Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(exchange.getEndpoint()).thenReturn(endpoint);
Mockito.when(endpoint.get("org.apache.cxf.jaxrs.provider.ServerProviderFactory")).thenReturn(ServerProviderFactory.getInstance());
task.configure(importTask);
}
示例7: getMockMessage
import org.apache.cxf.message.Message; //导入依赖的package包/类
/**
* Creates a mock message that is destined for a method called "test"on
*/
private Message getMockMessage() throws NoSuchMethodException {
Message message = mock(Message.class);
Exchange exchange = mock(Exchange.class);
BindingOperationInfo bindingOperationInfo = mock(BindingOperationInfo.class);
Service service = mock(Service.class);
MethodDispatcher methodDispatcher = mock(MethodDispatcher.class);
Method method = TestClass.class.getMethod("test");
when(message.getExchange()).thenReturn(exchange);
when(exchange.get(BindingOperationInfo.class)).thenReturn(bindingOperationInfo);
when(exchange.get(Service.class)).thenReturn(service);
when(service.get(MethodDispatcher.class.getName())).thenReturn(methodDispatcher);
when(methodDispatcher.getMethod(bindingOperationInfo)).thenReturn(method);
return message;
}
示例8: handleValidation
import org.apache.cxf.message.Message; //导入依赖的package包/类
@Override
protected void handleValidation(final Message message, final Object resourceInstance, final Method method,
final List<Object> arguments) {
super.handleValidation(message, resourceInstance, method, arguments);
// Check each parameter
final Set<ConstraintViolation<?>> validationErrors = new HashSet<>();
for (int index = 0; index < arguments.size(); index++) {
final Parameter parameter = method.getParameters()[index];
if (hasToBeValidated(parameter)) {
// This parameter is a not context, path or query parameter
validate(arguments.get(index), method, parameter, index, validationErrors);
}
}
// Check the veto
if (!validationErrors.isEmpty()) {
message.put(FaultListener.class.getName(), new NoOpFaultListener());
throw new ConstraintViolationException(validationErrors);
}
}
示例9: testPopupalteExchangeFromCxfResponseOfNullBody
import org.apache.cxf.message.Message; //导入依赖的package包/类
@Test
public void testPopupalteExchangeFromCxfResponseOfNullBody() {
DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
Exchange exchange = new DefaultExchange(context);
org.apache.cxf.message.Exchange cxfExchange = new org.apache.cxf.message.ExchangeImpl();
exchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.PAYLOAD);
Map<String, Object> responseContext = new HashMap<String, Object>();
responseContext.put(org.apache.cxf.message.Message.RESPONSE_CODE, Integer.valueOf(200));
Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
responseContext.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, headers);
org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
cxfExchange.setInMessage(cxfMessage);
cxfBinding.populateExchangeFromCxfResponse(exchange, cxfExchange, responseContext);
CxfPayload<?> cxfPayload = exchange.getOut().getBody(CxfPayload.class);
assertNotNull(cxfPayload);
List<?> body = cxfPayload.getBody();
assertNotNull(body);
assertEquals(0, body.size());
}
示例10: createOutputStream
import org.apache.cxf.message.Message; //导入依赖的package包/类
protected OutputStream createOutputStream(Message message,
boolean needToCacheRequest,
boolean isChunking,
int chunkThreshold) throws IOException {
HttpURLConnection connection = (HttpURLConnection)message.get(KEY_HTTP_CONNECTION);
if (isChunking && chunkThreshold <= 0) {
chunkThreshold = 0;
connection.setChunkedStreamingMode(-1);
}
try {
return new URLConnectionWrappedOutputStream(message, connection,
needToCacheRequest,
isChunking,
chunkThreshold,
getConduitName());
} catch (URISyntaxException e) {
throw new IOException(e);
}
}
示例11: testPropagateCxfToCamel
import org.apache.cxf.message.Message; //导入依赖的package包/类
@Test
public void testPropagateCxfToCamel() {
Exchange exchange = new DefaultExchange(context);
org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
Map<String, List<String>> cxfHeaders = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
cxfHeaders.put("Content-Length", Arrays.asList("241"));
cxfHeaders.put("soapAction", Arrays.asList("urn:hello:world"));
cxfHeaders.put("myfruitheader", Arrays.asList("peach"));
cxfHeaders.put("mybrewheader", Arrays.asList("cappuccino", "espresso"));
cxfMessage.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, cxfHeaders);
Map<String, Object> camelHeaders = exchange.getIn().getHeaders();
CxfHeaderHelper.propagateCxfToCamel(new DefaultHeaderFilterStrategy(),
cxfMessage, camelHeaders, exchange);
assertEquals("urn:hello:world", camelHeaders.get("soapaction"));
assertEquals("urn:hello:world", camelHeaders.get("SoapAction"));
assertEquals("241", camelHeaders.get("content-length"));
assertEquals("peach", camelHeaders.get("MyFruitHeader"));
assertEquals(Arrays.asList("cappuccino", "espresso"), camelHeaders.get("MyBrewHeader"));
}
示例12: writeToOutputStream
import org.apache.cxf.message.Message; //导入依赖的package包/类
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) {
/**
* Yes, all this code is EXTREMELY ugly. But it gives about a 60-70% performance
* boost with the JAXB RI, so its worth it.
*/
if (s == null) {
return false;
}
String enc = (String)m.get(Message.ENCODING);
return info.getClass().getName().equals("org.apache.cxf.binding.soap.model.SoapBindingInfo")
&& s.getDataBinding().getClass().getName().equals("org.apache.cxf.jaxb.JAXBDataBinding")
&& !MessageUtils.isDOMPresent(m)
&& (enc == null || "UTF-8".equals(enc));
}
示例13: testPopupalteExchangeFromCxfRequestWithHeaderMerged
import org.apache.cxf.message.Message; //导入依赖的package包/类
@Test
public void testPopupalteExchangeFromCxfRequestWithHeaderMerged() {
DefaultCxfBinding cxfBinding = new DefaultCxfBinding();
cxfBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
Exchange exchange = new DefaultExchange(context);
exchange.setProperty(CxfConstants.CAMEL_CXF_PROTOCOL_HEADERS_MERGED, Boolean.TRUE);
org.apache.cxf.message.Exchange cxfExchange = new org.apache.cxf.message.ExchangeImpl();
exchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.PAYLOAD);
org.apache.cxf.message.Message cxfMessage = new org.apache.cxf.message.MessageImpl();
Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
headers.put("myfruitheader", Arrays.asList("peach"));
headers.put("mybrewheader", Arrays.asList("cappuccino", "espresso"));
cxfMessage.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, headers);
cxfExchange.setInMessage(cxfMessage);
cxfBinding.populateExchangeFromCxfRequest(cxfExchange, exchange);
Map<String, Object> camelHeaders = exchange.getIn().getHeaders();
assertNotNull(camelHeaders);
assertEquals("peach", camelHeaders.get("MyFruitHeader"));
assertEquals("cappuccino, espresso", camelHeaders.get("MyBrewHeader"));
}
示例14: compare
import org.apache.cxf.message.Message; //导入依赖的package包/类
@Override
public int compare(
ClassResourceInfo cri1, ClassResourceInfo cri2, Message message) {
ResourceProvider rp1 = cri1.getResourceProvider();
ResourceProvider rp2 = cri2.getResourceProvider();
if (rp1 instanceof ServiceReferenceResourceProvider &&
rp2 instanceof ServiceReferenceResourceProvider) {
return comparator.compare(
(ServiceReferenceResourceProvider)rp2,
(ServiceReferenceResourceProvider)rp1);
}
if (rp1 instanceof ServiceReferenceResourceProvider) {
return -1;
}
if (rp2 instanceof ServiceReferenceResourceProvider) {
return 1;
}
return 0;
}
示例15: createCXFClient
import org.apache.cxf.message.Message; //导入依赖的package包/类
protected static ReportIncidentEndpoint createCXFClient(String url) {
List<Interceptor<? extends Message>> outInterceptors = new ArrayList<Interceptor<? extends Message>>();
// Define WSS4j properties for flow outgoing
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put("action", "UsernameToken Timestamp");
outProps.put("passwordType", "PasswordDigest");
outProps.put("user", "charles");
outProps.put("passwordCallbackClass", "org.apache.camel.example.reportincident.UTPasswordCallback");
WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);
// Add LoggingOutInterceptor
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
outInterceptors.add(wss4j);
outInterceptors.add(loggingOutInterceptor);
// we use CXF to create a client for us as its easier than JAXWS and works
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setOutInterceptors(outInterceptors);
factory.setServiceClass(ReportIncidentEndpoint.class);
factory.setAddress(url);
return (ReportIncidentEndpoint) factory.create();
}