0

使用 Grails 和 CXF,我发布了一个看起来像这样的小型 Web 服务

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)我会发布TestServiceEndpoint

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

一切都完成了。

现在我使用 Grails 进行发布,我不知道如何获得Endpoint. 有谁知道如何做到这一点?

4

1 回答 1

2

让我们假设服务接口看起来像这样

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

端点的属性可以在cxf-servlet.xml中指定。使用名为 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>
于 2010-08-02T08:35:31.473 回答