Jboss EAP 7 Web 服务问题 "Could not unwrap Operation",生成了不正确的 SOAP 请求

Jboss EAP 7 Webservice issue "Could not unwrap Operation", Incorrect SOAP request is generated

我正在将我们的 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 内部网络服务的问题。我粘贴了 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, and jboss community here 其中一个说他用 cxf 重新生成了(如果可以的话我想避免,除非我必须这样做)但我相信它们是不同的问题。

非常感谢任何帮助。

谢谢,

阿维

我实际上试图避免重新生成存根,但看起来 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 请求。

我知道我的实际问题是在不重新生成存根的情况下找到解决方案。因为除了重新生成存根之外别无他法,所以我认为我修复的方法是唯一的方法。所以将其标记为已回答。如有错误请指正

谢谢, 阿维纳什