本文整理汇总了Java中org.apache.axiom.om.OMFactory.createOMText方法的典型用法代码示例。如果您正苦于以下问题:Java OMFactory.createOMText方法的具体用法?Java OMFactory.createOMText怎么用?Java OMFactory.createOMText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.OMFactory
的用法示例。
在下文中一共展示了OMFactory.createOMText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendUsingMTOM
import org.apache.axiom.om.OMFactory; //导入方法依赖的package包/类
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException {
final String EXPECTED = "<m0:uploadFileUsingMTOMResponse xmlns:m0=\"http://services.samples\"><m0:response>" +
"<m0:image>PHByb3h5PkFCQzwvcHJveHk+</m0:image></m0:response></m0:uploadFileUsingMTOMResponse>";
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
OMElement request = factory.createOMElement("request", ns);
OMElement image = factory.createOMElement("image", ns);
FileDataSource fileDataSource = new FileDataSource(new File(fileName));
DataHandler dataHandler = new DataHandler(fileDataSource);
OMText textData = factory.createOMText(dataHandler, true);
image.addChild(textData);
request.addChild(image);
payload.addChild(request);
ServiceClient serviceClient = new ServiceClient();
Options options = new Options();
options.setTo(new EndpointReference(targetEPR));
options.setAction("urn:uploadFileUsingMTOM");
options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
options.setCallTransportCleanup(true);
serviceClient.setOptions(options);
OMElement response = serviceClient.sendReceive(payload);
Assert.assertTrue(response.toString().contains(EXPECTED), "Attachment is missing in the response");
}
示例2: sendUsingMTOM
import org.apache.axiom.om.OMFactory; //导入方法依赖的package包/类
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
OMElement request = factory.createOMElement("request", ns);
OMElement image = factory.createOMElement("image", ns);
FileDataSource fileDataSource = new FileDataSource(new File(fileName));
DataHandler dataHandler = new DataHandler(fileDataSource);
OMText textData = factory.createOMText(dataHandler, true);
image.addChild(textData);
request.addChild(image);
payload.addChild(request);
ServiceClient serviceClient = new ServiceClient();
Options options = new Options();
options.setTo(new EndpointReference(targetEPR));
options.setAction("urn:uploadFileUsingMTOM");
options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
options.setCallTransportCleanup(true);
serviceClient.setOptions(options);
OMElement response = serviceClient.sendReceive(payload);
Assert.assertTrue(response.toString().contains(
"<m:testMTOM xmlns:m=\"http://services.samples/xsd\">" + "<m:test1>testMTOM</m:test1></m:testMTOM>"));
}
示例3: getHeader
import org.apache.axiom.om.OMFactory; //导入方法依赖的package包/类
private OMElement getHeader(OMFactory factory) {
OMElement header = factory.createOMElement("header", null);
OMElement msgType = factory.createOMElement("field", null);
msgType.addAttribute(factory.createOMAttribute("id", null, "35"));
factory.createOMText(msgType, "D");
header.addChild(msgType);
OMElement sendingTime = factory.createOMElement("field", null);
sendingTime.addAttribute(factory.createOMAttribute("id", null, "52"));
factory.createOMText(sendingTime, new Date().toString());
header.addChild(sendingTime);
return header;
}
示例4: getBody
import org.apache.axiom.om.OMFactory; //导入方法依赖的package包/类
private OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) {
OMElement body = factory.createOMElement("body", null);
OMElement clordID = factory.createOMElement("field", null);
clordID.addAttribute(factory.createOMAttribute("id", null, "11"));
factory.createOMText(clordID, "122333");
body.addChild(clordID);
OMElement handleIns = factory.createOMElement("field", null);
handleIns.addAttribute(factory.createOMAttribute("id", null, "21"));
factory.createOMText(handleIns, "1");
body.addChild(handleIns);
OMElement qty = factory.createOMElement("field", null);
qty.addAttribute(factory.createOMAttribute("id", null, "38"));
factory.createOMText(qty, qtyValue);
body.addChild(qty);
OMElement ordType = factory.createOMElement("field", null);
ordType.addAttribute(factory.createOMAttribute("id", null, "40"));
factory.createOMText(ordType, "1");
body.addChild(ordType);
OMElement side = factory.createOMElement("field", null);
side.addAttribute(factory.createOMAttribute("id", null, "54"));
factory.createOMText(side, mode);
body.addChild(side);
OMElement symbol = factory.createOMElement("field", null);
symbol.addAttribute(factory.createOMAttribute("id", null, "55"));
factory.createOMText(symbol, text);
body.addChild(symbol);
OMElement timeInForce = factory.createOMElement("field", null);
timeInForce.addAttribute(factory.createOMAttribute("id", null, "59"));
factory.createOMText(timeInForce, "0");
body.addChild(timeInForce);
return body;
}
示例5: getHeader
import org.apache.axiom.om.OMFactory; //导入方法依赖的package包/类
private static OMElement getHeader(OMFactory factory) {
OMElement header = factory.createOMElement("header", null);
OMElement msgType = factory.createOMElement("field", null);
msgType.addAttribute(factory.createOMAttribute("id", null, "35"));
factory.createOMText(msgType, "D");
header.addChild(msgType);
OMElement sendingTime = factory.createOMElement("field", null);
sendingTime.addAttribute(factory.createOMAttribute("id", null, "52"));
factory.createOMText(sendingTime, new Date().toString());
header.addChild(sendingTime);
return header;
}
示例6: getBody
import org.apache.axiom.om.OMFactory; //导入方法依赖的package包/类
private static OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) {
OMElement body = factory.createOMElement("body", null);
OMElement clordID = factory.createOMElement("field", null);
clordID.addAttribute(factory.createOMAttribute("id", null, "11"));
factory.createOMText(clordID, "122333");
body.addChild(clordID);
OMElement handleIns = factory.createOMElement("field", null);
handleIns.addAttribute(factory.createOMAttribute("id", null, "21"));
factory.createOMText(handleIns, "1");
body.addChild(handleIns);
OMElement qty = factory.createOMElement("field", null);
qty.addAttribute(factory.createOMAttribute("id", null, "38"));
factory.createOMText(qty, qtyValue);
body.addChild(qty);
OMElement ordType = factory.createOMElement("field", null);
ordType.addAttribute(factory.createOMAttribute("id", null, "40"));
factory.createOMText(ordType, "1");
body.addChild(ordType);
OMElement side = factory.createOMElement("field", null);
side.addAttribute(factory.createOMAttribute("id", null, "54"));
factory.createOMText(side, mode);
body.addChild(side);
OMElement symbol = factory.createOMElement("field", null);
symbol.addAttribute(factory.createOMAttribute("id", null, "55"));
factory.createOMText(symbol, text);
body.addChild(symbol);
OMElement timeInForce = factory.createOMElement("field", null);
timeInForce.addAttribute(factory.createOMAttribute("id", null, "59"));
factory.createOMText(timeInForce, "0");
body.addChild(timeInForce);
return body;
}
示例7: uploadFileUsingMTOM
import org.apache.axiom.om.OMFactory; //导入方法依赖的package包/类
public OMElement uploadFileUsingMTOM(OMElement request) throws Exception {
OMText binaryNode = (OMText) request.
getFirstChildWithName(new QName("http://services.samples", "request")).
getFirstChildWithName(new QName("http://services.samples", "image")).
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 MTOM content to temp file : " + tempFile.getAbsolutePath());
OMFactory factory = request.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
OMElement payload = factory.createOMElement("uploadFileUsingMTOMResponse", ns);
OMElement response = factory.createOMElement("response", ns);
OMElement image = factory.createOMElement("image", ns);
FileDataSource fileDataSource = new FileDataSource(tempFile);
dataHandler = new DataHandler(fileDataSource);
OMText textData = factory.createOMText(dataHandler, true);
image.addChild(textData);
response.addChild(image);
payload.addChild(response);
MessageContext outMsgCtx = MessageContext.getCurrentMessageContext()
.getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
outMsgCtx.setProperty(
org.apache.axis2.Constants.Configuration.ENABLE_MTOM,
org.apache.axis2.Constants.VALUE_TRUE);
return payload;
}