开发者

How do I enable MTOM on the server side for a Web Service published using Grails with CXF?

开发者 https://www.devze.com 2023-01-09 07:59 出处:网络
Using Grails and CXF, I have published a small web service that looks like this class TestService { static expose=[\'cxf\']

Using Grails and CXF, I have published a small web service that looks like this

class TestService {

    static expose=['cxf']

    int pushData(int id, DataHandler data) {

        //receives data for a specific ID,
        return 1
    }
}

The thing is that I now would like to enable MTOM for the transfer of the DataHandler-data. Normally with Groovy and CXF (or JAX-WS) I'd publish TestService as an Endpoint

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

And all's done.

开发者_开发问答

Now that I use Grails to do my publishing I can't figure out how to get the Endpoint. Does anyone know how this could be accomplished?


Let's assume that the service interface looks like this

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

The attributes of the endpoint can be specified in the cxf-servlet.xml . With an implementing service called ServiceImpl, you need to add the following specifications

  <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>
0

精彩评论

暂无评论...
验证码 换一张
取 消