本文整理匯總了Java中javax.activation.DataHandler.getContent方法的典型用法代碼示例。如果您正苦於以下問題:Java DataHandler.getContent方法的具體用法?Java DataHandler.getContent怎麽用?Java DataHandler.getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.activation.DataHandler
的用法示例。
在下文中一共展示了DataHandler.getContent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validate
import javax.activation.DataHandler; //導入方法依賴的package包/類
void validate(Object ret, Call call, final String expOrdPattern) throws Exception{
if (null == ret) {
System.out.println("Received null ");
throw new AxisFault("", "Received null", null, null);
}
if (ret instanceof String) {
System.out.println("Received problem response from server: " + ret);
throw new AxisFault("", (String) ret, null, null);
}
Vector vret= (Vector) ret;
if (!(ret instanceof java.util.Vector )) {
//The wrong type of object that what was expected.
System.out.println("Received unexpected type :" +
ret.getClass().getName());
throw new AxisFault("", "Received unexpected type:" +
ret.getClass().getName(), null, null);
}
org.apache.axis.message.RPCElement retrpc= (org.apache.axis.message.RPCElement )
((Vector)ret).elementAt(0);
Document retDoc= org.apache.axis.utils.XMLUtils.newDocument(
new org.xml.sax.InputSource(new java.io.ByteArrayInputStream(
retrpc.toString().getBytes())));
//get at the attachments.
org.apache.axis.attachments.Attachments attachments=
call.getResponseMessage().getAttachmentsImpl();
//Still here, so far so good.
Element rootEl= retDoc.getDocumentElement();
Element caEl= getNextFirstChildElement(rootEl);
//this should be the only child element with the ref to our attachment
// response.
String href= caEl.getAttribute("href");
org.apache.axis.Part p= attachments.getAttachmentByReference(href);
if(null == p)
throw new org.apache.axis.AxisFault("Attachment for ref='"+href+"' not found." );
//Check to see the the attachment were sent in order
String ordPattern= caEl.getAttribute("ordinalPattern");
if(!expOrdPattern.equals(ordPattern))
throw new org.apache.axis.AxisFault(
"Attachments sent out of order expected:'" +expOrdPattern + "', got:'"+ordPattern+"'." );
//now get at the data...
DataHandler dh= ((org.apache.axis.attachments.AttachmentPart)p).getDataHandler();
System.err.println("content-type:" + dh.getContentType());
java.util.Vector rspVector= null;
Object rspObject = dh.getContent();//This SHOULD just return the vector but reality strikes...
if(rspObject == null)
throw new AxisFault("", "Received unexpected object:null", null, null);
else if(rspObject instanceof java.util.Vector) rspVector= (java.util.Vector)rspObject;
else if(rspObject instanceof java.io.InputStream)
rspVector= (java.util.Vector)
new java.io.ObjectInputStream((java.io.InputStream)rspObject ).readObject();
else
throw new AxisFault("", "Received unexpected object:" +
rspObject.getClass().getName(), null, null);
StringBuffer fullmsg= new StringBuffer();
for(java.util.Iterator ri= rspVector.iterator(); ri.hasNext();){
String part= (String)ri.next();
fullmsg.append(part);
System.out.print(part);
}
System.out.println("");
if(!(TheKey.equals (fullmsg.toString())))
throw new org.apache.axis.AxisFault("Fullmsg not correct'"+fullmsg +"'." );
}