Search code examples
javaweb-servicesmethodsparametersbare

Websercice that has SOAPBinding.ParameterStyle.BARE requires all method (include non WEBMETHOD) has only one parameter as input


i am using cxf 2.x to develop a webservice. Here is my web service class

@WebService(name = "XXXWS", targetNamespace = "http://www.XXX.com/XXXWS", portName = "XXXWSPort", serviceName = "XXXWSService")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public class XXXWS {

    @WebMethod(operationName = "XXXMethod", action = "http://www.XXX.com/XXXWS/XXXX")
    public XXXResponse XXXMethod(
            @WebParam(name = "XXXRequest") XXXRequest xxxRequest) {
        // implement code here

        return response;
    }

  private  static String getServiceURL(Environment env, String actionCode){ //<-- RED CROSS here

        //implement code here
        return url;     
    }
}

In eclipse there is a RED CROSS at the method getServiceURL (this is just a regular method, not a WEBMETHOD). It says

 Multiple markers at this line
        - Document Literal Bare operations must have unique XML elements for the input and output messages across all operations on the 
         Web Service : '{http://www.XXX.com/XXXWS}getServiceURL'
        - Document literal bare methods may have only one non-header IN parameter

So if i just use only ONE parameter as input for the method getServiceURL OR i use SOAPBinding.ParameterStyle.WRAPPED then the RED CROSS will disapear. But i need to have 2 parameters here.

My question is: if i need to use 2 parameters here and still use SOAPBinding.ParameterStyle.BARE, how can i remove the RED CROSS. I think there is a way to configure Eclipse to remove this kind of error


Solution

  • I figured it out: You must create an interface SEI for that webservice, then an implement class of that SEI. the method that has multiple parameters will be private method that stay only in the implement class. Everything will be fine. No more red cross.