本文整理匯總了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;
}