本文整理汇总了Java中org.apache.axiom.om.OMElement.getFirstOMChild方法的典型用法代码示例。如果您正苦于以下问题:Java OMElement.getFirstOMChild方法的具体用法?Java OMElement.getFirstOMChild怎么用?Java OMElement.getFirstOMChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.OMElement
的用法示例。
在下文中一共展示了OMElement.getFirstOMChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: oneWayUploadUsingMTOM
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public void oneWayUploadUsingMTOM(OMElement element) throws Exception {
OMText binaryNode = (OMText) element.getFirstOMChild();
DataHandler dataHandler = (DataHandler) binaryNode.getDataHandler();
InputStream is = dataHandler.getInputStream();
File tempFile = File.createTempFile("mtom-", ".gif");
FileOutputStream fos = new FileOutputStream(tempFile);
BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
byte data[] = new byte[BUFFER];
int count;
while ((count = is.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
System.out.println("Wrote to file : " + tempFile.getAbsolutePath());
}
示例2: mediate
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public boolean mediate(MessageContext msgCtx) {
try {
log.debug("BinaryExtractMediator Process, with offset: "+offset+" ,length "+length);
SOAPBody soapBody = msgCtx.getEnvelope().getBody();
OMElement firstElement = soapBody.getFirstElement();
log.debug("First Element : "+firstElement.getLocalName());
log.debug("First Element Text : "+firstElement.getText());
OMText binaryNode =(OMText) firstElement.getFirstOMChild();
log.debug("First Element Node Text : "+binaryNode.getText());
DataHandler dataHandler =(DataHandler) binaryNode.getDataHandler();
InputStream inputStream = dataHandler.getInputStream();
byte[] searchByte = new byte[length];
inputStream.skip(offset - 1);
int readBytes = inputStream.read(searchByte,0,length);
String outString = new String(searchByte,binaryEncoding);
msgCtx.setProperty(variableName,outString);
log.debug("Set property to MsgCtx, "+variableName+" = "+outString);
inputStream.close();
} catch (IOException e) {
log.error("Excepton on mediation : "+e.getMessage());
}
return true;
}