1 Reply Latest reply on Jun 7, 2010 4:36 PM by David Fleeman

    Consuming web service from Coldfusion using JAR created with CXF

    David Fleeman Newbie

      I've successfully generated a JUnit test for a web service deployed to SOA-P.  Below is the working JUnit test:

       

      /* START JUNIT CODE */

      package edu.ohio.soa;


      import java.net.URL;
      import java.util.ArrayList;
      import java.util.List;


      import junit.framework.Assert;


      import org.jboss.soa.peoplesoft_services.GetStudentsService;
      import org.junit.Test;


      import edu.ohio.schema.person.PersonNameId;
      import edu.ohio.schema.studentgroupservice.GetStudentsReq;
      import edu.ohio.schema.studentgroupservice.GetStudentsRsp;
      import edu.ohio.schema.studentgroupservice.StudentInfo;


      public class ClientTest {


          @Test
          public void testClient() throws Exception {
             
              // Instantiate reference to service
              GetStudentsService service = new GetStudentsService(new URL("http://localhost:8180/student-group-service-1.0.0/ebws/peoplesoft-services/GetStudents?wsdl"));


              // Construct the service request
              GetStudentsReq req = new GetStudentsReq();
              List<String> sg = new ArrayList<String>();
              sg.add("CAP");
              sg.add("ARMY");
              req.setStudentGroup(sg);


              // Make the service call and store the response
              GetStudentsRsp rsp = service.getGetStudentsPortType().getStudentsOp(req);


              // Print out key data to verify the response
              for (StudentInfo i : rsp.getStudentInfo()) {
                  PersonNameId name = i.getStudentName();
                  System.out.println(name.getOuid() + " " + name.getFirstName() + " " + name.getLastName());
              }


              // Assertion that response was successfully returned
              Assert.assertTrue(rsp!=null);
             
          }
      }

      /* END JUNIT COE */

       

      I've packaged the code corresponding with this JUnit test into a JAR and put it in the JBoss AS deploy/default/lib folder and restarted AS.  I am wanting to consume the web service from ColdFusion 9 using the Java objects in the JAR file.  However, the last line of code in provided snippet produces an error:

       

      /* START CF CODE */

      <cfscript>
          serviceURL = CreateObject("java", "java.net.URL");
          serviceURL.init("http://localhost:8180/student-group-service-1.0.0/ebws/peoplesoft-services/GetStudents?wsdl");


          serviceRef = CreateObject("java", "org.jboss.soa.peoplesoft_services.GetStudentsService");
          serviceRef = serviceRef.init(serviceURL);
      </cfscript>

      /* END CF CODE */

       

      The produced error is:

      Object  instantiation exception.

      An exception occurred while  instantiating a Java object. The class must not be an interface or an  abstract class. Error: ''.

      The error occurred in C:\jboss\appservers\jboss-eap-5.0\jboss-as\server\default\deploy\cfusion.ear\cfusion.war\index.cfm:  line 71

      71 :      serviceRef = serviceRef.init(serviceURL);

      Something is going wrong when trying to use the non-default constructor in the GetStudentsService java object.  I've not been able to find any
      useful answer on message boards and this is really holding me up at this point.  Any help is appreciated.  Thanks!