Web 服务实现 - 从客户端接收文件 [英] Web Service Implementation - Receive a file from the client

查看:38
本文介绍了Web 服务实现 - 从客户端接收文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用 Java 实现一个 Web 服务,以从我的客户端应用程序接收一个文件,该文件在 .Net 中实现.但是,我无法实现 Java Web 服务.我尝试了很多来获得任何示例程序.但是,我没看懂.

I am trying to implement a web service in Java to receive a file from my client application which is implemented in .Net. But, I am unable to implement the Java web service. I tried a lot to get any example program. But, I didn't get it.

我的主要目标是:

  1. 我将使用我的 .Net 客户端软件浏览和发送文件
  2. 我的 Java 网络服务将能够接收该文件
  3. 收到该文件后,我将使用该文件进行一些处理并生成一个新文件.
  4. 现在,我必须再次将该新文件返回给我的 .Net 客户端

简单地说,

输入:我的网络方法必须接收一个文件输出:我的网络方法应该返回一个文件

Input: My web method will have to receive a file Output: My web method should return a file

以下是我的本地环境详细信息:

Below are my local environment details:

Apache Tomcat 7、Axis 2、Eclipse、JRE 6

Apache Tomcat 7, Axis 2, Eclipse, JRE 6

谁能帮助我如何在我的 Java Web 服务中编写该 Web 方法?

Can anybody help me how to write that web method in my Java web service?

推荐答案

您可以将文件作为包含在 XML 文档中的 base64 编码数据或作为包含在 XML 文档 (MTOM) 之外的附件发送/接收.

You can send/receive files as base64 encoded data contained within the XML document or as attachments contained outside the XML document (MTOM).

在 wsdl 第一种方法中,您需要使用架构类型base64Binary".

In wsdl first approach you need to use schema type "base64Binary".

在代码优先的方法中,您可以编写:

In code first approach you can write:

public DataHandler yourMethod(DataHandler input)
or
public byte[] yourMethod(byte[] input)

链接:

这篇关于Web 服务实现 - 从客户端接收文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆