专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > J2ME

手机图片上传到服务器解决方案

发布时间:2010-06-05 12:30:14 文章来源:www.iduyao.cn 采编人员:星星草
手机图片上传到服务器
怎样将手机拍摄到的图片,通过.Net的webservice上传到服务器

我建了个Webservice,方法为upImage(byte[]   image)
手机端,通过http连接调用,通过DataOutputStream   向服务器
写数据,提示错误 "未实现实例 "。就是不能上传,为什么啊?

请教,高人的实现。。。最好给贴个代码端,详细设置

谢过。。。先

------解决方案--------------------
"未实现实例 ",某个对象没有实例化
------解决方案--------------------
提问太空 -.- 莫非要人帮你实现
------解决方案--------------------
这段代码是J2me API文档自带的代码段 ,因为你的代码没有贴出来 所以只能用API自带文档的标准范例来类比了.


void postViaHttpConnection(String url) throws IOException {
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;
int rc;

try {
c = (HttpConnection)Connector.open(url);

// Set the request method and headers
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty( "If-Modified-Since ",
"29 Oct 1999 19:43:31 GMT ");
c.setRequestProperty( "User-Agent ",
"Profile/MIDP-2.0 Configuration/CLDC-1.0 ");
c.setRequestProperty( "Content-Language ", "en-US ");

// Getting the output stream may flush the headers
os = c.openOutputStream();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~我觉得你的代码问题应该对应的出现在这个地方,你的DataOutputStream对象,应该是通过对 HttpConnection对象(API文档当中是c,你的就看你自己怎么 命名咯 )通过openOutputStream()这个方法来得到的.你可能是自己实例化的,那样是不行的 .或者你用ddebug看看 代码执行到哪一行,采出现的问题,实在不行每隔一行一个输出语句,我一开始都这么用的 ^_^.
os.write( "LIST games\n ".getBytes());
os.flush(); // Optional, getResponseCode will flush

// Getting the response code will open the connection,
// send the request, and read the HTTP response headers.
// The headers are stored until requested.
rc = c.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException( "HTTP response code: " + rc);
}

is = c.openInputStream();

// Get the ContentType
String type = c.getType();
processType(type);

// Get the length and process the data
int len = (int)c.getLength();
if (len > 0) {
int actual = 0;
int bytesread = 0 ;
byte[] data = new byte[len];
while ((bytesread != len) && (actual != -1)) {
actual = is.read(data, bytesread, len - bytesread);
bytesread += actual;
}
process(data);
} else {
int ch;
while ((ch = is.read()) != -1) {
process((byte)ch);
}
}
} catch (ClassCastException e) {
throw new IllegalArgumentException( "Not an HTTP URL ");
} finally {
if (is != null)
is.close();
if (os != null)
os.close();
if (c != null)
c.close();
}
}
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: