SOAPService invoking the getXMLData() method.

Java To Go!
SOAP-enabling business-to-business EJB
E-Ming Tan
Listing 3. SOAPService invoking the getXMLData() method.


public class SOAPService {
    //do whatever normal declarations here ...

  public String getXMLData(int xmlDataId, String xmlData, String
                                    xPath) throws IOException,
ProcessingErrorException, Exception {
    String xmlContent = “”;

    String retVal = null;

    System.out.println(“\nBeginning of SOAP containerManagedXML
                                       Bean.Client service ...\n”);

    XMLImplPK xmlDataKey = new XMLImplPK();
    xmlDataKey.id = xmlDataId;
    Vector v = new Vector();

    try {
      // Contact the XMLBean container (the “XMLImplHome”)
                                              through JNDI.
      Context ctx = getInitialContext();
      XMLImplHome home = (XMLImplHome) ctx.lookup(“container
                            ManagedXMLBean.XMLImplHome”);

      // Find the XMLImpl or create it.
      XMLImpl xmlBean = null;
      try {
        System.out.println(“Looking up xml data with id = “ + xml
                                                DataId + “...\n”);
        xmlBean = (XMLImpl) home.findByPrimaryKey(xmlDataKey);
      }
      catch (Exception e) {
        //System.out.println(“Did not find “ + xmlDataId + “ : “ + e);
      }

    //do whatever normal application processing here ...

    //do the same thing for getXMLDoc() ...

      ......
}