当前位置: 首页 > news >正文

做视频直播的网站有哪些/我对网络营销的理解

做视频直播的网站有哪些,我对网络营销的理解,网站设计算什么费用,怎么做返利网站吗老规矩废话不多说,直接入主题注:wcf 使用rest风格,传递json数据,图片是经过base64编码,android 使用common-codec-1.5.jar 进行base64编码服务器端wcf接口:namespace Test{// 注意: 如果更改此处的接口名称…

老规矩废话不多说,直接入主题

注:wcf 使用rest风格,传递json数据,图片是经过base64编码,android 使用common-codec-1.5.jar 进行base64编码

服务器端

wcf接口:

namespace Test

{

// 注意: 如果更改此处的接口名称 "IService1",也必须更新 Web.config 中对 "IService1" 的引用。

[ServiceContract]

public interface IService1

{

// 任务: 在此处添加服务操作

[OperationContract]

[WebInvoke(Method = "POST", UriTemplate = "update_pictrue",BodyStyle=WebMessageBodyStyle.WrappedRequest,RequestFormat=WebMessageFormat.Json,ResponseFormat=WebMessageFormat.Json)]

string update_pictrue(string name, string content, string type);

[OperationContract]

[WebInvoke(Method = "POST", UriTemplate = "down_pictrue", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]

string down_pictrue(string name);

}

}

接口实现:

namespace Test

{

// 注意: 如果更改此处的类名“Service1”,也必须更新 Web.config 和关联的 .svc 文件中对“Service1”的引用。

public class Service1 : IService1

{

#region IService1 成员

public string update_pictrue(string name,string content, string type)

{

// throw new NotImplementedException();

if (type != ".jpg" && type != ".gif")

{

return "格式不正确";

}

else

{

string imgFilePath = @"F:\Wcf_teach\pictrue_update_down\Test\update_pictrue\" + name;

if (!File.Exists(imgFilePath))

{

try

{

byte[] ms_content = Convert.FromBase64String(content);

FileStream fs = File.Open(imgFilePath, FileMode.OpenOrCreate);

fs.Write(ms_content, 0, ms_content.Length);

fs.Close();

return "上传成功";

}

catch (Exception ex)

{

return "出现异常";

}

}

else

{

return "上传失败";

}

}

}

public string down_pictrue(string name)

{

// throw new NotImplementedException();

string imgFilePath = @"F:\Wcf_teach\pictrue_update_down\Test\update_pictrue\" + name;

if (File.Exists(imgFilePath))

{

System.IO.FileStream fs = new System.IO.FileStream(imgFilePath, System.IO.FileMode.Open);

int i = (int)fs.Length;

byte[] content = new byte[i];

fs.Read(content, 0, i);

string result = Convert.ToBase64String(content);

fs.Close();

return result;

}

else

{

throw new Exception("没有该文件出现异常");

}

}

#endregion

}

}

客户端

public class pictrue_update_down extends Activity {

private Button update_btn;

private Button down_btn;

private ImageView img_img;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

findAll();

bind();

}

public void findAll() {

update_btn = (Button) this.findViewById(R.id.update_btn);

down_btn = (Button) this.findViewById(R.id.down_btn);

img_img = (ImageView) this.findViewById(R.id.img_img);

}

public void bind() {

update_btn.setOnClickListener(mylistener);

down_btn.setOnClickListener(mylistener);

}

private View.OnClickListener mylistener = new OnClickListener() {

public void onClick(View v) {

// TODO Auto-generated method stub

switch (v.getId()) {

case R.id.update_btn:

Thread th1 = new Thread(new mythread());

th1.start();

break;

case R.id.down_btn:

Thread th2 = new Thread(new mythread_down());

th2.start();

break;

default:

break;

}

}

};

Handler hd = new Handler() {

@Override

public void handleMessage(Message msg) {

// TODO Auto-generated method stub

// super.handleMessage(msg);

if (msg.what == 123) {

String jason = msg.obj.toString();

String filepath = Environment.getExternalStorageDirectory()

+ File.separator + jason;

Bitmap bitmap1 = BitmapFactory.decodeFile(filepath);

img_img.setImageBitmap(bitmap1);

}

}

};

class mythread_down implements Runnable {

public void run() {

// TODO Auto-generated method stub

HttpClient hc = new DefaultHttpClient();

HttpPost hp = new HttpPost(

"http://192.168.1.229/Test/service1.svc/down_pictrue");

HttpResponse hr = null;

JSONObject jo1 = new JSONObject();

try {

jo1.put("name", "999.jpg");

StringEntity se = new StringEntity(jo1.toString(), HTTP.UTF_8);

se.setContentType("application/json");

hp.setEntity(se);

hr = hc.execute(hp);

} catch (JSONException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (UnsupportedEncodingException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (ClientProtocolException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

String strResp = null;

if (hr.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) {

try {

strResp = EntityUtils.toString(hr.getEntity());

File f = new File("//sdcard//999.jpg");

if (!f.exists()) {

f.createNewFile();

FileOutputStream fos=new FileOutputStream(f);

byte[] content= Base64.decodeBase64(strResp.getBytes());

fos.write(content);

fos.flush();

Message msg=hd.obtainMessage(123);

msg.obj="//sdcard//999.jpg";

hd.sendMessage(msg);

}

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}else {

Toast.makeText(pictrue_update_down.this, "下载失败",

Toast.LENGTH_LONG).show();

}

}

}

class mythread implements Runnable {

public void run() {

// TODO Auto-generated method stub

HttpClient hc = new DefaultHttpClient();

HttpPost hp = new HttpPost(

"http://192.168.1.229/Test/service1.svc/update_pictrue");

HttpResponse hr;

String path = "//sdcard//999.jpg";

File f = new File(path);

if (f.exists()) {

// System.out.println("successful");

try {

int ig = (int) f.length();

byte[] content = new byte[ig];

FileInputStream fis;

fis = new FileInputStream(f);

fis.read(content, 0, ig);

String jason = new String(Base64.encodeBase64(content));

JSONObject jo1 = new JSONObject();

jo1.put("name", "999.jpg");

jo1.put("content", jason);

jo1.put("type", ".jpg");

StringEntity se = new StringEntity(jo1.toString(),

HTTP.UTF_8);

se.setContentType("application/json");

hp.setEntity(se);

hr = hc.execute(hp);

String strResp = null;

if (hr.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) {

strResp = EntityUtils.toString(hr.getEntity());

} else {

strResp = "$no_found_date$";

}

Toast.makeText(pictrue_update_down.this, strResp,

Toast.LENGTH_LONG).show();

} catch (UnsupportedEncodingException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (ClientProtocolException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (JSONException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} finally {

hp.abort();

}

}

}

}

}

http://www.jmfq.cn/news/4836817.html

相关文章:

  • 四川省人民政府官方网站/百度秒收录技术最新
  • 民治做网站/百度下载安装官方下载
  • 台湾wordpress/seo门户 site
  • 网站建设中是什么意思/爱站网长尾关键词挖掘工具下载
  • 网站制作建设公司/app地推接单平台有哪些
  • 那些网站主做玄幻小说/今天最新新闻
  • 企业网络推广做网站推广公司/搜索引擎推广的常见形式有
  • 网站开发详细报价单/百度竞价推广思路
  • 做装饰网站公司/seo网络推广案例
  • 做微网站用什么框架/制作网站需要什么技术
  • 德州网站建设公司/百度推广登录手机版
  • 做微信网站/广告营销推广
  • 广告公司可以做网站吗/网络营销的特点不包括
  • 推广网站企业/百度关键词优化系统
  • 做盗版音乐网站/seo排名的方法
  • java php 网站建设/关键词推广优化排名如何
  • 怎么做律所的官方网站/国内比百度好的搜索引擎
  • 做网站前的准备什么软件/外贸网站推广平台有哪些
  • vi设计 站酷/西安网站搭建
  • 时时彩网站建设/湖南优化推广
  • 网站 免费空间/免费推广网站2023
  • 重庆网站优化建设/seo推广优化平台
  • 微信商城网站怎么做的/seo咨询茂名
  • 博客自定义网站/百度快速查询
  • 网站后台不显示/谷歌搜索优化seo
  • 网站公安备案号是否反映备案时间/外贸推广是做什么的
  • 公众平台如何做网站/深圳网络推广最新招聘
  • 素材网站的图可以做海报吗/seo外包公司排名
  • wordpress js css/seo交互论坛
  • 520高清网站三级黄色软件男女做/优化设计六年级下册语文答案