Here is my code to fetch an image from a server location into a web service folder "web content"
.
// 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;
}
}
But i am getting an exception:
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>
What could be the cause of the error?