我正在将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。
modules.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>
我查看了一个现有的post和jboss社区here其中一个人说他用cxf重新生成(如果可以,我想避免,除非我必须)但他们是不同的我相信的问题。
非常感谢任何帮助。
谢谢,
阿维
答案 0 :(得分:0)
我实际上是在尝试避免重新生成存根,但看起来Jboss EAP 7在内部使用CXF来运行服务。早期使用JAX-WS生成存根时,Jboss 5在内部使用JAX-WS。
因此,结论是使用JAX-WS生成的任何存根都没有其他方法,只能使用任何存根生成工具重新生成存根。我使用Apache CXF和生成的存根至少 Port .java文件是不同的
/**
* This class was generated by Apache CXF 3.1.10
* 2017-04-07T11:01:43.951-05:00
* Generated source version: 3.1.10
*
*/
@WebService(targetNamespace = "Crmr5100", name = "Crmr5100Port")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface Crmr5100Port {
@WebMethod(operationName = "Crmr5100AdditionalIdDetail", action = "Crmr5100")
@WebResult(name = "Crmr5100AdditionalIdDetailResponse", targetNamespace = "Crmr5100", partName = "Crmr5100AdditionalIdDetail")
public Crmr5100AdditionalIdDetailResponse crmr5100AdditionalIdDetail(
@WebParam(partName = "Crmr5100AdditionalIdDetail", name = "Crmr5100AdditionalIdDetail", targetNamespace = "Crmr5100")
Crmr5100AdditionalIdDetail crmr5100AdditionalIdDetail
);
}
然后以正确的格式生成SOAP请求。
我知道我的实际问题是在不重新生成存根的情况下找到解决方案。因为除了重新生成存根之外别无他法,我认为我修复的方式是唯一的方法。所以标记为已回答。如果我错了,请纠正。
谢谢, 阿维纳什