# Entirex Orchestrator/xml

**URL:** <https://techcommunity.softwareag.com/t/entirex-orchestrator-xml/58418>\
**Category:** Forum\
**Tags:** Former-Crossvision-Products, Service-Orchestrator\
**Created:** [December 30, 2002, 1:22pm UTC](https://techcommunity.softwareag.com/t/entirex-orchestrator-xml/58418 "2002-12-30T13:22:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [December 30, 2002, 1:22pm UTC](https://techcommunity.softwareag.com/t/entirex-orchestrator-xml/58418/1 "2002-12-30T13:22:03Z")

</div>

Hi Collins   
  
 i am using j2sdk1.4.0&tomcat3.2…my problem with Log4j got solved,there was some problem with xml file…from java file i am sending one xml file and sequence file…to OrchestratorGateway, it is giving output  
  
\<error\_message\>  
Your request could not be satisfied. The incoming request did not contain enough  
 information for Orchestrator/XML to determine the processing required.  
\</error\_message\>  
  
  
  
My java File Mediator utility  
=============================  
import java.io.BufferedReader;  
import java.io.ByteArrayOutputStream;  
import java.io.InputStreamReader;  
import java.io.InputStream;  
import java.io.IOException;  
import java.net.URL;  
import java.net.MalformedURLException;  
import java.util.Vector;  
import java.util.Enumeration;  
import java.net.HttpURLConnection;  
import java.net.ProtocolException;  
  
/  
 **\* The MediatorUtility class is used to  
 \* post requests to mediator and recieve response  
 \***

**\* \*  
 \*@ author Sandhya Dacha  
 \*  
 \*/  
public class MediatorUtility  
{  
 //need to remove hardcoded values**  
  
 **final static String HTTP\_PROTOCOL = “http:”;  
 final static String ORCHESTRATOR\_NAME = “orchestrator”;  
 final static String XBRIDGE\_WEB = “xbridge.web”;  
 final static String PORTAL\_SERVLET = “portal.servlet”;  
 final static String TYPE\_TEXT\_XML = “text/xml”;  
 final static String S\_CONTENT\_TYPE = “Content-Type”;  
 final static String S\_SLASH = “/”;  
 final static String TYPE\_APPLICATION\_XML = “application/xml”;  
 final static String SEQUENCER\_PROPERTY = “xbd.sequence.uri”;  
 static final String DEFAULT\_XBRIDGE\_WEB = “default\_xbridge.web”;  
 static final String DEFAULT\_PORTAL\_SERVLET = “default\_portal.servlet”;**  
  
 **static String \_destinationURL = null;  
 static byte[] \_dataArray = null;  
 static String \_url = null;  
 static String \_sequenceFile = null;**  
  
 **/**  
 \* getResultsFromMediator will send the input XML and sequence file to the specified servlet passed through the  
 \* system property, portal.servlet. The default servlet is  
 \* OrchestratorGateway. If the servlet is OrchestratorGateway,  
 \* an additional argument, the URL format of sequence file will  
 \* be required.  
 \* Note that the MediatorUtility only support the “POST” method.  
  
_/  
 public static byte[] getResultsFromMediator(String argSequenceFile, String argInputXML)throws Exception{_  
  
 _HttpURLConnection \_httpConnection = null;  
 // use System.getProperty to figure out where the xbridge web is  
 // and what the portal servlet is_  
  
 _String xbridgeWeb = System.getProperty (XBRIDGE\_WEB, “[//localhost:8080/orchestrator](https://localhost:8080/orchestrator)”);  
 String portalServlet = System.getProperty (PORTAL\_SERVLET, “OrchestratorGateway”);_  
  
 _\_sequenceFile=argSequenceFile;  
 // get the destination URL_  
  
 _\_destinationURL = HTTP\_PROTOCOL + xbridgeWeb + S\_SLASH + portalServlet;  
 //\_destinationURL =“[http://localhost:8080/orchestrator/OrchestratorGateway](http://localhost:8080/orchestrator/OrchestratorGateway)”;  
 //OrchestratorGateway";  
 //OrchestratorGateway";_  
  
 _\_dataArray=argInputXML.getBytes();_  
  
 _// get the URL for HTTP protocol  
 \_url = (\_sequenceFile == null) ?  
 \_destinationURL:  
 \_destinationURL;  
 //+ “?” + SEQUENCER\_PROPERTY + “=” + \_sequenceFile;  
 System.out.println("URL: " + \_url);_  
  
 _// get the HTTP URL  
 URL httpURL = null;  
 try {  
 httpURL = new URL(\_url);  
 } catch(MalformedURLException e) {  
 System.out.println("new URL: " + \_url + e.toString());  
 //throw new MediatorConnectionException(e);  
 }_  
  
 _// open the HTTP URL connection  
 try {  
 \_httpConnection =(HttpURLConnection) httpURL.openConnection();  
 } catch(IOException e) {  
 System.out.println("Cannot open URL connection: " + e.toString());  
 //throw new MediatorConnectionException(e);  
 }_  
  
 _// mo caching of documents  
 \_httpConnection.setUseCaches(false);_  
  
 _// only support the “POST” method  
 try {  
 \_httpConnection.setRequestMethod(“POST”);  
 } catch(ProtocolException e) {  
 System.out.println(“setRquestMethod: " + e.toString());  
 }_  
  
 _// use the URL connection for output  
 \_httpConnection.setDoOutput(true);_  
  
 _// set the default value of a general request property  
 \_httpConnection.setRequestProperty(S\_CONTENT\_TYPE, TYPE\_TEXT\_XML);_  
  
 _// use the URL connection for input  
 \_httpConnection.setDoInput(true);_  
  
 _// send the document and receive the reply through the HTTP connection  
 int responseCode = 0;  
 byte[] rDataArray = null;  
 try{  
 httpSend(\_httpConnection);  
 System.out.println(“send was sucessfull”);  
 rDataArray = httpReceive(\_httpConnection);_  
  
 _// get and check the three digit HTTP status code where  
 // 1xx: Informational  
 // 2xx: Success  
 // 3xx: Redirection  
 // 4xx: Client Error  
 // 5xx: Server Error  
 responseCode = \_httpConnection.getResponseCode();  
 System.out.println(”-----\> Response Code: " + responseCode);_  
  
 _// print the error message if the status code is not 200 (HTTP\_OK)  
 if (responseCode != HttpURLConnection.HTTP\_OK) {  
 System.out.println(“HttpURLConnection response error\n”+responseCode);  
 //throw new LicenseChkrException(“some error occured while connecting to mediator”);  
 return null;  
 }  
 return rDataArray;  
 } catch(Exception e) {  
 System.out.println("Error! " + \_url + “: " + e.toString());  
 return null;  
 }finally{_  
  
 _// disconnet the HTTP connection  
 \_httpConnection.disconnect();  
 System.out.println(”_\*\*\*\*\*\*\*\* done \*\*\*\*\*\*\*\*\*\*\n");  
 }  
 }  
  
 /  
 **\* httpSend will send the document out through the opened  
 \* HTTP connection.  
 \*/  
private static void httpSend(HttpURLConnection \_httpConnection) throws Exception  
 {  
 System.out.println(“httpSend: … start …”);**  
  
 **int responseCode = 0;  
 String msg = null;**  
  
 **try {  
 System.out.println(“\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\n” + new String(\_dataArray));**  
  
 **// write the document to the output stream of the HTTP connection  
 \_httpConnection.getOutputStream().write(\_dataArray);**  
  
 **System.out.println(“\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\n”);  
 } catch(IOException e) {  
 msg = "httpSend: " + e.toString();  
 System.out.println(msg);  
 throw new Exception(msg);  
 } finally {  
 // close the output stream of the HTTP connection if error  
 \_httpConnection.getOutputStream().close();  
 }**  
  
 **System.out.println("httpSend: … done … bytes sent: " + \_dataArray.length);  
 }**  
  
 **/**  
 \* httpReceive will receive the reply document through the opened  
 \* HTTP connection.  
 \*/  
 private static byte httpReceive(HttpURLConnection \_httpConnection) throws Exception  
 {  
 System.out.println(“httpReceive: … start …”);  
  
 int rContentLength = 0;  
 byte rDataArray = null;  
  
 // get the content type  
 String rContentType = \_httpConnection.getContentType();  
  
 // use application/xml if no content type is specified  
 if (rContentType == null)  
 rContentType = TYPE\_APPLICATION\_XML;  
  
 // read the document from the output stream of the HTTP connection  
 byte buf = new byte[4096];  
 try {  
 ByteArrayOutputStream baos = new ByteArrayOutputStream ();  
 InputStream is = \_httpConnection.getInputStream ();  
 for (int i=0; (i=is.read (buf, 0, 4096)) != -1; ) baos.write (buf, 0, i);  
 rDataArray = new byte[rContentLength=baos.size ()];  
 rDataArray = baos.toByteArray ();  
 } catch(IOException e) {  
 // cannot receive for some reason  
 String eMsg = “httpReceive: " + e.toString();  
 e.printStackTrace();  
 System.out.println(eMsg);  
 throw new Exception(e.getMessage());  
 } finally {  
 // close the output stream of the HTTP connection if error  
 \_httpConnection.getInputStream().close();  
 }  
  
 // print the content type, content length, and the document  
 System.out.println(“httpReceive: Content-Type: " + rContentType +  
 “, Content-Length: " + rContentLength + “\n” +  
 “\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\n” + new String[rDataArray) + “\n” +  
 “\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\n” +  
 “httpReceive: … done … bytes received: " + rContentLength);  
  
 return rDataArray;  
 }  
 public static void main(String args)throws Exception{  
  
 System.out.println(“Checking for valid license”);  
 String inputXML=”\<?xml version='1.0'?\>ramakrishna cellexchangeKKK KKKKKKKK chess cricket KKKKKKKK shoban business KKKKKKKKvollyballtennis KKKKKKKK ”;  
 MediatorUtility.getResultsFromMediator(“[http://localhost:8080/orchestrator/samples/data/transformsequece.xml](http://localhost:8080/orchestrator/samples/data/transformsequece.xml)”, inputXML);  
  
 }  
  
} // MediatorUtility  
  
  
Input xml file   
==============  
i am passing xml file in Mediator.java as string inputXML  
  
  
Sequence File  
=============  
=  
  
 \< !–{Name: step};{Notes: }–\>  
  
  
  
  
  
  
the item1.xsl file  
====================  
  
\<?xml version="1.0"?\>  
\<xsl:stylesheet version=“1.0”  
 xmlns:xsl=“[XSLT Namespace](http://www.w3.org/1999/XSL/Transform)” \>  
  
\< !–  
  
\<xsl:template name=“item”\>  
**\<xsl:value-of select=“item” /\>**    
  
xsl:copy  
 \<xsl:apply-templates select=“office/tellme” /\>  
 \</xsl:copy\>  
\</xsl:template\>  
  
\<xsl:template name=“office”\>  
\<xsl:value-of select=“office” /\>   
  
\</xsl:template\>  
  
  
 →   
  
\<xsl:template match=”/”\>  
\<xsl:call-template name=“first” /\>  
\<xsl:call-template name=“second” /\>  
\<xsl:apply-templates select=“root/person” /\>  
\</xsl:template\>  
  
\<xsl:template name=“first”\>  
 **Person1 details**    
  
\<xsl:value-of select=“root/person[1]/name” /\>   
  
\<xsl:value-of select=“root/person[1]/office” /\>   
  
\<xsl:value-of select=“root/hobbies[1]/first” /\>   
  
\<xsl:value-of select=“root/hobbies[1]/second” /\>   
  
\</xsl:template\>  
  
\<xsl:template name=“second”\>  
 **Person2 details**    
  
\<xsl:value-of select=“root/person[2]/name” /\>   
  
\<xsl:value-of select=“root/person[2]/office” /\>   
  
\<xsl:value-of select=“root/hobbies[2]/first” /\>   
  
\<xsl:value-of select=“root/hobbies[2]/second” /\>   
  
\</xsl:template\>  
  
  
\<xsl:template match=“root/person” \>  
\<xsl:number value=“position[)” format="1. "/\>  
  
 **Person details**    
  
\<xsl:value-of select=“name” /\>   
  
\<xsl:value-of select=“office” /\>   
  
\<xsl:value-of select=“hobbies/first” /\>   
  
\<xsl:value-of select=“hobbies/second” /\>   
  
  
\</xsl:template\>  
  
\</xsl:stylesheet\>   
  
  
 please kindly look into this  
  
Regards  
Dacha

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [December 30, 2002, 3:47pm UTC](https://techcommunity.softwareag.com/t/entirex-orchestrator-xml/58418/2 "2002-12-30T15:47:02Z")

</div>

Hi,  
First, for some reason it seems that the code in your   
getResultsFromMediator method to build the URL has been partially commented out, so your http request doesn’t contain any information about the location of the sequence file. If you uncomment this code you should send an extra argument:  
?xbd.sequence.uri=  
with the URI and this should help.

```auto
// get the URL for HTTP protocol
_url = (_sequenceFile == null) ?
_destinationURL:
_destinationURL + "?" + SEQUENCER_PROPERTY + "=" + _sequenceFile;
```

Next, the location of the sequence file seems to contain a typo:  
MediatorUtility.getResultsFromMediator(“[http://localhost:8080/orchestrator/samples/data/transformsequece.xml](http://localhost:8080/orchestrator/samples/data/transformsequece.xml)”  
  
Shouldn’t there be an extra “n” in transformsequence.xml?  
  
Third, the location of the stylesheet in the SagTransformer step of the sequence should be (I think) a URL like this:  
  
where (in my case) item1.xsl lives in the same location as the transformsequence.xml file.  
  
Finally, the stylesheet tries to create several output elements like this:  
 **Person1 details**   
 **Person1 details**  
and it is illegal to create a DOM document like this with several root nodes. So I changed your stylesheet to wrap the output in a html tag like this:  
\<xsl:template match=“/”\>  
  
\<xsl:call-template name=“first” /\>  
\<xsl:call-template name=“second” /\>  
\<xsl:apply-templates select=“root/person” /\>  
  
\</xsl:template\>  
and now it works - I get this output:  
**Person1 details**  
ramakrishna  
cellexchangeKKK  
  
\<br/  
\> **Person2 details**   
shoban  
business  
  
  
1. **Person de  
tails**   
ramakrishna  
cellexchangeKKK  
chess  
cricket  
2.  
**Person details**   
shoban  
business  
vollyball  
tennis  
  
   
If none of this helps please let us know…  
  
[This message was edited by Bill Leeney on 30 Dec 2002 at 10:41.]

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:39pm UTC](https://techcommunity.softwareag.com/t/entirex-orchestrator-xml/58418/3 "2021-04-02T14:39:14Z")

</div>


