###前提・実現したいこと
javaでwebサービスを作成しています。
クライアント側は作成済で、あとはサーバー側を作成するのみなのですが、
ネット上の情報が少なくどのように実装していいのかわかりません。
下記に書いたように、見よう見真似でコードを書いてみましたが、上手くいきませんでした。
どなたか、詳しい作成方法が掲載されているサイトや本、実際のコードなど何でもいいですので、お知恵を貸してください。
<やりたいこと>
・SOAP通信
・SwAかMTOMで添付ファイルを受信
・受信した添付ファイルをサーバーに保存
<環境>
axis2、eclipseを使用しています。
###試したこと
以下のようなwebサービスを作成し、試してみましたが、いずれもDataHandler valueがnullになってしまいます。
【1】
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.activation.DataHandler;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;
import javax.xml.ws.BindingType;
import org.apache.commons.io.IOUtils;
@WebService(targetNamespace = "http://WebScanPrint/ExampleNamespace/StrageService", serviceName = "CtrlService")//)
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL, parameterStyle = ParameterStyle.BARE)
@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
public class Ctrl {
public void sendBinary( String FolderName, String DocumentName, DataHandler value) { FileOutputStream fos = null; try { fos = new FileOutputStream(new File("/tmp/" + DocumentName + ".pdf")); value.writeTo(fos); } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { IOUtils.closeQuietly(fos); } } }
}
【2】
import java.io.File;
import java.io.FileOutputStream;
import javax.activation.DataHandler;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
@WebService(targetNamespace = "http://WebScanPrint/ExampleNamespace/StrageService", serviceName = "CtrlMTOMService",portName = "CtrlMTOMPort")//)
@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
public class CtrlMTOM {
public void sendBinary(String FolderName, String DocumentName, DataHandler value) { try { FileOutputStream fileOutputStream = new FileOutputStream( new File("/tmp/mtom_result.pdf")); value.writeTo(fileOutputStream); fileOutputStream.close(); } catch (Exception e) { e.printStackTrace(); } }
}
あなたの回答
tips
プレビュー