Send XML over Sockets

I am beginning and I need to send XML formatted data from Swing Client to Server for parsing/processing/and response.
There are no web server available to use. I think its best to use socket connection, but how do I send xml data over socket, and how do I receive it from server and parse it?
I have read and cannot find a similar example.

Xerces has DOMSerializer which can be used to serialize a Document object to a string. Once it's a string it's trivial to transmit over a socket connection. On the other side, to parse it, you'll have to create a StringReader for the received string and then an InputSource from the StringReader. You'll then be able to pass the InputSource to the DocumentBuilder.parse( ) method to generate a Document on the receiving side.
Hope that helps,
- Jesse

Similar Messages

  • Problem with Sending files over Sockets

    Hi. I have a problem when I try to send files over sockets. When I send text files it works well but when I try to send .jpg or other kind of files it doesn't work well because some characters are wrong, I hope you can help me.
    Here is my code:
    //Sender code
    import java.io.*;
    import java.net.*;
    class Servidor{
         Servidor(){
              try{
                   String arch="art.jpg";
                   ServerSocket serv=new ServerSocket(125);
                   Socket socket=serv.accept();
                   System.out.println("Conectado");
                   int c;
                   BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                   FileInputStream fis=new FileInputStream(arch);
                   File f=new File(arch);
                   bw.write(""+f.length());
                   bw.newLine();
                   bw.flush();
                   System.out.println("Escribiendo");
                   while((c=fis.read())!=-1){
                        bw.write(c);
                   bw.flush();
                   fis.close();
                   System.out.println("Terminado");
                   while(true){
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Servidor();
    //Client code
    import java.io.*;
    import java.net.*;
    class Cliente{
         Cliente(){
              try{
                   Socket socket=new Socket("localhost",125);
                   System.out.println("Conectado");
                   BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
                   long tam=Long.parseLong(br.readLine());
                   long act=0;
                   FileOutputStream fos=new FileOutputStream("resp.jpg");
                   System.out.println("Recibiendo: "+tam);
                   while(act<tam){
                        fos.write(br.read());
                        act++;
                   System.out.println("Terminado: "+act+" / "+tam);
                   fos.close();
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Cliente();
    }

    I don't think you want BufferedReader and OutputStreamWriter, you want ByteArrayOutputStream and ByteArrayInputStream . The problem is that you are sending jpegs (binary data) as text.

  • Can we send  XML  over HTTPS ?

    Can we send XML over HTTPS ?

    malcolmmc wrote:
    meacod wrote:
    rabbits?
    Rabbits
    http://www.rabbitmq.com/
    They wrote
    +RabbitMQ is designed from the ground up to interoperate with other messaging systems: it is the leading implementation of AMQP, the open standard for business messaging, and, through adapters, supports XMPP, SMTP, STOMP and HTTP for lightweight web messaging.+
    They mentioned only HTTP ....Does HTTPS implied here ?

  • Server to Rich Client sending XML over Http

    I need to send XML data from a Servlet to a rich client over http.
    Currently I am using HttpURLConnection and SaxTransformerFactory to do this.
    Is it better to use SOAP or XML-RPC in this scenario?
    Are there any good online tutorials comparing SOAP, XML-RPC and AXP-Java Net API?
    What are the factors that I need to consider for choosing between these alternatives?
    Please advice. Thanks in advance.

    XML-RPC and SOAP use XML as a way to communicate, but they are used to invoke certain function calls in an application independend manner, not to be used to send XML data. So I'd say it depends on:
    a) what do you do with the XML data?
    b) will you be expanding the application?
    c) how difficult is it to rework the current implementation?

  • Query regarding sending XML over HTTP Post request

    Hello,
    I am trying to send XML data from a server to client via HTTP Post request
    And vice versa � receive the data by a client
    Assume that the xml data looks something like
    <?xml+version="1.0"?>
    So my post query will look like
    http://<IP Address>:<port>/
    POST /MessageReceiver.jsp HTTP/1.0
    Host: www.SomeHost.net
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 38
    %3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
    This information will be received by the client and converted back to xml data.
    My query is - is there some library/open-source stuff that
    does the process of transcoding the entity's non-ASCII characters
    at the server side
    and decoding the URL back to human-readable form at the client side?
    i.e. I need a simple mechanism to convert
    <?xml+version="1.0"?>
    to
    %3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
    at the server side, while sending data
    and do the opposite at the client side to get the xml back.
    Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?
    Or is there any other standard tool that checks for well-formed properties of xml?
    regards,
    Deepak.

    java.net.URLEncoder / URLDecoder?
    Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?No, it's for parsing HTML. An XML parser is checking for well-formedness in any case.

  • Sending xml over http

    I have a WLS 6.0 servlet that receives XML transactions via a post method.
              Code snippet as follows:
              public void doPost(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException
              int txContentLength = req.getContentLength();
              //get entire input xml stream and store in a stringbuffer
              InputStream inp = req.getInputStream();
              BufferedReader br = new BufferedReader(new InputStreamReader(inp));
              byte[] ba = new byte[txContentLength];
              System.out.println("Reading...");
              int bytesRead = inp.read(ba);
              System.out.println("bytesRead= " + bytesRead);
              while(bytesRead < txContentLength) {
              int moreRead = inp.read(ba, bytesRead, (ba.length - bytesRead));
              if(moreRead == -1)
              break;
              bytesRead += moreRead;
              System.out.println("finished reading buffer...");
              StringBuffer sb = new StringBuffer(new String(ba));
              I have a java client on my PC that takes an XML file as input and sends the
              information to the servlet without any problems.
              The problem is a client that is connecting to our network via a T1
              connection. When they send transactions, about 1 out of every 4
              transactions makes it past the "Reading..." statement above. The other
              transactions appear to 'hang' when it hits the inp.read(ba) line above.
              From all indications, that servlet's execute thread appears 'hung' as if the
              inp.read() is waiting forever.
              I've tried using readLine() on the InputStream() and my local client program
              is unaffected - it works OK. The remote client is having problems using
              either method. The only difference I've noted with the remote client is
              that they are using HTTP 1.0 and I'm using HTTP 1.1. Initially, their
              mime-type was null but they've changed it to text/xml and no luck. I've
              even sent them my client code that is working and they are still having
              problems...
              Another strange anomoly is that req.getContentLength() is returning a valid
              number on the transactions that fail. For example, I had some debug code
              that showed the content length and it was always something like 4012 or
              3500, etc. Not -1 as I would expect...
              Has anyone run into this problem with receiving XML transactions?
              Thanks
              Rob Mason
              

    Thanks for the suggestion - I went back and added a check on the
              contentLength to make sure it had a valid number before trying to call any
              'read' methods... still no luck.
              I did go in and put a try/catch around the read() logic below. The
              exception thrown is an InterruptedIOException. The docs say that this is
              thrown 'to indicate that an input or output transfer has been terminated
              because the thread performing it was terminated.'
              This would seem to indicate that WLS is having the problem - not the client?
              Via the console, under the Configuration section, my HTTP section has the
              following values:
              POST timeout secs: 10
              Max POST time: 10
              Max POST size: -1
              Is there anything else I can try on the server level?
              Thanks
              Rob Mason
              "Xiang Rao" <[email protected]> wrote in message
              news:[email protected]...
              >
              > T1 shouldn't be the problem. We even use dialup to upload file via HTTP
              POST. HTTP
              > 1.0 shouldn't be problem. If you think this is the only difference, you
              can ask
              > other developers to change it to HTTP 1.1 when they request your servlet.
              >
              > The hang at read(ba) most likely means no request data are sent to your
              servlet
              > even if you think there should be some data. In your code, you are better
              to add
              > a block to check if the content_length is GREATER THAN 0 (-1 or 0), if
              not, you
              > shouldn't open any inputstream and shouldn't call any read method. If the
              content_length
              > is 0, your character buffer will have length 0 and I really don't know
              what you
              > can put into such buffer. It is not necessary to set a buffer with the
              length
              > of expected Content_Length. Since you use BufferedReader, you can create a
              buffere
              > with large enough size (see 1K, 8K, 16K, etc)and the return value of read
              will
              > give you the exact length you get for each read call, then append result
              to your
              > Stringbuffer. On the other hand, it is better for you to handle
              IOException in
              > your servlet.
              >
              > Ask the other side developers to send you their client code and compare
              their
              > code with your test code word by word. Check how they compute the
              Content_Length
              > and how they send Content_Length field to you. If this field is not
              explicitly
              > set, I think you should get -1 or 0, even there are request data out. Also
              you
              > should check how the data are sent out to make sure they really send you
              request
              > data.
              >
              >
              >
              >
              > "Rob Mason" <[email protected]> wrote:
              > >I have a WLS 6.0 servlet that receives XML transactions via a post
              method.
              > >Code snippet as follows:
              > >
              > > public void doPost(HttpServletRequest req, HttpServletResponse res)
              > > throws ServletException, IOException
              > > {
              > > int txContentLength = req.getContentLength();
              > >
              > > //get entire input xml stream and store in a stringbuffer
              > > InputStream inp = req.getInputStream();
              > > BufferedReader br = new BufferedReader(new InputStreamReader(inp));
              > >
              > > byte[] ba = new byte[txContentLength];
              > > System.out.println("Reading...");
              > > int bytesRead = inp.read(ba);
              > > System.out.println("bytesRead= " + bytesRead);
              > > while(bytesRead < txContentLength) {
              > > int moreRead = inp.read(ba, bytesRead, (ba.length - bytesRead));
              > > if(moreRead == -1)
              > > break;
              > > bytesRead += moreRead;
              > > }
              > >
              > > System.out.println("finished reading buffer...");
              > > StringBuffer sb = new StringBuffer(new String(ba));
              > >}
              > >
              > >
              > >I have a java client on my PC that takes an XML file as input and sends
              > >the
              > >information to the servlet without any problems.
              > >The problem is a client that is connecting to our network via a T1
              > >connection. When they send transactions, about 1 out of every 4
              > >transactions makes it past the "Reading..." statement above. The other
              > >transactions appear to 'hang' when it hits the inp.read(ba) line above.
              > >From all indications, that servlet's execute thread appears 'hung' as
              > >if the
              > >inp.read() is waiting forever.
              > >
              > >I've tried using readLine() on the InputStream() and my local client
              > >program
              > >is unaffected - it works OK. The remote client is having problems using
              > >either method. The only difference I've noted with the remote client
              > >is
              > >that they are using HTTP 1.0 and I'm using HTTP 1.1. Initially, their
              > >mime-type was null but they've changed it to text/xml and no luck. I've
              > >even sent them my client code that is working and they are still having
              > >problems...
              > >
              > >Another strange anomoly is that req.getContentLength() is returning a
              > >valid
              > >number on the transactions that fail. For example, I had some debug
              > >code
              > >that showed the content length and it was always something like 4012
              > >or
              > >3500, etc. Not -1 as I would expect...
              > >
              > >Has anyone run into this problem with receiving XML transactions?
              > >
              > >Thanks
              > >Rob Mason
              > >
              > >
              > >
              >
              

  • Sending object over socket - please help (urgent)

    I have written a server/client application where server sends object to client.
    But on the client I've received the first message "@Line 1: Get ready!!!" TWICE but NEVER the second message "@Line 2: Please input Start".
    Please help me! Its urgent! I appreciate my much in advance.
    The source for Server:
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import sendNode;
    public class TestSer {
         static sendNode sendNodeObj = new sendNode();
    static String inputLine;
         public static void main(String[] args) throws IOException {
    ServerSocket serverSocket = null;
    try {
    serverSocket = new ServerSocket(4444);
    } catch (IOException e) {
    System.err.println("Could not listen on port: 4444.");
    System.exit(1);
    Socket clientSocket = null;
    try {
    clientSocket = serverSocket.accept();
    } catch (IOException e) {
    System.err.println("Accept failed.");
    System.exit(1);
    OutputStream o = clientSocket.getOutputStream();
    ObjectOutput out=new ObjectOutputStream(o);
    BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        clientSocket.getInputStream()));
    sendNodeObj.sendMsg="@Line 1: Get ready!!!";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    sendNodeObj.sendMsg="@Line 2: Please input Start";
    sendNodeObj.typeNode=-2;
    out.writeObject(sendNodeObj);
    out.flush();
    inputLine = in.readLine();
    while (!inputLine.equalsIgnoreCase("Start")) {
         sendNodeObj.sendMsg="@Error, Please input Start";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    inputLine = in.readLine();
    out.close();
    in.close();
    clientSocket.close();
    serverSocket.close();
    The source code for Client :
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.applet.Applet;
    import sendNode;
    public class TestCli extends Applet {
    static sendNode recNodeObj=null;
    public static void main(String[] args) throws IOException {
    BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
    Socket kkSocket = null;
    PrintWriter out = null;
    try {
    kkSocket = new Socket("127.0.0.1", 4444);
    out = new PrintWriter(kkSocket.getOutputStream(), true);
    } catch (UnknownHostException e) {
    System.err.println("Don't know about host.");
    System.exit(1);
    } catch (IOException e) {
    System.err.println("Couldn't get I/O for the connection to: taranis.");
    System.exit(1);
    InputStream i= kkSocket.getInputStream();
    ObjectInput in= new ObjectInputStream(i);
    try {
         recNodeObj = (sendNode)in.readObject();
    System.out.println(recNodeObj.sendMsg);
         recNodeObj = (sendNode)in.readObject();
    System.out.println(recNodeObj.sendMsg);
    if (recNodeObj.sendMsg.equalsIgnoreCase("@Line 2: Please input Start")) {
    out.println("Start");
    } catch (Exception e) {
    System.out.println(e.getMessage());
    System.out.println("receive error.");
    System.exit(1);
    out.close();
    in.close();
    stdIn.close();
    kkSocket.close();
    The object to be sent:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class sendNode implements Serializable {
    String sendMsg;
    int typeNode; // -1 no ObjectNode;
    // 1 right node, 2 base node, 3 left node;
    Object objectNode;

    You forgot to reset the OOS. ObjetOutputStream keeps a buffer of objects, so if you write the same object again with changes on it, you must reset the buffer.
    out.writeObject(sendNodeObj);
    out.flush();
    out.reset();

  • Sending objects over sockets - issues i am having

    Hi, this is my first time posting on these forums and I have exhausted my mental capacity on this problem i have been having the past few days. Hopefully somone could help me out.
    I am doing a uni project, and the goal i am currently trying to achieve is to send an object (serialized) from a client to a server. I will atach the code i have written and i will explain more from there.
    This is the server (part of the class, which calls this method)
    Constructor:
      public Broker(String bID) throws Exception {
        brokerID = bID;
        bServer = new ServerSocket(Integer.parseInt(bID));
        System.out.println("Broker listening on port " + bID);
        this.start();
    Main method
      public static void main(String[] args) throws Exception {
        new Broker("8008");
    run method
      public void run() {
        while(true) {
          try {
            Socket bSocket = bServer.accept();
            System.out.println("Accepted a connection from: " + bSocket.getInetAddress());
            brokerServer(bSocket);
            bSocket.close();
            System.out.println("Connection closed");
          catch (Exception e) { e.printStackTrace(); }
    Broker Server
      public void brokerServer(Socket bSocket) {
        BufferedReader in = null;
        ObjectOutputStream oos = null;
        PrintWriter out = null;
        ObjectInputStream ois = null;
        try {
          while (true) {
            oos = new ObjectOutputStream(new DataOutputStream(bSocket.getOutputStream()));
            out = new PrintWriter(new OutputStreamWriter(bSocket.getOutputStream()));
            ois = new ObjectInputStream(bSocket.getInputStream());
            in = new BufferedReader(new InputStreamReader(bSocket.getInputStream()));
            out.println("Connection with Broker on port " + brokerID + " established");
            out.flush();
            //read in first line
            String str = in.readLine();
            //if lineis null, break while loop
            if (str == null)  break;
            else {
              //a request is recieved from user to get user certificate
              if (str.trim().equals("GETUSERCERT")) {
                //read in the userName, size of paywords and user publick key (used in certificate)
                String userName = in.readLine();
                String size = in.readLine();
                PublicKey userPk = (PublicKey) ois.readObject();
                //generate user certificate
                UserCertificate uc = generateUserCertificate(userName, userPk, Integer.parseInt(size, 10));
                //send text to user stating next message is user certififcate
                out.println("SENDUSERCERT");
                out.flush();
                //user Certificate
                oos.writeObject( (UserCertificate) uc);
                oos.flush();
                break;
              if (str.trim().equals("FINISH"))
                break;
            ois.close();
            oos.close();
            out.close();
            in.close();
        catch(Exception e) { e.printStackTrace(); }
    This is the client
      private void requestUserCertificate(int sizeOfPaywordChain, String BrokerID) {
        String host = "localhost";
        ObjectOutputStream oos = null;
        ObjectInputStream ois = null;
        PrintWriter out = null;
        BufferedReader in = null;
        Socket u2bSocket = null;
        try {
          u2bSocket = new Socket(host, Integer.parseInt(BrokerID));
          System.out.println("Connecting to Broker on port " + BrokerID);
          ois = new ObjectInputStream(new DataInputStream(u2bSocket.getInputStream()));
          oos = new ObjectOutputStream(u2bSocket.getOutputStream());
          out = new PrintWriter(new OutputStreamWriter(u2bSocket.getOutputStream()));
          in = new BufferedReader(new InputStreamReader(u2bSocket.getInputStream()));
          //Informs broker that a user certificate is being requested
          out.println("GETUSERCERT");
          //send to broker, username and size of payword chain
          out.println(userName);
          out.println(sizeOfPaywordChain);
          out.flush();
          //send user's public key accross
          oos.writeObject((PublicKey) userPublicKey);
          oos.flush();
          out.println("FINISH");
          out.flush();
          //wait for response
          while(true) {
            //read in line
            String str = in.readLine();
            //if line is null, break while loop
            if (str == null) break;
            //if line read is "SENDUSERCERT" then next line is userCertificate sent from Broker
            if (str.trim().equals("SENDUSERCERT")) {
              //read User Certificate
              userCert = (UserCertificate)ois.readObject();
              break;
            else System.out.println(str);
          //close connections and streams
          u2bSocket.close();
          ois.close();
          oos.close();
          out.close();
          in.close();
        catch (Exception e) { e.printStackTrace(); }
      }I will be regurarly checking this thread, so any other code which you think i should post i will, i can post is ASAP.
    The problem
    First time i run the programs, it works perfectly, however when i run the client program again, it shows this error
    java.io.EOFException
         at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2438)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1245)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
         at User.requestUserCertificate(User.java:75)
         at User.main(User.java:278)the broker server doesn't display anything.
    Would anyone have any idea whats going on??
    Sometimes when i run it, it might display the above error, or it might work. its about 50/50. I have read heaps of similar problems people have had and posted on this forum, but i still don't have any luck in solving this delema.
    Any kind of help will be greatly appreciated.
    Rish

    I see one problem with the code. You are opening both ObjectInputStream ois and a BufferedReader in on the same socket. This won't work as "in" will read ahead to fill up its buffer. This could cause "ois" to find the socket already at end of stream prematurely. I would only use the Object Streams and send the strings as objects.

  • Sending data over and socket

    when i send messages over socket and receive it using [line = in.readLine()/code]
    if there is a \r\n it stops and makes u have to use readLine again to get the rest of the message
    is there a way to send the message so it totally ignores the \r\n and i can just use readLine once to receive my complete string in one go
    as this newline thing is very annoying
    thanks :)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I assume in is of type BufferedReader? If so, that is the definition of readLine.
    Other options:
    You can use java.util.Scanner to scan until the next delimiter, which you can set.
    You can use readUTF/writeUTF defined in interfaces DataInput/DataOut by
    using classes DataInputStream/DataOutputStream or ObjectInpuitStream/ObjectOutputStream.
    If you are using object stream, you could define any serializable objects you
    like for transmission.

  • Send XML Message via HTTP and Receive Response

    Hello,
    We have a scenario where we need to update Currency Exchange Rates in R/3 via a 3rd party called Oanda.  I'd like to use XI for this Interface, if possible. 
    Basically, we need to send XML over HTTP.  Here's the URL and the XML we need to use for our POST (I'll need to perform the look-up for about 15 currency codes - I plan on using a BPM process to loop through each currency code specified in a flat file):
    http://www.oanda.com/cgi-bin/fxml/fxml?fxmlrequest=<CONVERT><CLIENT_ID>TestAccount1</CLIENT_ID><EXCH>USD</EXCH><EXPR>CAD</EXPR><DATE>03/25/2008</DATE></CONVERT>
    And the reponse looks like this:
    <RESPONSE>
      <EXPR>CAD</EXPR>
      <EXCH>USD</EXCH>
      <AMOUNT>1</AMOUNT>
      <NPRICES>1</NPRICES>
      <CONVERSION>
        <DATE>Mon, 24 Mar 2008 20:00:00 GMT</DATE>
        <ASK>1.0257</ASK>
        <BID>1.0251</BID>
      </CONVERSION>
    </RESPONSE>
    I plan on mapping each reponse to BAPI_EXCHRATE_CREATEMULTIPLE, using BPM.
    So my question is this:  Should I use the HTTP adapter for the out going POST to Oanda?  If so, would the HTTP adapter be consider the sender or the receiver?  Also, how would the XML message be automatically appended to the end of the URL (i.e., after the fxmlrequest parameter)?  I guess I'm a little confused on how to use the HTTP adapter...  Are there any blogs that discuss this type of scenario?
    Thanks,
    Matt

    Hi guys,
    I have few concerns for setting up this scenario.
    1). I have created a data type for request mapping, and teste the mapping.
    The output looks like below:
      <?xml version="1.0" encoding="UTF-8" ?>
      <ns1:MT_CONVERT xmlns:ns1="http://test.com/ExchngRate">
       <CONVERT>
         <CLIENT_ID>test</CLIENT_ID>
         <EXPR>CAD</EXPR>
         <EXCH>USD</EXCH>
         <DATE>10/21/2009</DATE>
         <AMOUNT>1</AMOUNT>
       </CONVERT>
      </ns1:MT_CONVERT>
    How to pass only
      <CONVERT>
         <CLIENT_ID>test</CLIENT_ID>
         <EXPR>CAD</EXPR>
         <EXCH>USD</EXCH>
         <DATE>10/21/2009</DATE>
         <AMOUNT>1</AMOUNT>
       </CONVERT>
    to the receiver HTTP adapter.
    2) I am using URL address in the receiver HTTP adapter.
    Target Host: www.oanda.com
    Path Prefix: cgi-bin/fxml/fxml?fxmlrequest=
    What is will be Service Number?
    Looking forward for you help. Your help is greatly appreciated.
    Thanks,
    Namadev
    Edited by: Namadev Chillal on Oct 21, 2009 5:35 PM

  • How to edit xml file particular value. and how to send xml file over ip address 192.168.2.10 using ftp

    how to edit xml file particular value. and how to send xml file over ip address 192.168.2.10 device using ftp through Ethernet

    Hello
    For using FTP function in LabVIEW, I recommend you to check this document: FTP Basics
    Also, take a look at FTP Browser.vi, which is available at the Example Finder.
    To edit a XML file, try to use VIs in XML palette. Maybe Write to XML.vi helps you.
    Post your current VI if possible.
    Regards
    Mondoni

  • Send xML packet to TCP/IP socket in SOA 11g

    Send xML packet to TCP/IP socket in SOA 11g
    Hi,
    I have a requirement like
    I need to pass xml data to TCP/IP socket in the form of packets in SOA11g.
    How we can do this.Please advise me.step by step procedure helps more.

    Hi,
    There is a JCA Adapter for Sockets available... Have a look at this doc...
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_sock.htm#BABEBEJH
    Cheers,
    Vlad

  • Parse streaming XML over a socket

    Is it possible to parse XML incrementally over a socket connection? I would like to parse and respond dyanamically to streaming XML and I am looking for some direction. Everything that I have read so far with respect to parsing XML from files. Thanks in advance

    You will want to look into a SAX parser, they are specifically intended for parsing xml over an input stream. They call callbacks to handle each element that arrives from the socket.
    However, there are a lot of posts about the sax parsers hanging, and I just posted last week trying to find the cause/solution. I've seen a number of solutions posted, but none have worked in my case. No replies to my post yet.
    Steve

  • Sending images over network socket

    I'm working on a java web server. So far i have managed to get it to send html documents sucessfully to the client web browser, using a BufferedReader, and a PrintWriter object.
    But how should i send images over the socket? using this method doesn't work. Any suggestions?
    Thanks in advance.
    hornetau

    I did it first. You may pay me $10 and get XM2 WebServer 1.2 from my company.
    Ok, I'll help ya out here...
    HTTP protocol in Internet Explorer is "juiced up" meaning that it does not require HTTP data to be correctly sent. To send an image to be deisplayed...
    <html>
    <img src="theImage.gif"></img>
    </html>
    Now, the server will see a GET request like this...
    GET /theImage.gif HTTP/1.1
    Accepts: Image/jpeg, Image/gif, ...
    Your web server (in the IE case just needs to send)...
    output.println(data);
    The data object is a string, that represents the contents of the image.
    To do that, just get the correct File object, connect reader to it, then loop it
    until the reader is no longer ready (reader.ready() != true), as it loops, just append
    the readLine() command to the end of the data string and it will be ok.
    Now this works on IE just fine, using vary small file sizes due to it being loaded directly into
    memory. Casing problem if your app has only 500K of memory and the file size is 700K, 500-700=-200K, so use only small file sizes with this method.
    There is also the URLConnection and HttpURLConnection classes to use that will do this better, but
    they dont have any real way of getting the file's data - that's still YOUR job.

  • Can I render a Flash frame as a bitmap and send it over TCP/IP?

    I want to draw some combination of bitmaps, flash shapes, vectors, text etc and draw them programmatically into my movie using ActionScript, and then get every "rendered" pixel of my movie (at 100% view) into an array that I send to another program over TCP/IP. Can anyone help me here?
    The first part of the question is if its possible to render a frame that is a collection of Flash elements as a bitmap? I know that I can iterate through a bitmap and get every pixel using the getPixel method but I'm trying to access the final rendered frame displayed on my screen, including, as I said Flash shapes and text.
    The second question is what would be the best way to send this "video frame" over TCP/IP? Would I use an XML socket connection? That is the only way I know how to send data out of Flash over TCP/IP but I don't know if it is the only way - the help page says the data needs to be formatted as XML, which seems unwieldly for this application.
    I'm doing this now by using Max/MSP/Jitter to do a screen capture the size and location of my Flash movie and then send out the resulting matrix using a "jit.net.send" object (which lets you send frames of video over TCP/IP), but this is too clumsy for the installation I am building.
    Any help would be greatly appreciated!
    -bob

    Thanks! That was exactly what I was looking for in the first half of the question. And I guess the draw() method works in AS2 as well as AS3. I will test it but from what I understand, I can use a Bitmap as kind of my bottom-level container, then create (in ActionScript) a movie clip that can contain other movie clips or drawing API commands or whatever, animate these various elements then finally draw() them into the bitmap. I see that in AS3 I can even use getPixels or getVector to capture the full "video frame" in one line of code.
    Thanks rothrock, for the helpful links. My application is kind of unusual, in that I'm sending "video" data to a proprietary LED controller box for display on a low resolution LED display. I connect to the box over TCP/IP and send it "frames of video" 20 times a second. I got this to work with this other content and software (Max/MSP/Jitter) and I want to see how I could capture all the rendered pixel data in successive frames of Flash animation, format it properly, then send it over TCP/IP to this controller box. Don't really now enough about the various flavors of TCP/IP connections to figure out how to do this in Flash, and I know there are security limitations built in to Flash that have to be worked around. But my movies are small (say 96 pixels by 72 pixels) and I need to send uncompressed data directly to my controller box, so these interesting links showing how to use server-side scripts to create jpgs or pngs are probably not going to help me. I will hopefully find a higher-level programmer than myself to work this out, and I think some of the techniques here will hopefull prove to be helpful.
    Thanks again for your help!

Maybe you are looking for

  • Query syntax error

    Hi, I've a query for a report as below. I want distinct donor code whereas i have 2 or more customers with same name and i want to retrieve data of customers between specific donor codes.I've a syntax error where i give 'between' for the following sy

  • CS4 Media Encoder doesn't launch

    Have been exporting and rendering files in CS4 for years and for some reason, yesterday, ADOBE Media Encoder stopped launching from the export window of PPRO?  I still get the setting box, save box, but when I click okay, nothing happens; ME does not

  • MIGO Problem for an Stock Transport Order SD Methodology

    Hi All, I had a problem with GR for when i'm configuring STO with delivery. I'm getting an error when i try to post the GR with T.Code:MIGO.  I'm STO from Manufacturing Plant to Depot. I had created. a)Purchase Order b)Delivery through Purchase Order

  • Workflow in Dispute Management

    Hi, Is there anything additionally required to get the standard workflow in FSCM Dispute Management going? I have activated / completed the task specific customising but nothing is happening. Also, where is the option to send WF messages as express?

  • Performance implications of using multiple rules

    Hi: 1.  I have a question about the performance implications of multiple rules through a rule strategy sequence.  Can you share your experience on this? 2. Suppose that I have three rules that are accessed through a rule strategy sequence.  Would the