【发布时间】:2012-01-11 03:39:13
【问题描述】:
请帮我解决以下问题,我尝试了很长时间(3 周)但无法获得正确的解决方案。我必须尽快完成它,因为我的这么多 web 服务输出取决于自定义返回字符串.
我已经使用 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 响应/输出字符串 :::::::::
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 sn-p。