webservice例子 来个没事干的大神 帮我

webservice例子 实 现文件上传 图片压缩!有大红包 求帮忙!加qq865091142

和普通的处理方式没区别,就是看图片你要怎么处理,轻量级的转base64那还是数据流,如果大量的上传。可以用hession或者ftp

直接传图片地址,就可以上传

public void uploadFile(String imageFilePath) {
String actionUrl = "http://1s49179.51mypc.cn/test1/servlet/Videoservlet";
try {
URL url = new URL(actionUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();

        con.setDoInput(true);
        con.setDoOutput(true);
        con.setUseCaches(false);

        con.setRequestMethod("POST");

        DataOutputStream ds = new DataOutputStream(con.getOutputStream());
        File file = new File(imageFilePath);

        FileInputStream fStream = new FileInputStream(file);
        int bufferSize = 1024;
        byte[] buffer = new byte[bufferSize];

        int length = -1;

        while ((length = fStream.read(buffer)) != -1) {

            ds.write(buffer, 0, length);
        }

        fStream.close();
        ds.flush();

        InputStream is = con.getInputStream();
        int ch;
        StringBuffer b = new StringBuffer();
        while ((ch = is.read()) != -1) {
            b.append((char) ch);
        }

        ds.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

通过动态代理调用接口
需要用到apache cxf
public class DynamicClient {
public static void main(String[] args) {
DynamicClientFactory factory = DynamicClientFactory.newInstance();
Client client = factory.createClient("http://localhost:8088/ws/soap/sendHis?wsdl");
try {
Object[] results = client.invoke("sendMedInfo", "参数l");
System.out.println(results[0]);
} catch (Exception e) {
e.printStackTrace();
}
}
}、

java 调用webservice比较简单的方式----webservice传输一般都是纯字符串-注意那个参数-那个参数-建议你做成json或者xml,如果涉及图片,先把图片转成base64。