Spring integration 如何使用spring集成java dsl和操作名调用soap Web服务

Spring integration 如何使用spring集成java dsl和操作名调用soap Web服务,spring-integration,spring-ws,spring-integration-dsl,Spring Integration,Spring Ws,Spring Integration Dsl,我试图使用spring集成的MarshallingWebServiceOutboundGateway调用soap Web服务。以下是我的流程,非常简单: @Bean public IntegrationFlow asghar() throws Exception { Map<String, Object> action = new HashMap<>(); action.put("ws_soapAction", "getCardTypes");

我试图使用spring集成的MarshallingWebServiceOutboundGateway调用soap Web服务。以下是我的流程,非常简单:

@Bean
public IntegrationFlow asghar() throws Exception {
    Map<String, Object> action = new HashMap<>();
    action.put("ws_soapAction", "getCardTypes");

    return IntegrationFlows.from("inputChannel")
            .enrichHeaders(action)
            .handle(asgharWebserviceGateway()).get();
} 
这是cxf从wsdl生成的服务接口的一部分

@WebMethod
@WebResult(name = "return", targetNamespace = "http://ws.gateway.manager.br.com/", partName = "return")
public CardTypesResponse getCardTypes(

        @WebParam(partName = "cardGroup", name = "cardGroup")
                CardGroup cardGroup
);
这是同一部分的wsdl:

  <wsdl:message name="getCardTypes">
    <wsdl:part name="cardGroup" type="tns:cardGroup">
    </wsdl:part>
  </wsdl:message>

  <wsdl:message name="getCardTypesResponse">
    <wsdl:part name="return" type="tns:cardTypesResponse">
    </wsdl:part>
  </wsdl:message>

  <wsdl:operation name="getCardTypes">
    <wsdl:input message="tns:getCardTypes" name="getCardTypes">
    </wsdl:input>
    <wsdl:output message="tns:getCardTypesResponse" name="getCardTypesResponse">
    </wsdl:output>
  </wsdl:operation>
  <wsdl:operation name="getCardTypes">
    <soap:operation soapAction="" style="rpc"/>
      <wsdl:input name="getCardTypes">
        <soap:body namespace="http://ws.gateway.manager.br.com/" use="literal"/>
      </wsdl:input>
      <wsdl:output name="getCardTypesResponse">
        <soap:body namespace="http://ws.gateway.manager.br.com/" use="literal"/>
      </wsdl:output>
  </wsdl:operation>
现在,我想知道如何使用操作名(getCardTypes)以及应在何处设置它,以便正确创建soap消息,该消息必须是:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

    <SOAP-ENV:Header>

    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <tns:getCardTypes xmlns:tns="http://ws.gateway.manager.br.com/">
             <tns:cardGroup xmlns:tns="http://ws.gateway.manager.br.com/">
                <code>9865421</code>
                <title>654965587</title>
            </tns:cardGroup>
        </tns:getCardTypes>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

因此,您的
CardGroup
对象必须包装到
GetCardTypes
对象中。SpringWS不是CXF,所以您需要习惯它的契约优先方法

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <tns:cardGroup xmlns:tns="http://ws.gateway.manager.br.com/">
            <code>9865421</code>
            <title>654965587</title>
        </tns:cardGroup>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

    <SOAP-ENV:Header>

    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <tns:getCardTypes xmlns:tns="http://ws.gateway.manager.br.com/">
             <tns:cardGroup xmlns:tns="http://ws.gateway.manager.br.com/">
                <code>9865421</code>
                <title>654965587</title>
            </tns:cardGroup>
        </tns:getCardTypes>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<wsdl:message name="getCardTypes">
    <wsdl:part name="cardGroup" type="tns:cardGroup">
    </wsdl:part>
</wsdl:message>