2011-03-22 78 views
0

Iam能夠使用MTOM-XOP以價值觀念上傳圖像。之後,我嘗試通過引用概念(XOP:Include)使用MTOM-XOP上傳相同的圖像。Iam能夠編寫客戶端程序並生成OMElement並傳遞給服務also.But在這裏我strucked.I不知道如何處理引用的圖像和寫入到指定的文件夾。我搜索谷歌,但發現了許多樣本和解決方案的價值觀念和SWA concept.Please給我指導或示例程序在服務器端處理OMElement?如何使用MTOM-XOP概念在服務器端處理OMElement?

的OMElement:

<fd:upload xmlns:fd="http://mtom.sample.com"><fd:fileName>dog</fd:fileName><fd:fileType>jpg</fd:fileType><fd:fileContent><axis2ns1:Include xmlns:axis2ns1="http://www.w3.org/2004/08/xop/include" href="[email protected]" /></fd:fileContent></fd:upload> 

如何處理href屬性,我發現解決方案,

ArrayList<OMElement> xops =AttachmentUtils.findXopElements(element); 
     if (xops != null && xops.size() > 0) { 
      logFile("Found XOP:Include Elements\n"); 
     } 
     QName href = new QName("","href"); 
     Iterator<OMElement> itr = xops.iterator(); 
     while (itr.hasNext()) { 
      OMElement xop = itr.next(); 
      String cid = xop.getAttributeValue(href); 
      logFile("CID :"+cid+"\n"); 
     } 

但是,這部分在服務器不執行side.Please給我們以此爲指導。

謝謝。

回答

0

Axiom使用isBinary()返回true的OMText節點表示XOP/MTOM附件。這個節點是爲每個xop創建的:在原始消息中包含元素。在這裏描述的情況下,可以檢索fd:fileContent元素的第一個子元素,將其轉換爲OMText,然後在該對象上調用getDataHandler()。返回的DataHandler可以訪問附件的內容。