2011-10-14 3 views
1

저는 애플리케이션이있어서 XML을 파서 링해야합니다. Java Project에서이 작업을 수행하면 작동합니다. 그러나 Android 프로젝트에서이 작업을 수행하려고하면 URL을 연결할 수 없으며 XPath를 사용하고 있습니다. 코드 :안드로이드 - XPath로 웹 서비스 처리하기

개인 정적 최종 문자열 STRING_XML = "http : // localhost : 50645/WebServiceClientes.asmx/ListaReservas";

는 .... AndroidManifest.xml에서

// prepare a URL to the geocoder 
URL url = new URL(STRING_XML); 

// prepare an HTTP connection to the geocoder 
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 

Document geocoderResultDocument = null; 
try { 
    // open the connection and get results as InputSource. 
    conn.connect(); 
    InputSource geocoderResultInputSource = new InputSource(conn.getInputStream()); 

    // read result and parse into XML Document 
    geocoderResultDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(geocoderResultInputSource); 
} finally { 
    conn.disconnect(); //The debug stops here, so, Disconnect!!! 
} 
+0

무엇이 오류입니까? 매니페스트에 대한 사용 권한으로 인터넷이 가능합니까? 전화, 에뮬레이터 또는 실제 전화로 무엇을 사용하고 있습니까? – JPM

답변

0

uses-permission 더 추가 : INTERNET

또한, finally 확실히마다 호출된다.

0

로컬 호스트 WebService를 사용하고 있었고 액세스하려면 포트 8080을 사용해야합니다.

관련 문제