Using X-UP Models in a Web Application (eGovFrame)

This chapter describes how to use an X-UP model in a web application by utilizing a model created in the section Model Development Using SAP RFC Invoke.

eGovFrame 2.6.0 was used as the basis for this chapter, and it was written with the assumption that the user is familiar with web application development.

The application development stages described in this chapter for an X-UP model that uses UX-Studio are as follows:

Web Application Creation

A web application is required to implement an X-UP model.

Go to [File > New eGovFrame Web Project] to create a project.

Enter a project name and click the [Next] button.

Generate the example using EgovSampleController.java.

This is a generated project.

Applying an X-UP Model to a Web Application

Apply an X-UP model in a web application in the following order:

Extract the contents of xup.war and copy the library in the xup/WEB-INF/lib folder to the generated project's src/main/webapp/WEB-INF/lib folder.

Copy the X-API user license file (XPLATFORM_Server_License.xml) to the lib folder.

Add the library files to the build path for use in a web application.

Copy the xup folder from the extracted xup.war file (xup/WEB-INF/xup) into the src/main/webapp/WEB-INF folder.

After the folder is copied, the project's generated directory structure and files appear as follows:

Copy the X-UP user license file (X-UP_Server_License.xml) to the src/main/webapp/WEB-INF/xup/conf folder.

To use all the features of X-UP, register the X-UP servlet in web.xml.

The servlet url-pattern is identical to the dispatcher-servlet url-pattern provided by eGovFrame, and therefore, it must be changed to [.xup].

Add the information in the web.xml file from xup.war file to the eGov web.xml file.

xup/WEB-INF/web.xml > src/main/webapp/WEB-INF/web.xml
<servlet>
	<servlet-name>action</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	<init-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/config/egovframework/springmvc/dispatcher-servlet.xml,/WEB-INF/config/egovframework/springmvc/urlfilename-servlet.xml
		</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
	<servlet-name>action</servlet-name>
	<url-pattern>*.do</url-pattern>
</servlet-mapping>

<servlet>
	<servlet-name>FrontControllerServlet</servlet-name>
	<servlet-class>com.tobesoft.xup.service.FrontControllerServlet</servlet-class>
	<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
	<servlet-name>FrontControllerServlet</servlet-name>
	<url-pattern>/FrontControllerServlet.xup</url-pattern>
</servlet-mapping>

To use the X-UP administrator functions, copy the xup_manage_ui folder and index.jsp file from xup.war to the WEB-INF folder.

The final file structure is as follows when completed:

Model Development Using SAP RFC Invoke

Please refer to the section Model Development Using SAP RFC Invoke for SAP RFC invoke development.

Model Export to a Web Application Server

This section describes how to export a developed model to a web application server.

Start the WAS, and then open X-UP Builder's mashup.msh file.

The default server URL is defined as follows under the Overview section in the mashup.msh file:

http://localhost:8080/xup/FrontControllerServlet.do

Change the server URL to the web module name of the WAS. (Also change the url-pattern.)

http://localhost:8080/connector/FrontControllerServlet.xup

Click [Deploy X-UP Model] after selecting the model.

Click the [Export * .jar in Local Directory] button on the Deploy Wizard to create a jar file.

Extract the generated .jar file and place it in the web application.

The target directory is as follows:

Place the file in the src/main/webapp/WEB-INF/xup/model folder.

Model Call in a Web Application

Create the following controller to call a model from a web application.

You can call a developed X-UP model using the following code:

package egovframework.rte.cmmn.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tobesoft.xplatform.data.PlatformData;
import com.tobesoft.xplatform.tx.HttpPlatformRequest;
import com.tobesoft.xplatform.tx.HttpPlatformResponse;
import com.tobesoft.xup.connector.XIConnector;
import com.tobesoft.xup.service.xi.XIServiceRequest;
import com.tobesoft.xup.service.xi.XIServiceResponse;

@Controller
public class XIServiceController {

    @RequestMapping(value="/xi/getFlightList.do")
    public String getFlightList(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // Generate HttpPlatformRequest using HttpServletRequest
        HttpPlatformRequest req = new HttpPlatformRequest(request);
        // XML data analysis
        req.receiveData();
        // Save data as PlatformData
        PlatformData platformData = req.getData();

        String domainName = "NexawebInc";
        String modelName = "INVOKE_SAP_RFC";
        
        // Generate XIConnector
        XIConnector connector = XIConnector.getConnector();
        // Generate request for transmitting to X-UP
        XIServiceRequest serviceRequest = connector.createXIRequest(domainName, modelName, platformData);

        XIServiceResponse serviceResponse = (XIServiceResponse)connector.execute(serviceRequest);
        PlatformData resultPlatformData = serviceResponse.getPlatformData();

        // Generate HttpPlatformRequest using HttpServletResponse
        HttpPlatformResponse res = new HttpPlatformResponse(response);
        res.setData(resultPlatformData);
        // Transmit data
        res.sendData();
        return null;
    }
}

Testing

Call a developed controller and verify that an X-UP model is successfully called.

The getStockList method's RequestMapping value is used to call the model.

The following URL can be used to verify the results from a browser.

http://localhost:8080/connector/xi/getFlightList.do

Target WAS server / Application context name / Request mapping

Verify the resulting data. (Sample)

Be sure to set the OS, JRE, and DLL to the same version (32-bit or 64-bit) if the following errors occur:

caused by java.lang.NoClassDefFoundError :

message=Could not initialize class com.sap.conn.jco.rt.JCoRuntimeFactory

-or- Error getting the version of the native layer:

java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path