首页 > 解决方案 > 如何在 Spring Boot 上访问 wsdl 方法?

问题描述

当我在 Spring Boot 中调用肥皂服务时,我遇到了错误。我使用 cxf wsdl2java 来实现服务方法。我可以成功地将wsdl导入soap-ui。但我无法向该服务发送发布请求。

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

@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] oacxf.phase.PhaseInterceptorChain:应用程序 { http://quota.thirdparty.mycompany.com/ }QueryQuotaWebServiceImplService#{ http: //webservice.mycompany.com.tr/}getQuotaInfo 已抛出异常,现在展开 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) 和参数 [com.mycompany.thirdparty.quota.GetQuotaInfoInput@256dd1f9]。在 org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:166) ~[cxf-core-3.3.1.jar:3.3.1] 在 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] 在 org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.

标签: javaspring-bootcxfwsdl2java

解决方案


问题是关于端点定义的使用。

    @Autowired
    private Bus bus;

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

这是所有代码链接。

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


推荐阅读