代码之家  ›  专栏  ›  技术社区  ›  Lars Andren

如何在服务器端为使用Grails和CXF发布的Web服务启用MTOM?

  •  0
  • Lars Andren  · 技术社区  · 14 年前

    class TestService {
    
        static expose=['cxf']
    
        int pushData(int id, DataHandler data) {
    
            //receives data for a specific ID,
            return 1
        }
    }
    

    问题是我现在想启用MTOM来传输DataHandler数据。通常使用Groovy和CXF(或JAX-WS)我会发布 TestService 作为一个 Endpoint

    Endpoint ep = Endpoint.publish("http://localhost:9000/test", new TestService())
    SOAPBinding binding = (SOAPBinding)ep.getBinding();
    binding.setMTOMEnabled(true);
    

    一切都结束了。

    现在我使用Grails进行发布,我不知道如何获得 . 有人知道这是怎么做到的吗?

    1 回复  |  直到 14 年前
        1
  •  2
  •   Lars Andren    14 年前

    @MTOM
    @WebService(targetNamespace="http://soap.services.website.com/", 
            endpointInterface="com.armorize.web.services.ServiceInterface")
    public interface ServiceInterface
    
      int uploadData(@XmlMimeType("application/octet-stream") DataHandler code) ;
    

    端点的属性可以在 . 对于名为ServiceImpl的实现服务,您需要添加以下规范

      <jaxws:endpoint id="endpointID"
            implementor="com.website.web.services.ServiceImpl" address="/test">
    
            <jaxws:properties>
                <entry key="mtom-enabled" value="true" />
                <entry key="mtom-threshold" value="0" />
            </jaxws:properties>