我正在將我們的Jboss 5 Web服務遷移到Jboss EAP 7.在調用服務時,我們發現生成的SOAP請求合併了兩個標記導致錯誤響應。Jboss EAP 7 Webservice問題「無法解開操作」,生成不正確的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網址,新QName(名稱空間,服務名)和的getPort(新QName(名稱空間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
}
以下片斷是被我的SOAPHandler打印到控制檯上,當我撥打服務的Jboss EAP 7服務器上的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再生(我想避免,如果我可以,除非我必須),但他們是我相信的不同問題。
任何幫助,非常感謝。
感謝,
阿維