JAX-WS RIまたはAxis2ベースのいずれかを使用したシンプルで実用的なサンプルMTOMサンプルコード(サービス+クライアント)を探しています。
私はその単語をグーグルで検索して、単に機能しないスニペットとコードを見つけました!
要求しているWebサービスクライアントにPDF添付ファイルを送信したい。
少し早めに質問したようです:) MTOMを使用したサンプルjax-wsコードを次に示します..私は自分で管理します..
axis2 + mtom でもいくつかの問題があることを聞いて読んだ.. ドキュメントも axis2 では本当に悪い。また、パフォーマンスに疑問があります(ただし、XMLBeans では ADB についてはわかりません)...
package webservice;
import java.io.File;
import javax.activation.DataHandler;
import org.jvnet.staxex.StreamingDataHandler;
/**
*
* @author Raghavendra_Samant
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try { // Call Web Service Operation
com.xxx.labelgeneration.LabelGeneratorService service = new com.xxx.labelgeneration.LabelGeneratorService();
com.xxx.labelgeneration.LabelGenerator port = service.getLabelGeneratorPort();
// TODO initialize WS operation arguments here
java.lang.String name = "dynamic.pdf";
// TODO process result here
byte[] result = port.getFile(name);
System.out.println("Result = "+result.length);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
}
}
サーバ側
package com.xxx.LabelGeneration;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.soap.MTOM;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
/**
*
* @author Raghavendra_Samant
*/
@WebService()
@MTOM
public class LabelGenerator {
/**
* Web service operation
*/
@WebMethod(operationName = "getFile")
public DataHandler getFile(@WebParam(name = "name") String fileName) {
//TODO write your implementation code here:
return new DataHandler(new FileDataSource(fileName));
}
}