2017-08-23 1 views
0

Je suis nouveau à l'intégration de ressort et à la botte de ressort. Et, mon cas d'utilisation est d'interroger un message dans une file d'attente JMS et d'appeler un autre service Web en utilisant le message XML de charge utile provenant de la file d'attente JMS. La charge utile XML contient l'en-tête SOAP, le corps et les en-têtes SAML.ws: la passerelle sortante ajoute l'enveloppe SOAP supplémentaire et l'en-tête au message

je peux frapper le service Web avec la charge utile XML en utilisant l'outil d'interface utilisateur SOAP.

Ceci est mon fichier de configuration d'intégration de printemps.

============================================== ======

<beans:beans xmlns="http://www.springframework.org/schema/integration" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:int="http://www.springframework.org/schema/integration" 
    xmlns:http="http://www.springframework.org/schema/integration/http" 
    xmlns:jms="http://www.springframework.org/schema/integration/jms" 
    xmlns:ws="http://www.springframework.org/schema/integration/ws" 
    xmlns:stream="http://www.springframework.org/schema/integration/stream" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd 
      http://www.springframework.org/schema/integration 
      http://www.springframework.org/schema/integration/spring-integration.xsd 
      http://www.springframework.org/schema/integration/http 
      http://www.springframework.org/schema/integration/http/spring-integration-http.xsd 
      http://www.springframework.org/schema/integration/jms 
      http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd 
      http://www.springframework.org/schema/integration/ws 
      http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd 
      http://www.springframework.org/schema/integration/stream 
      http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd"> 
    <jms:message-driven-channel-adapter id="jmsIn" 
      destination-name="requestQueue" 
      channel="jmsInChannel" 
      error-channel = "error-Channel" /> 


<channel id="error-Channel"/> 
<stream:stdout-channel-adapter id="error-Channel"/> 

<channel id="jmsInChannel"> 
    <interceptors> 
     <wire-tap channel="loggerChannel"/> 
    </interceptors> 
</channel> 

<logging-channel-adapter id="loggerChannel" level="INFO"/> 

<beans:bean id="MY.SOAP-MessageSender" 
    class="org.springframework.ws.transport.http.HttpComponentsMessageSender"> 
    <beans:property name="connectionTimeout" value="30000" /> 
    <beans:property name="readTimeout" value="50000" /> 
</beans:bean> 
    <chain input-channel="jmsInChannel" output-channel="outChannel"> 
     <header-enricher> 
      <header name="Content-Type" value="text/xml;charset=UTF-8" /> 
      <header name="SOAPAction" value="soapaction"/> 
     </header-enricher> 
     <ws:outbound-gateway message-sender="MY.SOAP-MessageSender" uri="http://localhost:8080/soapws-endpoint"/> 
    </chain> 

    <!-- The response from the service is logged to the console. --> 
    <!-- <stream:stdout-channel-adapter id="outChannel"/> --> 
    <channel id="outChannel"> 
     <interceptors> 
      <wire-tap channel="loggerChannel2"/> 
     </interceptors> 
    </channel> 
<logging-channel-adapter id="loggerChannel2" level="INFO"/> 

<beans:bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> 
    <!-- brokerURL, You may have different IP or port --> 
    <beans:constructor-arg index="0" value="tcp://localhost:61616" /> 
</beans:bean> 

    <!-- Spring JMS Template --> 
    <beans:bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate" > 

    <beans:property name="connectionFactory" ref="connectionFactory"/> 

    </beans:bean> 
</beans:beans> 

===================================== ========================

Je peux voir que Spring ajoute une enveloppe SOAP supplémentaire et un en-tête à la charge utile XML existante (qui a déjà le Enveloppe SOAP et charge utile).

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/> 
<SOAP-ENV:Body><soapenv:Envelope xmlns:head="http://header" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://typ"> 
    <soapenv:Header> 
. 
. 
. WS security hader 
    </soapenv:Header> 
</soapenv:Body> 
</soapenv:Envelope> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

Question: Comment puis-je supprimer l'enveloppe SOAP supplémentaire et en-tête SOAP qui s'ajouté. Y a-t-il des propriétés prêtes à l'emploi dans les configurations que je peux utiliser? Si ce n'est pas le cas, veuillez fournir un exemple de code que je peux utiliser. S'il vous plaît aider ... Merci d'avance.

Répondre

0

Comment c'est conçu; il suffit d'envoyer le contenu et la passerelle ajoutera l'enveloppe SOAP. Il est basé sur Spring Web Services.

Si vous voulez rouler votre propre traitement SOAP, utilisez simple passerelle sortante http au lieu.

+0

Si vous avez besoin d'injecter des en-têtes SOAP personnalisé, cochez cette http://docs.spring.io/spring-integration/docs/5.0.0.M6/reference/html/ws.html#ws-message-headers dans la fin à propos de 'DefaultSoapHeaderMapper' –

0

Merci Gary. Je l'ai utilisé la configuration suivante

<header-enricher input-channel="jmsInChannel" 
output-channel="jmsOutChannel"> 
      <header name="Content-Type" value="text/xml;charset=UTF-8" /> 
      <header name="SOAPAction" value="soapaction"/> 
     </header-enricher> 
     <int:channel id="jmsOutChannel" /> 
<http:outbound-gateway extract-request-payload="true" id="webservice.outbound.gateway" request-channel="jmsOutChannel" reply-channel="celsiusChannel" url="http://localhost:8080/soa-ws" expected-response-type="java.lang.String" /> 

à la place de

<chain input-channel="jmsInChannel" output-channel="celsiusChannel"> 
     <header-enricher> 
      <header name="Content-Type" value="text/xml;charset=UTF-8" /> 
      <header name="SOAPAction" value="soapaction"/> 
     </header-enricher> 
     <ws:outbound-gateway message-sender="MY.SOAP-MessageSender" uri="http://localhost:8080/soa-ws"/> 
    </chain> 

Je pense que l'attribut extrait demande-charge utile = "true" http: passerelle sortante a fait l'affaire. Maintenant, l'en-tête et l'enveloppe SOAP supplémentaires ne sont pas ajoutées.