如何在 spring 启动时访问 wsdl 方法?

How to access a wsdl method on spring boot?

我在 spring 引导中调用 soap 服务时出现以下错误。我使用 cxf wsdl2java 来实现服务方法。我可以将 wsdl 成功导入到 soap-ui。但是我无法向服务发送 post 请求。

有什么意见,我该如何解决这个问题?

@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
    );
}

这是完整的堆栈信息。

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.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]

问题与端点定义的使用有关。

    @Autowired
    private Bus bus;

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

这里是所有代码link。

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