Siebel Portal Framework Guide > Delivering Content to External Web Applications > Connecting to the XML Web Interface >

XML Command Block


You can use an XML command block to send the HTTP request through the Siebel Web server. For example, you can submit inbound XML documents to SWE as the HTTP request body data. In the Java code sample below, the XML command block opens a socket connection to the Web server and writes the request data stream to the socket's OutputStream.

public static final String FULL_XML_PROC_STR = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

   InputStream      in;
   BufferedReader   fromServer;
   PrintWriter      toServer;
   Socket           socket;
   String           payload;
   String           line;

   try

      {

         if (request != null && request.length() > 0)

         {

            // send request

            socket   = new Socket(url.getHost(), url.getPort());

            toServer = new PrintWriter(new                OutputStreamWriter(socket.getOutputStream()));
               in    = socket.getInputStream();
               payload = FULL_XML_PROC_STR + request;
            toServer.println("POST " + url.toString() + " HTTP/1.0");

            toServer.println("Cookie: " + sessionID);
            toServer.println("Content-Type: text/xml");
            toServer.print("Content-Length: ");
            toServer.println(payload.length());
            toServer.println("");
            toServer.println(payload);
            toServer.flush();

         fromServer = new BufferedReader(new InputStreamReader(in));

            // read the response
               while ((line = fromServer.readLine()) != null)
               {
               . . .
               }
               fromServer.close();
               toServer.close();
               socket.close();
         }
      }

      catch (Exception ex)

      {

      System.err.println(ex.toString());

      }

Siebel Portal Framework Guide Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.