java - 如何在 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.
解决方案
问题是关于端点定义的使用。
@Autowired
private Bus bus;
@Bean("queryQuotaWebService")
public Endpoint queryQuotaEndpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, new QueryQuotaWebServiceImpl());
endpoint.publish("/QueryQuotaWebService");
return endpoint;
}
这是所有代码链接。
推荐阅读
- javascript - 使用 socket.io 和 React 获取数据的正确方法是什么?
- loops - 如何在 for 循环的每次迭代中保存变量
- c++ - 是否使用对使用 reinterpret_cast 未定义行为强制转换的指针的引用?
- python - 蟒蛇 | Flask Url_For MissingSchema:无效的 URL 错误
- angular - 有没有办法自动更新和构建一个android应用程序
- hibernate - jBPM在计时器事件后创建重复任务:多个实例正在运行
- python - 通过 dj_rest_auth 在用户注册中保存额外的字段
- azure - 如何在 Azure 上托管静态 HTML 并使其仅对我组织的经过身份验证的用户可用?
- javascript - 使用 Axios 未收到来自后端 RestAPI 的响应错误
- javascript - 如何在由 Visual Studio 代码内部人员打开的两个项目中使用 npm?