wowowebservice 2016-11-28 13:19 采纳率: 50%
浏览 1583

java 调用 .net 发布 webservice 传递 byte[]

public static void MakeThumbnail(byte[] ImageCount, String thumbnailPath, int width, int height, String mode, String rename, String format) throws Exception {

    URL wsUrl = new URL(URL);

    HttpURLConnection conn = (HttpURLConnection) wsUrl.openConnection();
    conn.setDoInput(true);
    conn.setDoOutput(true);
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
    OutputStream os = conn.getOutputStream();

    // 请求体
    String soap = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
            + "<soap:Body>"
            + "<MakeThumbnail xmlns=\"http://www.520shq.com/\">"
            + "<ImageCount>"
            + ImageCount
            + "</ImageCount>"
            + "<thumbnailPath>"
            + thumbnailPath
            + "</thumbnailPath>"
            + "<width>"
            + width
            + "</width>"
            + "<height>"
            + height
            + "</height>"
            + "<mode>"
            + mode
            + "</mode>"
            + "<rename>"
            + rename
            + "</rename>"
            + "<format>"
            + format
            + "</format>"
            + "</MakeThumbnail>"
            + "</soap:Body></soap:Envelope>";

    os.write(soap.getBytes());
    InputStream is = conn.getInputStream();

    byte[] b = new byte[1024];
    int len = 0;
    String xml = "";
    while ((len = is.read(b)) != -1) {
        xml += new String(b, 0, len, "UTF-8");
    }

    is.close();
    os.close();
    conn.disconnect();

    我只要传递byte[] 就会报400 求大神帮帮忙!
  • 写回答

1条回答 默认 最新

  • threenewbee 2016-11-28 16:51
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog