以下是我将代码从服务器位置提取到网络服务文件夹"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;
}
}
但我得到一个例外:
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>
可能是错误的原因是什么?
答案 0 :(得分:0)