本文整理汇总了Java中org.apache.axiom.attachments.ByteArrayDataSource类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayDataSource类的具体用法?Java ByteArrayDataSource怎么用?Java ByteArrayDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayDataSource类属于org.apache.axiom.attachments包,在下文中一共展示了ByteArrayDataSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createEnvelope
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
private OMElement createEnvelope() throws Exception {
DataHandler expectedDH;
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
OMElement rpcWrapEle = fac.createOMElement("mtomSample", omNs);
data = fac.createOMElement("data", omNs);
expectedDH = new DataHandler(
new ByteArrayDataSource(new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
98 }));
OMElement subData = fac.createOMElement("subData", omNs);
OMText textData = new OMTextImpl(expectedDH, fac);
subData.addChild(textData);
data.addChild(subData);
rpcWrapEle.addChild(data);
return rpcWrapEle;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:EchoRawMTOMStreamingTest.java
示例2: JAXBProviderTests
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
public JAXBProviderTests() {
super();
//Create a DataSource from a String
String string = "Sending a JAXB generated string object to Source Provider endpoint";
stringDS = new ByteArrayDataSource(string.getBytes(),"text/plain");
try {
//Create a DataSource from an image
File file = new File(imageResourceDir + File.separator + "test.jpg");
ImageInputStream fiis = new FileImageInputStream(file);
Image image = ImageIO.read(fiis);
imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:JAXBProviderTests.java
示例3: generateAuthCode
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
/**
* Generates valid OAuth code to be used in SOAP requests.
* @param requestId
* @param timestamp
* @param token
* @return
*/
protected AuthCode generateAuthCode(RequestId requestId, Timestamp timestamp, AccessToken token) {
String originalText =
requestId.getRequestId().getGuid() + ";" +
timestamp.getTimestamp() + ";" +
APPLICATION_ID.getApplicationId() + ";" +
(token != null ? (token.getAccessToken() + ";") : "") +
getProperty("TALTIONI_SHARED_SECRET");
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-256");
md.update(originalText.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(md.digest(), "application/octet-stream"));
AuthCode authCode = new AuthCode();
authCode.setAuthCode(dataHandler);
return authCode;
}
开发者ID:Sensotrend,项目名称:moves2taltioni,代码行数:28,代码来源:TaltioniDataAccess.java
示例4: main
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
public static void main(String[] args) {
try {
MTOMServiceStub stub = new MTOMServiceStub(
"http://localhost:8088/axis2/services/MTOMService.MTOMServiceHttpSoap12Endpoint/");
String messageToSend = "Test message for binary data";
DataHandler dataHandler = null;
dataHandler = new DataHandler(new ByteArrayDataSource(messageToSend.getBytes()));
//first send it as base 64 binary
stub.getBinaryData(dataHandler);
//use mtome
stub._getServiceClient().getOptions().setProperty(
Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
dataHandler = new DataHandler(new ByteArrayDataSource(messageToSend.getBytes()));
stub.getBinaryData(dataHandler);
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
}
开发者ID:syodage,项目名称:Axis2-Samples,代码行数:24,代码来源:TestMTOMServiceStub.java
示例5: setDocumentPayloadRawData
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
@Override
public void setDocumentPayloadRawData(
SegmentDocumentResponse segmentDocumentResponse,
boolean packageAsXdm, String senderEmailAddress,
String recipientEmailAddress, XacmlResult xacmlResult)
throws Exception {
final ByteArrayDataSource rawData = documentEditor
.setDocumentPayloadRawData(segmentDocumentResponse
.getSegmentedDocumentXml(), packageAsXdm,
senderEmailAddress, recipientEmailAddress, xacmlResult,
segmentDocumentResponse
.getExecutionResponseContainerXml(), null, null);
segmentDocumentResponse.setDocumentPayloadRawData(new DataHandler(
rawData));
}
开发者ID:bhits,项目名称:dss-api,代码行数:16,代码来源:DocumentSegmentationImpl.java
示例6: testSetDocumentPayloadRawData
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
private void testSetDocumentPayloadRawData(boolean packageAsXdm) {
// Arrange
when(xacmlResultMock.getHomeCommunityId()).thenReturn(
"2.16.840.1.113883.3.467");
byte[] encryptionKeyBytes = null;
byte[] maskingKeyBytes = null;
ByteArrayDataSource rawData = null;
try {
final Key deSedeEncryptKey = EncryptTool.generateKeyEncryptionKey();
final Key deSedeMaskKey = EncryptTool.generateKeyEncryptionKey();
encryptionKeyBytes = deSedeEncryptKey.getEncoded();
maskingKeyBytes = deSedeMaskKey.getEncoded();
// Act
rawData = documentEditor.setDocumentPayloadRawData(c32,
packageAsXdm, "[email protected]", "[email protected]",
xacmlResultMock, ruleExecutionResponseContainer,
maskingKeyBytes, encryptionKeyBytes);
assertTrue(rawData.getInputStream().toString()
.startsWith("[email protected]"));
} catch (final Exception e) {
}
// Assert
assertNotNull(rawData);
assertTrue(rawData.toString().startsWith(
"[email protected]"));
assertEquals("application/octet-stream", rawData.getContentType());
}
开发者ID:bhits,项目名称:dss-api,代码行数:31,代码来源:DocumentEditorImplTest.java
示例7: deployService
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
protected void deployService(String serviceName, OMElement dssConfiguration) throws Exception {
DSSTestCaseUtils dssTest = new DSSTestCaseUtils();
Assert.assertTrue(dssTest.uploadArtifact(dssContext.getContextUrls().getBackEndUrl(), sessionCookie, serviceName,
new DataHandler(new ByteArrayDataSource(dssConfiguration.toString().getBytes()))),
"Service File Uploading failed");
Assert.assertTrue(dssTest.isServiceDeployed(dssContext.getContextUrls().getBackEndUrl(), sessionCookie, serviceName),
"Service Not Found, Deployment time out ");
}
开发者ID:wso2,项目名称:product-ei,代码行数:9,代码来源:DSSIntegrationTest.java
示例8: setEndpoints
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
protected DataHandler setEndpoints(DataHandler dataHandler)
throws XMLStreamException, IOException, XPathExpressionException {
if (isBuilderEnabled()) {
return dataHandler;
}
String config = readInputStreamAsString(dataHandler.getInputStream());
config = replaceEndpoints(config);
ByteArrayDataSource dbs = new ByteArrayDataSource(config.getBytes());
return new DataHandler(dbs);
}
开发者ID:wso2,项目名称:product-ei,代码行数:11,代码来源:ESBIntegrationTest.java
示例9: testSetDocumentPayloadRawData
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
private void testSetDocumentPayloadRawData(boolean packageAsXdm) {
// Arrange
when(xacmlResultMock.getHomeCommunityId()).thenReturn(
"2.16.840.1.113883.3.467");
byte[] encryptionKeyBytes = null;
byte[] maskingKeyBytes = null;
ByteArrayDataSource rawData = null;
try {
Key deSedeEncryptKey = EncryptTool.generateKeyEncryptionKey();
Key deSedeMaskKey = EncryptTool.generateKeyEncryptionKey();
encryptionKeyBytes = deSedeEncryptKey.getEncoded();
maskingKeyBytes = deSedeMaskKey.getEncoded();
// Act
rawData = documentEditor.setDocumentPayloadRawData(c32,
packageAsXdm, "[email protected]", "[email protected]",
xacmlResultMock, ruleExecutionResponseContainer,
maskingKeyBytes, encryptionKeyBytes);
logger.debug(rawData.toString());
logger.debug(rawData.getContentType());
logger.debug(rawData.getName());
logger.debug(rawData.getInputStream().toString());
assertTrue(rawData.getInputStream().toString()
.startsWith("[email protected]"));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
// Assert
assertNotNull(rawData);
assertTrue(rawData.toString().startsWith(
"[email protected]"));
assertEquals("application/octet-stream", rawData.getContentType());
}
开发者ID:tlin-fei,项目名称:ds4p,代码行数:36,代码来源:DocumentEditorImplTest.java
示例10: processDocument
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
public OMElement processDocument(InputStream inputStream,
String contentType,
MessageContext msgContext) throws AxisFault {
// TODO: this could be further optimized by deferring the read operation
byte[] msgBytes;
try {
msgBytes = IOUtils.toByteArray(inputStream);
} catch (IOException ex) {
throw new AxisFault("Unable to read message payload", ex);
}
return processDocument(new ByteArrayDataSource(msgBytes), contentType, msgContext);
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:13,代码来源:BinaryBuilder.java
示例11: getDataSource
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
public DataSource getDataSource(MessageContext messageContext,
OMOutputFormat format,
String soapAction) throws AxisFault {
return new ByteArrayDataSource(
getBytes(messageContext, format),
getContentType(messageContext, format, soapAction));
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:8,代码来源:MessageFormatterExAdapter.java
示例12: encode
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
public AxisMessage encode(ClientOptions options, byte[] message) throws Exception {
AxisMessage result = new AxisMessage();
result.setMessageType("application/octet-stream");
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
OMElement wrapper = factory.createOMElement(BaseConstants.DEFAULT_BINARY_WRAPPER);
DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(message));
wrapper.addChild(factory.createOMText(dataHandler, true));
envelope.getBody().addChild(wrapper);
result.setEnvelope(envelope);
return result;
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:13,代码来源:MessageEncoder.java
示例13: prepareMessage
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
@Override
protected XMLMessage prepareMessage() throws Exception {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMElement payload = factory.createOMElement(new QName("root"));
Attachments attachments = new Attachments();
attachments.addDataHandler(contentID, new DataHandler(new ByteArrayDataSource(attachmentContent, "application/octet-stream")));
return new XMLMessage(payload, XMLMessage.Type.SWA, attachments);
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:9,代码来源:SwATestCase.java
示例14: testretByteArray
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
/**
* Auto generated test method
*/
public void testretByteArray() throws java.lang.Exception {
byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
ComplexDataTypesDocLitBareStub.RetByteArray req = new ComplexDataTypesDocLitBareStub.RetByteArray();
req.setInByteArray(new DataHandler(new ByteArrayDataSource(input)));
DataHandler ret = stub.retByteArray(req).get_return();
byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
assertTrue(Arrays.equals(bytes, input));
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:ComplexDataTypesDocLitBareTest.java
示例15: testretByteArray
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
/**
* Auto generated test method
*/
public void testretByteArray() throws java.lang.Exception {
byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
DataHandler ret = stub.retByteArray(new DataHandler(new ByteArrayDataSource(input)));
byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
assertTrue(Arrays.equals(bytes, input));
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:12,代码来源:ComplexDataTypesComplexDataTypesSOAP11Test.java
示例16: createPayload
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
private OMElement createPayload() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
OMElement rpcWrapEle = fac.createOMElement("echoMTOMtoBase64", omNs);
OMElement data = fac.createOMElement("data", omNs);
byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, 98 };
DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
expectedTextData = new OMTextImpl(dataHandler, true, fac);
data.addChild(expectedTextData);
rpcWrapEle.addChild(data);
return rpcWrapEle;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:EchoRawMTOMToBase64Test.java
示例17: convertToBase64Binary
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
public static javax.activation.DataHandler convertToBase64Binary(String s) {
// reusing the byteArrayDataSource from the Axiom classes
if ((s == null) || s.equals("")){
return null;
}
ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(
Base64.decode(s)
);
return new DataHandler(byteArrayDataSource);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:11,代码来源:ConverterUtil.java
示例18: deployService
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
protected void deployService(String serviceName, OMElement dssConfiguration) throws Exception {
DSSTestCaseUtils dssTest = new DSSTestCaseUtils();
Assert.assertTrue(dssTest.uploadArtifact(dssServer.getBackEndUrl(), dssServer.getSessionCookie(), serviceName,
new DataHandler(new ByteArrayDataSource(dssConfiguration.toString().getBytes()))),
"Service File Uploading failed");
Assert.assertTrue(dssTest.isServiceDeployed(dssServer.getBackEndUrl(), dssServer.getSessionCookie(), serviceName),
"Service Not Found, Deployment time out ");
}
开发者ID:wso2-attic,项目名称:product-dss,代码行数:9,代码来源:DSSIntegrationUITest.java
示例19: publishTweet
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
public ItemId publishTweet( AccountType accountType,
String description,
String account,
String fileName,
byte[] file ) throws BridgeException {
BridgeAccountDao bridgeAccountDao = bridgeAccountService.getAccountByName(account, accountType);
PublishRequestE publishRequestE = new PublishRequestE();
PublishRequest publishRequest = new PublishRequest();
Message message = new Message();
message.setMessage(description);
publishRequest.setMessage(message);
File fileType = new File();
fileType.setFile(new DataHandler(new ByteArrayDataSource(file)));
publishRequest.setFile(fileType);
Filename filenameType = new Filename();
filenameType.setFilename(fileName);
publishRequest.setFilename(filenameType);
Lss lss = new Lss();
lss.setLss(account);
publishRequest.setLss(lss);
Token token = new Token();
token.setToken(bridgeAccountDao.getAccessToken());
publishRequest.setToken(token);
publishRequestE.setPublishRequest(publishRequest);
ItemId itemId = null;
if ( AccountType.FACEBOOKBRIDGE.equals(accountType) ) {
itemId = publishTweetToPort(publishRequestE, facebookService);
}
else if ( AccountType.FLICKRBRIDGE.equals(accountType) ) {
itemId = publishTweetToPort(publishRequestE, flickrService);
}
else if ( AccountType.TWITPICBRIDGE.equals(accountType) ) {
itemId = publishTweetToPort(publishRequestE, twitpicService);
}
return itemId;
}
开发者ID:voncuver,项目名称:cwierkacz,代码行数:40,代码来源:SsiAdapter.java
示例20: getContent
import org.apache.axiom.attachments.ByteArrayDataSource; //导入依赖的package包/类
@Override
public DataHandler getContent() {
ByteArrayDataSource rawData= new ByteArrayDataSource(this.content);
return new DataHandler(rawData);
}
开发者ID:wso2,项目名称:carbon-business-process,代码行数:6,代码来源:AttachmentDAOImpl.java
注:本文中的org.apache.axiom.attachments.ByteArrayDataSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论