2009-07-11 6 views
3

JAX-WS RI 또는 ​​Axis2 기반의 간단한 샘플 MTOM 샘플 코드 (서비스 + 클라이언트)를 찾고 있습니다.JAX-WS MTOM 샘플 코드

나는 단순히 작동하지 않는 스 니펫과 코드를 찾기 위해 단어를 봤다.

요청한 웹 서비스 클라이언트에 PDF 첨부 파일을 보내려고합니다. 내가 조금 일찍 질문 : 여기 MTOM과 샘플 JAX-WS 코드는 ... 내가 내 자신에 관리 CUD ..

허드 물어 읽어처럼

답변

0

보인다 심지어이 축 2 + MTOM과 몇 가지 문제가 있습니다. 문서화도 axis2에서 정말 나쁩니다. 는 또한 성능 (XML 빈스의 ADB와 확실하지 않지만) 의문이다 ... 참조 : http://weblogs.java.net/blog/kohsuke/archive/2007/02/jaxws_ri_21_ben.html

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)); 

    } 
}