尝试编写webservice的服务端时遇到报错:
Exception in thread “main” java.lang.IllegalArgumentException: An operation with name [{http://service.demo.example.com/}count] already exists in this service 完整报错如下:
Exception in thread "main" java.lang.IllegalArgumentException: An operation with name [{http://service.demo.example.com/}count] already exists in this service
at org.apache.cxf.service.model.InterfaceInfo.addOperation(InterfaceInfo.java:78)
at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.createOperation(ReflectionServiceFactoryBean.java:1008)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.createOperation(JaxWsServiceFactoryBean.java:633)
at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.createInterface(ReflectionServiceFactoryBean.java:1000)
at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:461)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:695)
at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:530)
at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
at com.example.demo.controller.WebService.main(WebService.java:22)
检查半天后发现似乎是mybatisplus与webservice起冲突了
报错代码:
package com.example.demo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.domain.UserDO;
import javax.jws.WebService;
@WebService
public interface UserService extends IService<UserDO> {
String test(String name);
}
package com.example.demo.service.serviceimpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dao.UserDao;
import com.example.demo.domain.UserDO;
import com.example.demo.service.UserService;
public class UserServiceimpl extends ServiceImpl<UserDao, UserDO> implements UserService {
@Override
public String test(String name){
return name+",你好";
}
}
去除mybatisplus后不再报错的代码
package com.example.demo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.domain.UserDO;
import javax.jws.WebService;
@WebService
public interface UserService{
String test(String name);
}
package com.example.demo.service.serviceimpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dao.UserDao;
import com.example.demo.domain.UserDO;
import com.example.demo.service.UserService;
public class UserServiceimpl implements UserService {
@Override
public String test(String name){
return name+",你好";
}
}
|