use of org.apache.camel.Converter in project camel by apache.
the class CxfConverter method soapMessageToString.
@Converter
public static String soapMessageToString(final SOAPMessage soapMessage, Exchange exchange) throws SOAPException, IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
soapMessage.writeTo(baos);
return baos.toString(IOHelper.getCharsetName(exchange));
}
use of org.apache.camel.Converter in project camel by apache.
the class CxfConverter method soapMessageToInputStream.
@Converter
public static InputStream soapMessageToInputStream(final SOAPMessage soapMessage, Exchange exchange) throws SOAPException, IOException {
CachedOutputStream cos = new CachedOutputStream(exchange);
soapMessage.writeTo(cos);
InputStream in = cos.getInputStream();
return in;
}
use of org.apache.camel.Converter in project camel by apache.
the class MinaConverter method toByteBuffer.
@Converter
public static ByteBuffer toByteBuffer(byte[] bytes) {
ByteBuffer buf = ByteBuffer.allocate(bytes.length);
buf.put(bytes);
return buf;
}
use of org.apache.camel.Converter in project camel by apache.
the class Mina2Converter method toIoBuffer.
@Converter
public static IoBuffer toIoBuffer(byte[] bytes) {
IoBuffer buf = IoBuffer.allocate(bytes.length);
buf.put(bytes);
return buf;
}
use of org.apache.camel.Converter in project camel by apache.
the class DnsRecordConverter method toRecord.
/**
* @param ip, like "192.168.1.1"
* @return the complete DNS record for that IP.
*/
@Converter
public static Record toRecord(String ip) throws IOException {
Resolver res = new ExtendedResolver();
Name name = ReverseMap.fromAddress(ip);
int type = Type.PTR;
int dclass = DClass.IN;
Record rec = Record.newRecord(name, type, dclass);
Message query = Message.newQuery(rec);
Message response = res.send(query);
Record[] answers = response.getSectionArray(Section.ANSWER);
if (answers.length == 0) {
return null;
} else {
return answers[0];
}
}
Aggregations