Use spring integration to send webservice request












0















I want to use spring integration to replace my old webservice gateway. in old gateway, program receive the request and send out by httpclient.
here is my old webservice gateway's send part



 DefaultHttpClient httpClient = null;
Map<String,String> map = new HashMap<String,String>();
httpClient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(dynamicUrl);
String soapRequestData =dynamicXMLString;
HttpEntity re = new StringEntity(soapRequestData, HTTP.UTF_8);
httppost.setHeader("Content-Type","application/soap+xml; charset=utf-8");
httppost.setEntity(re);
try {
HttpResponse response = httpClient.execute(httppost);
if(response.getStatusLine().getStatusCode() == 200) {
String xmlString = EntityUtils.toString(response.getEntity());
System.out.println("-------------------------");
System.out.println(xmlString);
}
} catch (IOException e) {
e.printStackTrace();
}


Now I want to use spring-integration-http to replace the httpclient part.
I use int-http:inbound-gateway to receive the request,use service activator to treat the request and send out by int-http:outbound-gatewy.
inbound-gateway:



    <int:channel id="inchannel"/>
<int:channel id="respReply"/>
<int-http:inbound-gateway request-channel="inchannel" path="**" supported-methods="POST,GET"
reply-channel="respReply">
<int-http:cross-origin/>
</int-http:inbound-gateway>
<int:service-activator input-channel="receiveChannel" ref="serviceActivator" method="serviceActivator"
output-channel="respReply"></int:service-activator>


my spirng integration outbond gateway is like this:



    <int:channel id='reply.channel'>
<int:queue capacity='10'/>
</int:channel>
<int:channel id='request.channel'/>


<int-http:outbound-gateway id="outbound.gateway"
request-channel="request.channel" url-expression="headers.fwdUrl"
http-method-expression="headers.reqMethod"
charset="UTF-8" reply-timeout="5000" reply-channel="reply.channel"
>


my java code in activator



 private GatewaySerive gatewaySerive;
public Message<?> serviceActivator(Message<String> msg){
MessageChannel outRequestChannel = context.getBean("request.channel", MessageChannel.class);
PollableChannel outReplyChannel = context.getBean("reply.channel", PollableChannel.class);
gatewaySerive.getSendOutMsg(msg); // add headers.fwdUrl headers.reqMethod in msg head
try{
outRequestChannel.send(enhanceMsg);
}catch (Exception e){
e.printStackTrace();
System.out.println(e.getMessage());
}
Message<?> replyMesg = outReplyChannel.receive();


and I get the exception when send webservice request:



org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://xxx.asmx]; nested exception is org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error, failedMessage=GenericMessage [payload=60,63,120,109,108,32,118,101,114,115,105,111,xxxxxxxxxxx, headers={content-length=317, http_requestMethod=POST, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, httpMethod=POST, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, respUrl=http://xxx.asmx, host=localhost:8080, http_requestUrl=http://localhost:8080/httpGateway/ws/findPhonePlace, connection=Keep-Alive, id=7450b3a9-7432-8740-f5fa-0914dcbb1b81, contentType=application/soap+xml;charset=utf-8, accept-encoding=gzip,deflate, user-agent=Apache-HttpClient/4.5.6 (Java/1.8.0_131), timestamp=1547907719856}]


how can I slove this? I want to send webservice by spring-integration-http










share|improve this question





























    0















    I want to use spring integration to replace my old webservice gateway. in old gateway, program receive the request and send out by httpclient.
    here is my old webservice gateway's send part



     DefaultHttpClient httpClient = null;
    Map<String,String> map = new HashMap<String,String>();
    httpClient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(dynamicUrl);
    String soapRequestData =dynamicXMLString;
    HttpEntity re = new StringEntity(soapRequestData, HTTP.UTF_8);
    httppost.setHeader("Content-Type","application/soap+xml; charset=utf-8");
    httppost.setEntity(re);
    try {
    HttpResponse response = httpClient.execute(httppost);
    if(response.getStatusLine().getStatusCode() == 200) {
    String xmlString = EntityUtils.toString(response.getEntity());
    System.out.println("-------------------------");
    System.out.println(xmlString);
    }
    } catch (IOException e) {
    e.printStackTrace();
    }


    Now I want to use spring-integration-http to replace the httpclient part.
    I use int-http:inbound-gateway to receive the request,use service activator to treat the request and send out by int-http:outbound-gatewy.
    inbound-gateway:



        <int:channel id="inchannel"/>
    <int:channel id="respReply"/>
    <int-http:inbound-gateway request-channel="inchannel" path="**" supported-methods="POST,GET"
    reply-channel="respReply">
    <int-http:cross-origin/>
    </int-http:inbound-gateway>
    <int:service-activator input-channel="receiveChannel" ref="serviceActivator" method="serviceActivator"
    output-channel="respReply"></int:service-activator>


    my spirng integration outbond gateway is like this:



        <int:channel id='reply.channel'>
    <int:queue capacity='10'/>
    </int:channel>
    <int:channel id='request.channel'/>


    <int-http:outbound-gateway id="outbound.gateway"
    request-channel="request.channel" url-expression="headers.fwdUrl"
    http-method-expression="headers.reqMethod"
    charset="UTF-8" reply-timeout="5000" reply-channel="reply.channel"
    >


    my java code in activator



     private GatewaySerive gatewaySerive;
    public Message<?> serviceActivator(Message<String> msg){
    MessageChannel outRequestChannel = context.getBean("request.channel", MessageChannel.class);
    PollableChannel outReplyChannel = context.getBean("reply.channel", PollableChannel.class);
    gatewaySerive.getSendOutMsg(msg); // add headers.fwdUrl headers.reqMethod in msg head
    try{
    outRequestChannel.send(enhanceMsg);
    }catch (Exception e){
    e.printStackTrace();
    System.out.println(e.getMessage());
    }
    Message<?> replyMesg = outReplyChannel.receive();


    and I get the exception when send webservice request:



    org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://xxx.asmx]; nested exception is org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error, failedMessage=GenericMessage [payload=60,63,120,109,108,32,118,101,114,115,105,111,xxxxxxxxxxx, headers={content-length=317, http_requestMethod=POST, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, httpMethod=POST, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, respUrl=http://xxx.asmx, host=localhost:8080, http_requestUrl=http://localhost:8080/httpGateway/ws/findPhonePlace, connection=Keep-Alive, id=7450b3a9-7432-8740-f5fa-0914dcbb1b81, contentType=application/soap+xml;charset=utf-8, accept-encoding=gzip,deflate, user-agent=Apache-HttpClient/4.5.6 (Java/1.8.0_131), timestamp=1547907719856}]


    how can I slove this? I want to send webservice by spring-integration-http










    share|improve this question



























      0












      0








      0








      I want to use spring integration to replace my old webservice gateway. in old gateway, program receive the request and send out by httpclient.
      here is my old webservice gateway's send part



       DefaultHttpClient httpClient = null;
      Map<String,String> map = new HashMap<String,String>();
      httpClient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost(dynamicUrl);
      String soapRequestData =dynamicXMLString;
      HttpEntity re = new StringEntity(soapRequestData, HTTP.UTF_8);
      httppost.setHeader("Content-Type","application/soap+xml; charset=utf-8");
      httppost.setEntity(re);
      try {
      HttpResponse response = httpClient.execute(httppost);
      if(response.getStatusLine().getStatusCode() == 200) {
      String xmlString = EntityUtils.toString(response.getEntity());
      System.out.println("-------------------------");
      System.out.println(xmlString);
      }
      } catch (IOException e) {
      e.printStackTrace();
      }


      Now I want to use spring-integration-http to replace the httpclient part.
      I use int-http:inbound-gateway to receive the request,use service activator to treat the request and send out by int-http:outbound-gatewy.
      inbound-gateway:



          <int:channel id="inchannel"/>
      <int:channel id="respReply"/>
      <int-http:inbound-gateway request-channel="inchannel" path="**" supported-methods="POST,GET"
      reply-channel="respReply">
      <int-http:cross-origin/>
      </int-http:inbound-gateway>
      <int:service-activator input-channel="receiveChannel" ref="serviceActivator" method="serviceActivator"
      output-channel="respReply"></int:service-activator>


      my spirng integration outbond gateway is like this:



          <int:channel id='reply.channel'>
      <int:queue capacity='10'/>
      </int:channel>
      <int:channel id='request.channel'/>


      <int-http:outbound-gateway id="outbound.gateway"
      request-channel="request.channel" url-expression="headers.fwdUrl"
      http-method-expression="headers.reqMethod"
      charset="UTF-8" reply-timeout="5000" reply-channel="reply.channel"
      >


      my java code in activator



       private GatewaySerive gatewaySerive;
      public Message<?> serviceActivator(Message<String> msg){
      MessageChannel outRequestChannel = context.getBean("request.channel", MessageChannel.class);
      PollableChannel outReplyChannel = context.getBean("reply.channel", PollableChannel.class);
      gatewaySerive.getSendOutMsg(msg); // add headers.fwdUrl headers.reqMethod in msg head
      try{
      outRequestChannel.send(enhanceMsg);
      }catch (Exception e){
      e.printStackTrace();
      System.out.println(e.getMessage());
      }
      Message<?> replyMesg = outReplyChannel.receive();


      and I get the exception when send webservice request:



      org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://xxx.asmx]; nested exception is org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error, failedMessage=GenericMessage [payload=60,63,120,109,108,32,118,101,114,115,105,111,xxxxxxxxxxx, headers={content-length=317, http_requestMethod=POST, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, httpMethod=POST, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, respUrl=http://xxx.asmx, host=localhost:8080, http_requestUrl=http://localhost:8080/httpGateway/ws/findPhonePlace, connection=Keep-Alive, id=7450b3a9-7432-8740-f5fa-0914dcbb1b81, contentType=application/soap+xml;charset=utf-8, accept-encoding=gzip,deflate, user-agent=Apache-HttpClient/4.5.6 (Java/1.8.0_131), timestamp=1547907719856}]


      how can I slove this? I want to send webservice by spring-integration-http










      share|improve this question
















      I want to use spring integration to replace my old webservice gateway. in old gateway, program receive the request and send out by httpclient.
      here is my old webservice gateway's send part



       DefaultHttpClient httpClient = null;
      Map<String,String> map = new HashMap<String,String>();
      httpClient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost(dynamicUrl);
      String soapRequestData =dynamicXMLString;
      HttpEntity re = new StringEntity(soapRequestData, HTTP.UTF_8);
      httppost.setHeader("Content-Type","application/soap+xml; charset=utf-8");
      httppost.setEntity(re);
      try {
      HttpResponse response = httpClient.execute(httppost);
      if(response.getStatusLine().getStatusCode() == 200) {
      String xmlString = EntityUtils.toString(response.getEntity());
      System.out.println("-------------------------");
      System.out.println(xmlString);
      }
      } catch (IOException e) {
      e.printStackTrace();
      }


      Now I want to use spring-integration-http to replace the httpclient part.
      I use int-http:inbound-gateway to receive the request,use service activator to treat the request and send out by int-http:outbound-gatewy.
      inbound-gateway:



          <int:channel id="inchannel"/>
      <int:channel id="respReply"/>
      <int-http:inbound-gateway request-channel="inchannel" path="**" supported-methods="POST,GET"
      reply-channel="respReply">
      <int-http:cross-origin/>
      </int-http:inbound-gateway>
      <int:service-activator input-channel="receiveChannel" ref="serviceActivator" method="serviceActivator"
      output-channel="respReply"></int:service-activator>


      my spirng integration outbond gateway is like this:



          <int:channel id='reply.channel'>
      <int:queue capacity='10'/>
      </int:channel>
      <int:channel id='request.channel'/>


      <int-http:outbound-gateway id="outbound.gateway"
      request-channel="request.channel" url-expression="headers.fwdUrl"
      http-method-expression="headers.reqMethod"
      charset="UTF-8" reply-timeout="5000" reply-channel="reply.channel"
      >


      my java code in activator



       private GatewaySerive gatewaySerive;
      public Message<?> serviceActivator(Message<String> msg){
      MessageChannel outRequestChannel = context.getBean("request.channel", MessageChannel.class);
      PollableChannel outReplyChannel = context.getBean("reply.channel", PollableChannel.class);
      gatewaySerive.getSendOutMsg(msg); // add headers.fwdUrl headers.reqMethod in msg head
      try{
      outRequestChannel.send(enhanceMsg);
      }catch (Exception e){
      e.printStackTrace();
      System.out.println(e.getMessage());
      }
      Message<?> replyMesg = outReplyChannel.receive();


      and I get the exception when send webservice request:



      org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://xxx.asmx]; nested exception is org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error, failedMessage=GenericMessage [payload=60,63,120,109,108,32,118,101,114,115,105,111,xxxxxxxxxxx, headers={content-length=317, http_requestMethod=POST, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, httpMethod=POST, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@348c0b2c, respUrl=http://xxx.asmx, host=localhost:8080, http_requestUrl=http://localhost:8080/httpGateway/ws/findPhonePlace, connection=Keep-Alive, id=7450b3a9-7432-8740-f5fa-0914dcbb1b81, contentType=application/soap+xml;charset=utf-8, accept-encoding=gzip,deflate, user-agent=Apache-HttpClient/4.5.6 (Java/1.8.0_131), timestamp=1547907719856}]


      how can I slove this? I want to send webservice by spring-integration-http







      spring-integration-http






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 at 18:09









      it4Astuces

      365112




      365112










      asked Jan 19 at 16:11









      jsdshjsdsh

      164




      164
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54268967%2fuse-spring-integration-to-send-webservice-request%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54268967%2fuse-spring-integration-to-send-webservice-request%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Liquibase includeAll doesn't find base path

          How to use setInterval in EJS file?

          Petrus Granier-Deferre