Search code examples
javaspring-bootcxfwsdl2java

How to access a wsdl method on spring boot?


I'm getting below error when I call a soap service in spring boot. I used cxf wsdl2java for implementing service methods. I can import wsdl successfully to soap-ui. But I can not send a post request to the service.

Is there any opinion, how can I solve this problem?

@Bean("queryQuotaWebService")
public Endpoint queryQuotaEndpoint() {
       EndpointImpl endpoint = new EndpointImpl(bus, "#queryQuota");
       endpoint.setImplementorClass(QueryQuotaWebServiceImpl.class);
       endpoint.publish("/QueryQuotaWebService");
       return endpoint;
}
@Controller("queryQuota")
public class QueryQuotaWebServiceImpl implements QueryQuotaWebService {

   @Override
   public GetQuotaInfoResultBean getQuotaInfo(GetQuotaInfoInput parameters) 
   {
      try {
          return (GetQuotaInfoResultBean) pimsOperationExecutor.execute(parameters);
      } catch (MyException e) {
          throw new RuntimeException(e);
      }
   }
}
@WebService(targetNamespace = "http://webservice.mycompany.com.tr/", name = "QueryQuotaWebService")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface QueryQuotaWebService {

@WebMethod
    @WebResult(name = "getQuotaInfoResponse", targetNamespace = "http://webservice.mycompany.com.tr/", partName = "parameters")
    public GetQuotaInfoResultBean getQuotaInfo(
        @WebParam(partName = "parameters", name = "getQuotaInfoInput", targetNamespace = "http://webservice.mycompany.com.tr/")
        GetQuotaInfoInput parameters
    );
}

Here is full stacktace.

2019-05-22 16:22:21.339 WARN 1388 --- [nio-8081-exec-4] o.a.cxf.phase.PhaseInterceptorChain : Application {http://quota.thirdparty.mycompany.com/}QueryQuotaWebServiceImplService#{http://webservice.mycompany.com.tr/}getQuotaInfo has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: object is not an instance of declaring class while invoking public com.mycompany.thirdparty.quota.GetQuotaInfoResultBean com.mycompany.thirdparty.quota.QueryQuotaWebServiceImpl.getQuotaInfo(com.mycompany.thirdparty.quota.GetQuotaInfoInput) with params [com.mycompany.thirdparty.quota.GetQuotaInfoInput@256dd1f9]. at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:166) ~[cxf-core-3.3.1.jar:3.3.1] at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:267) ~[cxf-rt-frontend-jaxws-3.3.1.jar:3.3.1] at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:140) ~[cxf-core-3.3.1.jar:3.3.1] at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232) ~[cxf-rt-frontend-jaxws-3.3.1.jar:3.3.1] at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85) ~[cxf-rt-frontend-jaxws-3.3.1.jar:3.3.1] at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:74) ~[cxf-core-3.3.1.jar:3.3.1] at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[cxf-core-3.3.1.jar:3.3.1] at java.util.concurrent.Executors$RunnableAdapter.call$$$capture(Executors.java:511) ~[na:1.8.0_191] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java) ~[na:1.8.0_191] at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[na:1.8.0_191] at java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:1.8.0_191]


Solution

  • Problem was about useage of endpoint definiton.

        @Autowired
        private Bus bus;
    
        @Bean("queryQuotaWebService")
        public Endpoint queryQuotaEndpoint() {
            EndpointImpl endpoint = new EndpointImpl(bus, new QueryQuotaWebServiceImpl());
            endpoint.publish("/QueryQuotaWebService");
            return endpoint;
        }
    

    here is all code link.

    https://github.com/ekocbiyik/cxf-springboot