2012-05-22 31 views
1

我有這樣的響應消息:如何通過名稱調解OMElement?

<message> 
    <header> 
     <TransactionID>1</TransactionID> 
     <Timestamp>2012-05-22 10:10:36</Timestamp> 
     <OpCode>BOSS_DELETE_USER_SME.CD</OpCode> 
     <MsgType>RESP</MsgType> 
     <ReturnCode>1016</ReturnCode> 
     <ErrorMessage>uif return error message!</ErrorMessage> 
    </header> 
</message> 

我需要擴展類轉換RetuenCode「1016」到「0」。如何獲得OMElement「ReturnCode」中介?我的代碼失敗了。

SOAPEnvelope envelope = context.getEnvelope(); 
SOAPBody soapBody = envelope.getBody(); 
QName ReturnCode = new QName(null, "ReturnCode");  
OMElement response = soapBody.getFirstChildWithName(ReturnCode); 

回答

1

的部分

<header> 

它是SOAP體裏面?如果首先出現這種情況,則需要從SOAP正文中獲取Header元素,然後從該元素中獲取名爲ReturnCode的第一個子元素。

歡呼聲, Charith

+0

是的,它在SOAP主體。但是如何獲得元素「ReturnCode」。我想通過名稱獲得它,但失敗了。如何在媒體中按名稱獲取元素?你可以幫幫我嗎?非常感謝你。 – luohao

+0

非常感謝。我已經解決了這個問題 – luohao