2011-09-06 13 views
0

私はJavaでアンドロイドアプリケーションを開発します。そして、このアプリケーションは.net soapアプリケーションに接続します。それは大丈夫、それは動作します(私はhttpのpostメソッドを使用します)。 私の実際の問題は、Webサービスが大きくて巨大な(特にHTML - データソースコードを含む)データを返すことです。 それで、WebサービスにgetReportsメソッドなどのリクエストをすると、約3〜5MBのストリームデータが返され、outofmemoryが発生します。このため、私はそれを解析することができませんでした。私は自分の接続方法が真実ではないことを知っています。 私は間違いを犯すと真に実装できますか?石鹸接続のストリームエラー

ありがとうございます。

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); 
*/ 
+0

あなたはKSOAPをしようと試みたかありますか? http://code.google.com/p/ksoap2-android/wiki/HowToUse – PedroAGSantos

+0

はい、私は多くの方法を試してみました。このように、最初に保存されたsdcardをファイルとして保存し、それを読み込み解析します。しかし、すべてのデバイスはsdcardを持っていません。そうではない。他の方法として、私は、.netサーバーに要求するjsp Webサーバーを作成し、解析としてデータを返します。最後に、私はそれを簡単に得る、そうではありません。最後に、ksoapをやろうとしました。それは私のhttpヘッダーをサポートしません..パフ,,,, –

答えて

0

Ksoapは、ここではサポートヘッダを行い

Element AuthHeader = new Element(); 
AuthHeader.setName("Auth"); 
AuthHeader.setNamespace(namespace); 

Element element = new Element(); 
element.setName("Username"); 
element.setNamespace(namespace); 
element.addChild(Element.TEXT, username); 
AuthHeader.addChild(Element.ELEMENT, element); 

element = new Element(); 
element.setName("Password"); 
element.setNamespace(namespace); 
element.addChild(Element.TEXT, password); 
AuthHeader.addChild(Element.ELEMENT, element); 

headers[0] = AuthHeader; 

envelope.headerOut = headers; 
+0

あなたの意見をありがとうが、私の問題は大きなデータです。 Webサービスは、3〜5MBのストリームデータを返します。とにかくアプリケーションは、すべてのストリームデータを取得中にoutofmemoryを引き起こします。 –

+0

こんにちは。それは何のデータですか? – Pintac