Siebel Portal Framework Guide > Delivering Content to External Web Applications >
Connecting to the XML Web Interface
The XML Web Interface can be used against any Siebel business application. Requests to generate XML from Siebel business applications can be submitted through a Siebel Web Server using a query string or an XML command block. Examples of these two methods are provided in the following sections. Query String
You can send HTTP requests to SWE using a query string. For example, the following code sample illustrates an Active Server Page that uses MSXML to make an HTTP request. The request logs in to the Siebel application and navigates to the Account List View. The XML response from SWE is transformed into HTML using XSLT. NOTE: See Sample XSLT for code snippets that demonstrate transforming an XML response from SWE into HTML.
<% @LANGUAGE="VBScript" %>
<%
'----------------------------------------------
'Open HTTP connection and send XML command req
'----------------------------------------------
strURL = "http://" & Request.form ("swe") & "/start.swe?SWECmd=ExecuteLogin&SWEDataOnly=1&SWEUserName=sadmin&SWEPassword=sadmin&SWESetMarkup=XML ZO Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open "GET", strURL, False xmlhttp.send () Set ologinXmlDoc = xmlhttp.responseXML
strCookie = xmlhttp.getResponseHeader ("Set-Cookie") On Error Resume Next If strCookie = "" Then Response.Write ("Unable to connect to Siebel Web Server. Please check Login Name, Password, and Siebel Web Server URL") Response.End
End If strSessionId = mid(strCookie,inStr(strCookie,"!"),inStr(strCookie,";")-inStr(strCookie,"!"))
strURL = "http://" & Request.form ("swe") & "/start.swe?SWECmd=GotoView&SWEView=Account+List+View&SWESetMarkup=XML&SWEDataOnly=1" & "&_sn=" & strSessionId Set xmlhttp = Nothing Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open "GET", strURL, False xmlhttp.send () Set oXmlDoc = xmlhttp.responseXML
'-----------
'Session Var
'-----------
Session ("SWESessionId") = strSessionId Session ("swe") = Request.form ("swe")
'-----------
'Prepare XSL
'-----------
sXsl = "acctresponse.xsl" Set oXslDoc = Server.CreateObject("Msxml2.DOMDocument") oXslDoc.async = false oXslDoc.load(Server.MapPath(sXsl))
%>
<HTML>
<HEAD>
<TITLE>My Portal</TITLE>...
<BODY>
...
<TD colSpan=2><%Response.Write (oXmlDoc.transformNode(oXslDoc))%> </TD>
...
</BODY>
</HTML>
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());
}
|