本文整理汇总了Java中org.apache.axiom.attachments.ByteArrayDataSource类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayDataSource类的具体用法?Java ByteArrayDataSource怎么用?Java ByteArrayDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayDataSource类属于org.apache.axiom.attachments包,在下文中一共展示了ByteArrayDataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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));
}
示例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());
}
示例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 ");
}
示例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);
}
示例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());
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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));
}
示例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));
}