使用CXFNonSpringServlet发布的webservice服务接收参数老是为null
解决方法:
import javax.servlet.ServletConfig;
import javax.xml.ws.Endpoint;
import org.apache.cxf.BusFactory;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
import com.test.WebServiceServer;
public class WebServiceServlet extends CXFNonSpringServlet {
private static final long serialVersionUID = 1L;
@Override
protected void loadBus(ServletConfig sc) {
//以下方式发布webservice服务不行,接收参数为
/*super.loadBus(sc);
Bus b=getBus();
BusFactory.setDefaultBus(b);
WebServiceServer hi=new WebServiceServer();//实现类
ServerFactoryBean sfb=new ServerFactoryBean(); //server工厂
sfb.setServiceClass(WebServiceServerI.class);// 接口类
sfb.setAddress("/shortMessage"); //服务请求路径
sfb.setServiceBean(hi);
sfb.create();*/
//以下方式可以解决参数为空的问题
super.loadBus(sc);
WebServiceServer hi=new WebServiceServer();
BusFactory.setDefaultBus(getBus());
Endpoint.publish("/shortMessage", hi);
}
}