Soap 连接中的流错误
我用java开发android应用程序。并且,该应用程序连接.net肥皂应用程序。没关系,它可以工作(我使用http post方法)。 我的实际问题是 Web 服务返回大量(特别是包含 html --cdata 源代码)数据。 因此,当我向 Web 服务请求(例如 getReports 方法)时,它返回大约 3 - 5 mb 流数据,导致内存不足。因此,我无法解析它。我知道我的连接方法不可能是真的。 如果我犯了错误,如何才能真正执行呢?
提前致谢。
String NAMESPACE = "http://tempuri.org/lorem";
String SURL = "http://www.test.com/lorem/test.asmx";
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
xml += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://tempuri.org/\">"
+ "<soapenv:Header/><soapenv:Body>"
+ "<web:getReport><web:strLang>strLang</web:strLang></web:getReport>"
+ "</soapenv:Body></soapenv:Envelope>";
URLConnection connection = url.openConnection();
HttpURLConnection httpconn = (HttpURLConnection) connection;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
bout.write(xml.getBytes());
byte[] b = bout.toByteArray();
httpconn.setRequestProperty("SOAPAction", Namespace+ "/" + "getReport");
httpconn.setRequestProperty("Accept-Encoding","gzip,deflate");
httpconn.setRequestProperty("Host","www.test.com");
httpconn.setRequestMethod("POST");
httpconn.setDoInput(true);
httpconn.setDoOutput(true);
httpconn.connect();
OutputStream out = httpconn.getOutputStream();
out.write(b);
InputStreamReader isr = new InputStreamReader(httpconn.getInputStream());
BufferedReader in = new BufferedReader(isr);
String inputLine = "";
StringBuffer parsingData = new StringBuffer();
while (null != (inputLine = in.readLine())) {
// OutOfMemory Error
parsingData.append(inputLine);
}
/*
* parsingMethods (parsingData);
*/
I develop android application in java. And, this application connects .net soap application. It is ok, it works (i use http post method).
My actual problem is web service returns big and huge (especially contains html --cdata source code) data.
So, when i request (such as, getReports methods) to web service, it returns about 3 - 5 mb stream data, causes outofmemory. Because of this, i couldn't parse it. I know my connection method cannot be true.
How can i implement truely if i make a mistake?
Thanks in advance.
String NAMESPACE = "http://tempuri.org/lorem";
String SURL = "http://www.test.com/lorem/test.asmx";
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
xml += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://tempuri.org/\">"
+ "<soapenv:Header/><soapenv:Body>"
+ "<web:getReport><web:strLang>strLang</web:strLang></web:getReport>"
+ "</soapenv:Body></soapenv:Envelope>";
URLConnection connection = url.openConnection();
HttpURLConnection httpconn = (HttpURLConnection) connection;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
bout.write(xml.getBytes());
byte[] b = bout.toByteArray();
httpconn.setRequestProperty("SOAPAction", Namespace+ "/" + "getReport");
httpconn.setRequestProperty("Accept-Encoding","gzip,deflate");
httpconn.setRequestProperty("Host","www.test.com");
httpconn.setRequestMethod("POST");
httpconn.setDoInput(true);
httpconn.setDoOutput(true);
httpconn.connect();
OutputStream out = httpconn.getOutputStream();
out.write(b);
InputStreamReader isr = new InputStreamReader(httpconn.getInputStream());
BufferedReader in = new BufferedReader(isr);
String inputLine = "";
StringBuffer parsingData = new StringBuffer();
while (null != (inputLine = in.readLine())) {
// OutOfMemory Error
parsingData.append(inputLine);
}
/*
* parsingMethods (parsingData);
*/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ksoap 确实支持标头,这里是如何实现的
Ksoap does support headers here is how