-3
請幫我解決以下問題,我嘗試了很長時間(3周),但無法獲得正確的解決方案。我必須儘快完成它,因爲我的許多web服務輸出取決於自定義返回字符串。如何使用java從SOAP響應中刪除(<)和([CDATA [[))?
我已經使用javax.jws編寫了java代碼。
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;
String returnStr = null;
String responseCodeStart = "<responseCode>";
String responseCodeEnd = "</responseCode>";
String responseMessageStart = "<responseMessage>";
String responseMessageEnd = "</responseMessage>";
返回自定義字串在JAVA到SOAP響應/輸出String :::::::::
returnStr = "\r\n" + responseCodeStart + "1000" + responseCodeEnd + "\r\n" + responseMessageStart + "Registration successful>>" + responseMessageEnd + "\r\n";
問題:
1) I am getting (<) tag instead of (<)
2) I am getting ([CDATA[[) tag in response.
SOAP響應:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:registerUserResponse xmlns:ns2="http://impl.timecapsule.com/">
<return><responseCode>1102</responseCode>
<responseMessage> [!CDATA[[Please provide username] </responseMessage></return>
</ns2:registerUserResponse>
</soap:Body>
</soap:Envelope>
* 分辨率需要: *
1) < to remove
2) CDATA to remove
I want to retrieve it as XML object instead of String using java code.
THANKS
這個問題是一個火車事故,請考慮您的固定格式問題,並提供更完整的Java代碼片斷。 – 2012-01-11 16:13:54