服务端声明
@WebService(serviceName = "CreateKnwlFileService")
public class CreateKnwlFile {
/* 接口声明 */
@WebMethod(operationName = "createKnwlFile")
public @WebResult(name="result")String createKnwlFile2(@WebParam(name="fileContent")String fileContent,
@WebParam(name = "fileName") String fileName) {
try {
//测试:将收到的文件内容转换写入临时文件查看
byte[] bytes = Base64.decode(fileContent);
String path = "C:\\Users\\test\\Desktop\\206\\";
FileOutputStream out = new FileOutputStream(path+fileName);
out.write(bytes);
out.flush();
out.close();
//将收到的文件内容重新转换为输入流
// byte[] bytes = Base64.decode(fileContent);
// new ByteArrayInputStream(bytes);
} catch (Exception e) {
e.printStackTrace();
}
}
}
使用soupui发布后如图:
PostMethod 测试
import jpack.util.Base64;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import java.io.*;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**
* SOAP客户端工具类
* @author Administrator
*
*/
public class CallKms