简体   繁体   中英

Using @WebParam(header = true) in CXF web service

I'm trying to write a web service that has only one massage param and the rest are header params. My web service looks like this:

    @BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
    @MTOM
    @WebService(targetNamespace = WS_NAMESPACE + "/FileSvc")
    @Service
    public interface FileSvc
    {
        void uploadFile(@WebParam(name = "dataHandler") @XmlMimeType("application/octet-stream")DataHandler dataHandler,
                    @WebParam(header = true, name = "fileName") String fileName,
                    @WebParam(header = true, name = "fileSize") long fileSize);
    } 

The services factory is defined like this:

    <bean id="fileSvcProxyFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
            <property name="serviceClass" value="com....FileSvc"/>
            <property name="address" value="http://.../FileSvc"/>
            <property name="bus" ref="client_bus"/>
            <property name="dataBinding" ref="globalJAXBDataBinding" />
    </bean> 

When I try testing this service -from a java client I get this error when I try loading the service:

Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Message part {http://.../FileSvc}fileName of Message {http://.../FileSvc}uploadFile cannot be processed. This can be caused by the use of JAX-WS-specific types without the JAX-WS service factory bean.

Can anyone explain to me how this webParam works?

Thanks,

Try removing the globalJAXBDataBinding thing and seeing if that helps. Alternatively, add @RequestWrapper and @ResponseWrapper annotations to the interface methods to point at appropriate wrapper types. Not 100% sure that will work, but worth a shot.

If it still doesn't work, a small full testcase would be appreciated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM