我試圖通過在Eclipse中使用BlackBerry Java插件在字符串中傳遞請求xml來使用SOAP響應xml。過去兩天我一直在尋找解決方法。黑莓 - 沒有得到肥皂響應xml
我附上了下面的示例代碼。
public String CheckXml()
{
final String requestXml="<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\"><header xmlns=\"http://schemas.cordys.com/General/1.0/\"></header><SOAP:Body><authenticateAgainstOID xmlns=\"http://schemas.cordys.com/OIDAuthentication\"><stringParam>HEMANTS_MUM013</stringParam><stringParam1>TATA2012</stringParam1></authenticateAgainstOID></SOAP:Body></SOAP:Envelope>";
final String HOST_ADDRESS = "http://xyz.com/cordys/com.eibus.web.soap.Gateway.wcp?organization=o=B2C,cn=cordys,cn=cbop,o=tatamotors.com&SAMLart=MDFn+8e5dRDaRMRIwMY7nI84eEccbx+lIiV0VhsOQ7u+SKG6n5+WNB58";
String result="";
try {
HttpConnection url=(HttpConnection)Connector.open(HOST_ADDRESS);
url.setRequestProperty("Content-Type", "text/xml");
url.setRequestMethod(HttpConnection.GET);
OutputStreamWriter writer=new OutputStreamWriter(url.openOutputStream());
writer.write(requestXml);
writer.flush();
writer.close();
StringBuffer buffer1=new StringBuffer();
InputStreamReader reader=new InputStreamReader(url.openInputStream());
StringBuffer buffer=new StringBuffer();
char[] cbuf=new char[2048];
int num;
while (-1 != (num = reader.read(cbuf))) {
buffer.append(cbuf, 0, num);
}
String result1 = buffer.toString();
} catch (Exception e) {
System.out.println(e);
}
return result;
}
我試圖也用於檢查http連接,我在這裏發佈的代碼,如果(url.getResponseCode()== HttpConnection.HTTP_OK) \t \t { \t \t \t的InputStream的inputStream = url.openInputStream() ; \t \t \t buffer.append(IOUtilities.streamToBytes(inputStream)); \t \t \t result = buffer.toString(); \t \t \t \t \t}但它不適合我 – Pramodhini
你得到了什麼?有一些例外?也許你需要設置一些接受標題。你可以嗅探桌面客戶端,並檢查它發送到服務器的標題/也許你需要改變方法從GET到POST。 –
嗨改變和檢查後,仍然現在得到相同的錯誤,像類沒有找到inputstreamreader線附近。 – Pramodhini