Hi ,

I am working on TCP socket communcation with wso2 ESB.

I was able to send message to TCP server however once the TCP server is
replying back i cannot see the message in wso3 esb, could you please help
me with this.

API :

<api xmlns="http://ws.apache.org/ns/synapse"; name="ScalesAPI"
context="/scale">
   <resource methods="GET" url-mapping="/scale">
      <inSequence>
         <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
         <property name="OUT_ONLY" value="true"/>
         <payloadFactory media-type="text">
            <format>&amp;lt;RN&amp;gt;</format>
            <args/>
         </payloadFactory>
         <call>
            <endpoint>
               <address uri="tcp://192.168.80.87:8915"/>
            </endpoint>
         </call>
         <log level="custom">
            <property name="After Call" expression="."/>
         </log>
      </inSequence>
      <outSequence>
         <log level="custom">
            <property name="Into Out Sequence" expression="."/>
         </log>
      </outSequence>
   </resource>
</api>



JAVA Code :
public class TCPServer {

public static void main(String[] args) throws Exception {
String clientSentence;
String name = "Amit";
  String capitalizedSentence = "&lt; 00 23 &gt;";
  ServerSocket welcomeSocket = new ServerSocket(8915);

  while (true) {
   Socket connectionSocket = welcomeSocket.accept();
   BufferedReader inFromClient =
    new BufferedReader(new
InputStreamReader(connectionSocket.getInputStream()));
   DataOutputStream outToClient = new
DataOutputStream(connectionSocket.getOutputStream());
   clientSentence = inFromClient.readLine();
   System.out.println("Received: " + clientSentence);
  // capitalizedSentence = clientSentence.toUpperCase() + 'n';
   System.out.println("Received1: " + clientSentence);
  //outToClient.writeBytes(capitalizedSentence);

   PrintStream p = new PrintStream(connectionSocket.getOutputStream());

   p.println(capitalizedSentence);

   outToClient.close();
   System.out.println("Received2: " + clientSentence);
   inFromClient.close();
   connectionSocket.close();
  }

}

}



Logs :

[2018-08-23 14:28:54,732] []  INFO - LogMediator After Call = <?xml
version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="
http://www.w3.org/2003/05/soap-envelope";><soapenv:Body><axis2ns43:text
xmlns:axis2ns43="http://ws.apache.org/commons/ns/payload
">&amp;lt;RN&amp;gt;</axis2ns43:text></soapenv:Body></soapenv:Envelope>




Regards,

Amit Gupta
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to