0
다음은 서버 위치에서 웹 서비스 폴더 "web content"
으로 이미지를 가져 오는 코드입니다.서버에서 이미지 가져 오기
SOAP Response Envelope
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.net.ConnectException: Connection timed out: connect</faultstring>
- <detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">01HW040207</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
은 무엇 오류의 원인이 될 수 :
// imports removed
public class WebService {
public int writeToFileImage(int a) throws IOException{
File file =new File("sdcard/myImage.jpg");
file.createNewFile();
URL u = new URL("http://172.29.26.40:8080/ExampleService/demo.jpg");
URLConnection uc = u.openConnection();
uc.connect();
InputStream in = uc.getInputStream();
FileOutputStream out;
out = new FileOutputStream(file);
final int BUF_SIZE = 1 << 8;
byte[] buffer = new byte[BUF_SIZE];
int bytesRead = -1;
while((bytesRead = in.read(buffer)) > -1) {
out.write(buffer, 0, bytesRead);
}
in.close();
out.close();
return a;
}
}
하지만 난 예외는 무엇입니까?
당신이 당신의 웹 브라우저에서이 URL에 액세스하려고 있나요? 어쩌면 자원이 단순히 사용 가능하지 않을 수 있습니까? 여기에서 연락 할 수 없기 때문에 ... – Sephy
뭘하고 싶은지에 대한 설명이 분명하길 바랍니다. 코드에서 서버의 이미지를 장치 sdcard로 가져 오는 것처럼 보입니다. 일반적으로 포트 8080은 공개하지 않습니다. 그러나 에뮬레이터에서 액세스 할 수 있는지 확인하십시오. SOAP, WebService라는 용어는 장치에 이미지를 다운로드하는 간단한 작업과 관련이 없어야합니다. – dipu