本文整理汇总了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 +"'." );
}