2012-01-11 2 views
-1

휴대 전화에서 앱을 실행하지만 에뮬레이터에서 작업하는 중에 다음 오류가 발생합니다.SAX 파서가 전화기에서는 작동하지 않지만 에뮬레이터에서는 작동하는 이유는 무엇입니까?

HttpClient client = new DefaultHttpClient(); 
    HttpPost httppost = new HttpPost(BMIConstant.Url + "ValidLoginUser"); 
    List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>(); 
    password = etxt_pass.getText().toString().trim(); 
    username = etxt_user.getText().toString().trim(); 
    nvps.add(new BasicNameValuePair("Emailaddress", username)); 
    nvps.add(new BasicNameValuePair("Password", password)); 
    System.out.println("user name is--->"+username+ " password---->"+password); 
    System.out.println(httppost.getRequestLine()); 

    try { 
     UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8); 
     httppost.setEntity(p_entity); 
     HttpResponse response = client.execute(httppost); 
     HttpEntity responseEntity = response.getEntity();   
     SAXParserFactory spf = SAXParserFactory.newInstance(); 
     SAXParser sp = spf.newSAXParser(); 
     XMLReader xr = sp.getXMLReader(); 
     LoginHandler myLoginHandler = new LoginHandler(); 
     xr.setContentHandler(myLoginHandler); 
     xr.parse(new InputSource(responseEntity.getContent())); 
     LoginParser myLoginParser = myLoginHandler.parser; 
     System.out.println("return code is---->"+myLoginParser.getCode()); 

     id = Integer.parseInt(myLoginParser.getCode()); 

    } catch (Exception e) { 
     e.printStackTrace(); 

     removeDialog(0); 
    } 

01-11 12 : 47 : 15.194 : System.err에/W (7300) : $ org.apache.harmony.xml.ExpatParser는 ParseException은 : 행 20 열 76 (무효가 잘 형성되지 토큰) 01-11 12 : 47 : 15.194 : System.err에/W (7300) : org.apache.harmony.xml.ExpatParser.parseFragment (ExpatParser.java:523)에서 01-11 12 : 47 : 15.194 : W/System.err (7300) : org.apache.harmony.xml.ExpatParser.parseDocument (ExpatParser.java:482) 01-11 12 : 47 : 15.194 : System.err (7300) : org. org.apache.harmony.xml.ExpatReader.parse (ExpatReader.java : 320) 01-11 12 : 47 : 15.204 java : 277) 01-11 12 : 47 : 15.204 : W/System.err (73 00) : com.apps.clx.bouncemein.WelcomeActivity.tryLogin (WelcomeActivity.java:258) 01-11 12 : 47 : 15.204 : System.err (7300) : com.apps.clx.bouncemein. WelcomeActivity $ 6.run (WelcomeActivity.java:161) 01-11 12 : 47 : 15.204 (7300)를 System.err/W : android.app.Activity.runOnUiThread (Activity.java:3707)에서 01-11 12 : 47 : 15.204 : W/System.err (7300) : com.apps.clx.bouncemein.WelcomeActivity.loadDataInView (WelcomeActivity.java:156) 01-11 12 : 47 : 15.204 : W/System.err (7300) : com.apps.clx.bouncemein.WelcomeActivity.access $ 1 (WelcomeActivity.java:152) 01-11 12 : 47 : 15.204 : System.err (7300) : com.apps.clx.bouncemein. WelcomeActivity $ 3.onClick (WelcomeActivity.java:84) 01-11 12 : 47 : 15.204 : W/System.err에 (7300)에 android.view.View.performClick (View.java:2408) 01-11 12 : 47 : 15.214 : 승/승 ystem.err (7300) : android.view.View $ PerformClick.run (View.java:8816) 01-11 12 : 47 : 15.214 : W/System.err (7300) : android.os.Handler. handleCallback (Handler.java:587) 01-11 12 : 47 : 15.214 : W/System.err (7300) : android.os.Handler.dispatchMessage (Handler.java:92) 01-11 12:47 : 15.214 : W/System.err (7300) : android.os.Looper.loop (Looper.java:123) 01-11 12 : 47 : 15.214 : W/System.err (7300) : android.app. ActivityThread.main 01-11 12의 (ActivityThread.java:4633) : 47 : 15.214 : W/System.err에 (7300) java.lang.reflect.Method.invokeNative (원시 메소드)에 01-11 12시 47분 : 15.214 : W/System.err (7300) : java.lang.reflect.Method.invoke (Method.java:521) 01-11 12 : 47 : 15.214 : System.err (7300) : at com .android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:858)

도와주세요.

다음 오류가 표시되면 확인하고 알려주세요.

I/System.out(11616): result is:<html> 
    01-11 16:09:42.415: I/System.out(11616):  <head> 
    01-11 16:09:42.415: I/System.out(11616):   <title>Runtime Error</title> 
    01-11 16:09:42.415: I/System.out(11616):   <style> 
    01-11 16:09:42.415: I/System.out(11616):   body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
    01-11 16:09:42.415: I/System.out(11616):   p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} 
    01-11 16:09:42.415: I/System.out(11616):   b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} 
    01-11 16:09:42.415: I/System.out(11616):   H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } 
    01-11 16:09:42.415: I/System.out(11616):   H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } 
    01-11 16:09:42.415: I/System.out(11616):   pre {font-family:"Lucida Console";font-size: .9em} 
    01-11 16:09:42.425: I/System.out(11616):   .marker {font-weight: bold; color: black;text-decoration: none;} 
    01-11 16:09:42.425: I/System.out(11616):   .version {color: gray;} 
    01-11 16:09:42.425: I/System.out(11616):   .error {margin-bottom: 10px;} 
    01-11 16:09:42.425: I/System.out(11616):   .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } 
    01-11 16:09:42.425: I/System.out(11616):   </style> 
    01-11 16:09:42.425: I/System.out(11616):  </head> 
    01-11 16:09:42.425: I/System.out(11616):  <body bgcolor="white"> 
    01-11 16:09:42.425: I/System.out(11616):    <span><H1>Server Error in '/BounceMeInWS' Application.<hr width=100% size=1 color=silver></H1> 
    01-11 16:09:42.425: I/System.out(11616):    <h2> <i>Runtime Error</i> </h2></span> 
    01-11 16:09:42.425: I/System.out(11616):    <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> 
    01-11 16:09:42.425: I/System.out(11616):    <b> Description: </b>An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 
    01-11 16:09:42.425: I/System.out(11616):    <br><br> 
    01-11 16:09:42.425: I/System.out(11616):    <b>Details:</b> To enable the details of this specific error message to be viewable on remote machines, please create a &lt;customErrors&gt; tag within a &quot;web.config&quot; configuration file located in the root directory of the current web application. This &lt;customErrors&gt; tag should then have its &quot;mode&quot; attribute set to &quot;Off&quot;.<br><br> 
    01-11 16:09:42.425: I/System.out(11616):    <table width=100% bgcolor="#ffffcc"> 
    01-11 16:09:42.425: I/System.out(11616):    <tr> 
    01-11 16:09:42.425: I/System.out(11616):     <td> 
    01-11 16:09:42.425: I/System.out(11616):      <code><pre> 
    01-11 16:09:42.425: I/System.out(11616): &lt;!-- Web.Config Configuration File --&gt; 
    01-11 16:09:42.425: I/System.out(11616): &lt;configuration&gt; 
    01-11 16:09:42.425: I/System.out(11616):  &lt;system.web&gt; 
    01-11 16:09:42.425: I/System.out(11616):   &lt;customErrors mode=&quot;Off&quot;/&gt; 
    01-11 16:09:42.425: I/System.out(11616):  &lt;/system.web&gt; 
    01-11 16:09:42.425: I/System.out(11616): &lt;/configuration&gt;</pre></code> 
    01-11 16:09:42.425: I/System.out(11616):     </td> 
    01-11 16:09:42.425: I/System.out(11616):    </tr> 
    01-11 16:09:42.425: I/System.out(11616):    </table> 
    01-11 16:09:42.425: I/System.out(11616):    <br> 
    01-11 16:09:42.425: I/System.out(11616):    <b>Notes:</b> The current error page you are seeing can be replaced by a custom error page by modifying the &quot;defaultRedirect&quot; attribute of the application&#39;s &lt;customErrors&gt; configuration tag to point to a custom error page URL.<br><br> 
    01-11 16:09:42.425: I/System.out(11616):    <table width=100% bgcolor="#ffffcc"> 
    01-11 16:09:42.425: I/System.out(11616):    <tr> 
    01-11 16:09:42.425: I/System.out(11616):     <td> 
    01-11 16:09:42.425: I/System.out(11616):      <code><pre> 
    01-11 16:09:42.425: I/System.out(11616): &lt;!-- Web.Config Configuration File --&gt; 
    01-11 16:09:42.425: I/System.out(11616): &lt;configuration&gt; 
    01-11 16:09:42.425: I/System.out(11616):  &lt;system.web&gt; 
    01-11 16:09:42.425: I/System.out(11616):   &lt;customErrors mode=&quot;RemoteOnly&quot; defaultRedirect=&quot;mycustompage.htm&quot;/&gt; 
    01-11 16:09:42.425: I/System.out(11616):  &lt;/system.web&gt; 
    01-11 16:09:42.425: I/System.out(11616): &lt;/configuration&gt;</pre></code> 
    01-11 16:09:42.425: I/System.out(11616):     </td> 
    01-11 16:09:42.425: I/System.out(11616):    </tr> 
    01-11 16:09:42.425: I/System.out(11616):    </table> 
    01-11 16:09:42.425: I/System.out(11616):    <br> 
    01-11 16:09:42.425: I/System.out(11616):  </body> 
    01-11 16:09:42.425: I/System.out(11616): </html> 
    01-11 16:09:42.445: I/System.out(11616): inside dialoge box 
+0

'responseEntity' ('EntityUtils.toString (HttpEntity) '사용)의 내용을 출력하고 질문에 첨부 할 수 있습니까? – Jens

+0

responseEntity의 내용을 추가했습니다. – user1142637

+0

글쎄, 문제는 안드로이드 코드에 없습니다 - 귀하의 웹 서비스가 충돌합니다. 서버 로그를 확인하는 것이 좋습니다. – Jens

답변

0

오류는 XML에 문제가 있음을 나타냅니다.

먼저 네트워크에서 올바른 답장을 받았는지 확인해야합니다. HTTP 응답 status code 봐 :

if(response.getStatusLine().getStatusCode() == 200){ 
    // it's ok, proceed with parsing 
} else { 
    // som error: retry, notify user, etc.. 
} 

내 생각 엔 당신이 localhost (= 127.0.0.1)에 액세스하려고하는 것입니다. 대신 10.0.2.2을 사용하십시오.

업데이트 : 잘못된 주소 또는 포트가 잘못된 응답 코드가 아닌 예외를 생성합니다. XML에 몇 가지 문제가 있어야합니다. 어쩌면 인코딩 문제일까요? 여기에 문제가되는 XML을 게시 할 수 있습니까?

+0

예를 들어 응답이없는 호스트 (예 : localhost) 또는 잘못된 포트에 연결하면 HTTP 상태 코드가 아닌 예외가 발생합니다. – Jens

+0

사실, 답변을 수정합니다 –

0

가 잘 형성되지 않음 (유효하지 않은 토큰) 일반적으로 잘못된 응답 XML로 결과는 방법에 따라 응답의 XML 문자열을 확인하십시오

HttpEntity responseEntity = response.getEntity();
String responseString = EntityUtils.convertStreamtoString (responseEntity);

이 문자열에 특수 문자 (예 : '&')가 있는지 확인하십시오. 있다면,이 문자들을 대체하십시오.

+0

덕분에, 장치에서 웹 서비스의 데이터를 가져 오는 동안 서버 오류가 발생하지만 에뮬레이터에서 데이터를 성공적으로 가져올 수 있습니다. – user1142637

+0

괜찮 으면, 장치 측에서 연결을 허용하지 않는 서버 측 응용 프로그램의 특정 설정이 필요한지 또는 장치를 통해 webservice에 액세스 할 때 서버에 대한 일부 특수 매개 변수를 전송해야하는지 확인해야합니다. 당신은 에뮬레이터에서 프록시 뒤에 네트워크에 액세스 할 수 있습니다/프록시 반대 장치없이. – jeet

관련 문제