我试图通过在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