0

我正在将我们的 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 重新生成(如果可以的话,我想避免,除非我必须这样做)但我相信它们是不同的问题。

任何帮助是极大的赞赏。

谢谢,

阿维

4

1 回答 1

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 请求。

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

谢谢, 阿维纳什

于 2017-04-18T20:35:57.473 回答