我正在将我们的 Jboss 5 Web 服务迁移到 Jboss EAP 7。在调用该服务时,我们看到生成的 SOAP 请求合并了两个标签导致错误响应的问题。
首先我看到一个警告:无法展开操作
09:53:10,936 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-24) Creating Service {Crmr5100}Crmr5100 from WSDL: http://intwsdev.internal.myservices:8080/crm/services/Crmr5100?wsdl 09:53:11,069 WARNING [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (default task-24) Could not unwrap Operation {Crmr5100}Crmr5100AdditionalIdDetail to match method "public abstract void webservices.stubs.crmr5100.Crmr5100Port.crmr5100AdditionalIdDetail(webservices.stubs.crmr5100.Crmr5100AdditionalIdDetail$Request,javax.xml.ws.Holder,javax.xml.ws.Holder)"
我明白警告说方法不匹配,但我认为不是真的,下面是我生成的端口接口
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.1.3.2-02/08/2010 05:22 PM(mockbuild)-SNAPSHOT
* Generated source version: 2.0
*/
@WebService(name = "Crmr5100Port", targetNamespace = "Crmr5100")
public interface Crmr5100Port {
/**
*
* @param response
* @param error
* @param request
*/
@WebMethod(operationName = "Crmr5100AdditionalIdDetail", action = "Crmr5100")
@RequestWrapper(localName = "Crmr5100AdditionalIdDetail", targetNamespace = "Crmr5100", className = "webservices.stubs.crmr5100.Crmr5100AdditionalIdDetail")
@ResponseWrapper(localName = "Crmr5100AdditionalIdDetailResponse", targetNamespace = "Crmr5100", className = "webservices.stubs.crmr5100.Crmr5100AdditionalIdDetailResponse")
public void crmr5100AdditionalIdDetail(
@WebParam(name = "request", targetNamespace = "")
webservices.stubs.crmr5100.Crmr5100AdditionalIdDetail.Request request,
@WebParam(name = "response", targetNamespace = "", mode = WebParam.Mode.OUT)
Holder<webservices.stubs.crmr5100.Crmr5100AdditionalIdDetailResponse.Response> response,
@WebParam(name = "error", targetNamespace = "", mode = WebParam.Mode.OUT)
Holder<webservices.stubs.crmr5100.Crmr5100AdditionalIdDetailResponse.Error> error);
}
这就是我调用服务的方式,wsInterfaceFactory.getPort() 只调用 javax.xml.ws.Service(URL url, new QName(namespace, serviceName) 和 getPort(new QName(nameSpace, portName), portClass)
Crmr5100Port ws = wsInterfaceFactory.getPort(Crmr5100Port.class);
Crmr5100AdditionalIdDetail.Request request = new Crmr5100AdditionalIdDetail.Request();
request.setCommand("OPEN");
request.setClientId(credentials.getUsername());
request.setClientPassword(credentials.getWebServicePassword());
request.setComCfg(systemOptions.getOptionValueAsString("COMCFG"));
Crmr5100AdditionalIdDetail.Request.ImportImap1AdditionalId importAddn = new Crmr5100AdditionalIdDetail.Request.ImportImap1AdditionalId();
importAddn.setId(BigInteger.valueOf(a_additionalId));
importAddn.setAdditionalId(a_aiNumber);
request.setImportImap1AdditionalId(importAddn);
Holder<webservices.stubs.crmr5100.Crmr5100AdditionalIdDetailResponse.Response> response = new Holder<>();
Holder<webservices.stubs.crmr5100.Crmr5100AdditionalIdDetailResponse.Error> error = new Holder<>();
ws.crmr5100AdditionalIdDetail(request, response, error);
if (error.value == null && response.value != null) {
Crmr5100AdditionalIdDetailResponse.Response res = response.value;
// Do something with my response
}
下面的代码片段是当我在 Jboss EAP 7 服务器上调用服务时,我的 SOAPHandler 在控制台中打印的 SOAP 请求
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
<soap:Body>
<ns2:Crmr5100AdditionalIdDetail xmlns:ns2="Crmr5100" clientId="AMORAM" clientPassword="XXXXX" comCfg="TCP myserv4sprhgend1 4275" command="OPEN">
<ImportImap1AdditionalId>
<Id>368638372002136</Id>
<AdditionalId>WQ0013966001</AdditionalId>
</ImportImap1AdditionalId>
</ns2:Crmr5100AdditionalIdDetail>
</soap:Body>
</soap:Envelope>
下面是当我在独立的 java 程序(在 main 方法中调用服务)或通过 SOAP UI 运行上述代码时为相同操作生成的 SOAP 请求,如果您观察到这两个请求,第一个请求缺少标记及其内容合并到其前身标签中
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:Crmr5100AdditionalIdDetail xmlns:ns2="Crmr5100">
<request command="OPEN" clientId="AMORAM" clientPassword="XXXXX" comCfg="TCP myserv4sprhgend1 4275">
<ImportImap1AdditionalId>
<Id>368638372002136</Id>
<AdditionalId>WQ0013966001</AdditionalId>
</ImportImap1AdditionalId>
</request>
</ns2:Crmr5100AdditionalIdDetail>
</S:Body>
</S:Envelope>
我不确定这是否是 Jboss 内部 Web 服务的问题。我粘贴了我的 modules.xml 以找出 jboss 使用的 jar。
模块.xml
<module xmlns="urn:jboss:module:1.3" name="org.apache.cxf.impl">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="cxf-rt-bindings-coloc-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-bindings-object-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-bindings-soap-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-bindings-xml-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-databinding-aegis-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-databinding-jaxb-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-frontend-jaxws-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-frontend-simple-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-management-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-security-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-security-saml-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-transports-http-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-transports-http-hc-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-transports-jms-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-transports-local-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-wsdl-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-ws-addr-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-ws-mex-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-ws-policy-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-rt-ws-rm-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-tools-common-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-tools-java2ws-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-tools-validator-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-tools-wsdlto-core-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-tools-wsdlto-databinding-jaxb-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-tools-wsdlto-frontend-jaxws-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-services-ws-discovery-api-3.1.4.redhat-1.jar"/>
<resource-root path="cxf-xjc-boolean-3.0.5.redhat-1.jar"/>
<resource-root path="cxf-xjc-bug986-3.0.5.redhat-1.jar"/>
<resource-root path="cxf-xjc-dv-3.0.5.redhat-1.jar"/>
<resource-root path="cxf-xjc-ts-3.0.5.redhat-1.jar"/>
<resource-root path="cxf-xjc-runtime-3.0.5.redhat-1.jar"/>
</resources>
<dependencies>
...
</dependencies>
我查看了一篇现有的帖子,这里的 jboss 社区中的一个说他用 cxf 重新生成(如果可以的话,我想避免,除非我必须这样做)但我相信它们是不同的问题。
任何帮助是极大的赞赏。
谢谢,
阿维