MATLAB SERVER PAGES

thickbugΛογισμικό & κατασκευή λογ/κού

28 Οκτ 2013 (πριν από 3 χρόνια και 10 μήνες)

117 εμφανίσεις

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB

SERVER PAGES


Ali KIZIL, Istanbul 2005

MATLAB, Simulink & related products are registered trademarks of The MathWorks Inc,


which has no affiliation with the maintainer of this page and MATLAB Server Pages (MSP).


Mathematica and related products are registered trademarks of Wolfram Research Inc,

which has no affiliation with the maintainer of this slide show and MATLAB Server Pages (MSP).

http://sourceforge.net/projects/msp http://msp.sourceforge.net

What is MATLAB Server Pages?


MATLAB

Server

Pages

(MSP)

is

an

open

source
,

platform

independent,

technical

web

programming

language

using

MATLAB

in

background,

which

supports

3
-
Tier

Architecture

(Web

Tier



Business

Tier

and

Database

Tier)

including

Distributed

Computing

and

Parallel

Processing

via

remote

procedure

calls

and

web

services
.



Some

Features

of

MSP
:


MATLAB

Tag

Libraries
:

Develop
e

technical

web

pages

as

simple

as

using

HTML

Tags
.


MATLAB

RMI

Tag

Libraries
:

Use

a

remote

MATLAB

just

like

it

is

running

on

local
.


MSP

Expression

Language

Support
:

For

DB

Connectivity

and

Easy

Computing
.


MATLAB

Server

Faces
:

Advanced

Web

Components

such

as

Uploads

&

Validators
.


MATLAB

Beans
:

Handle

Business

Rules

and

Logics
.


MATLAB

Web

Service
:

Use

MATLAB

as

a

Web

Service
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Why do you need MSP?


Scenario


You

are

a

web

developer

or

an

application

engineer

for

an

IT

company
.

Your

manager

called

you

and

talked

about

a

customer

request
.

Customer

needs

a

web

portal

for

its

employees

to

let

them

to

analyze

financial

raw

data

and

make

some

advanced

financial

calculations
.

This

demand

is

urgent

for

customer
.



IT

company

may

only

use

trend

programming

languages,

for

example

Java

or

C#
.

But

it

may

take

several

months

to

develop,

test

and

deploy

the

portal
.

Furthermore,

this

IT

company

may

take

advices

from

financial

consultants

for

analysis

and

calculations,

so

they

may

need

a

large

workgroup

to

meet

customer

demand
.



In

the

other

hand,

they

can

use

a

technical

computing

application

to

interact

with

Java

or

C#
.

This

may

reduce

development

time

and

project

costs
.

Now

they

need

to

decide

what

they

can

use

in

background
.

After

a

short

research,

they

have

found

two

commercial

products

called

The

MathWorks

Inc
.

MATLAB
®

and

Wolfram

Research

Mathematica
®
.

Both

products

have

tools

for

several

technical

subjects

including

financial

calculations

topic
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Why do you need MSP?


Although

both

products

support

financial

analysis

and

calculations
.



They

both

have

some

disadvantages

for

the

project
.




At

first

glance,

MATLAB

has

a

user

friendly

syntax

for

application

development

and

several

useful

products
.

One

of

them

is

“MATLAB

Web

Server”,

which

is

a

CGI

gateway

application

that

executes

communication

between

HTTP

messages

and

MATLAB
.

When

the

developer

tried

the

demo,

he

found

that

creating

a

simple

application

(for

example
:

Taking

two

parameters

from

a

form

and

summing

them)

requires

at

least

3

code

pages
:

An

HTML

input

page,

an

output

page

and

a

M
-
File
.

Moreover,

MATLAB

Web

Server

has

no

ability

to

interact

with

another

programming

language

even

JavaScript

and

online

debugging

features
.

He

found

that

there

are

some

restrictions

too
.

He

can

not

use

some

MATLAB

products

with

MATLAB

Web

Server
.



Mathematica

also

has

several

products

for

advanced

calculations,

but

with

a

harder

syntax
.

Beside

syntax

and

as

an

advantage

towards

to

MATLAB,

Mathematica

has

MathLink

and

webMathematica

products

that

support

Java,

JSP

and

Web

Service

interactivity
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Why do you need MSP?


webMathematica

has

tag

libraries

to

use

Mathematica

in

JavaServer

Pages
.

It

is

possible

to

interact

with

JavaScripts
.

Mathematica

can

deploy

developed

application

as

Web

Services

too
.



MATLAB

has

weak

points

in

web

tier

and

has

no

direct

support

for

Java

or

C#
.

But,

it

includes

an

unmanaged

C

Engine

Library

to

invoke

MATLAB

and

get/set

data

from
/to

MATLAB
.

MATLAB

Server

Pages

targets

to

fill

this

gap
.

MATLAB

Server

Pages

communicates

with

MATLAB

using

its

C

Engine

Library

and

opens

the

doors

of

MATLAB

to

internet
.



For

the

given

scenario,

Mathematica

seems

as

a

good

candidate
.

However

MATLAB

has

a

larger

market

coverage

in

fields

of

Model

Based

Simulation,

Control

&

Command

Engineering

and

Financial

Engineering
*
.

Deloitte

&

Touché,

Ernst

&

Young,

J
.
P
.

Morgan,

Moody’s

and

Price

Waterhouse

Coopers

are

some

customers

of

The

MathWorks

Inc
.

in

financial

engineering

field
.



MSP

fills

the

gaps

of

MATLAB

for

the

mentioned

aspects
.

* Based on work experience.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

What is MATLAB?


In

short,

as

mentioned,

MATLAB

is

a

technical

language

of

computing
.




MATLAB,

short

for

"matrix

laboratory",

refers

to

both

the

numerical

computing

environment

and

to

its

core

programming

language
.

Created

by

The

MathWorks,

MATLAB

allows

easy

matrix

manipulation,

plotting

of

functions

and

data,

implementation

of

algorithms,

creation

of

user

interfaces,

and

interfacing

with

programs

in

other

languages
.




Although

it

specializes

in

numerical

computing,

optional

toolboxes

enlarges

its

usage

area
.

It

is

used

by

more

than

one

million

people

in

industry

and

academia

and

runs

on

most

modern

operating

systems,

including

Windows,

Mac

OS,

Linux

and

Unix
.




The

current

version

is

MATLAB

7
.
1

Service

Pack

3
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Overview of MATLAB

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Architecture

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP Engine Architecture

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP Client Architecture

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP 3
-
Tier Overview

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP Technologies


Technology

Description

Implementation

JavaServer Pages

JavaServer

Pages

(JSP)

technology

lets

you

rapidly

develop

and

easily

maintain,

information
-
rich,

dynamic

Web

pages
.

JSP

pages

contain

display

markup

and

tags

that

encapsulate

the

logic

for

generati ng

dynamic

content
.

JSP

technology

includes

some

standard

tags

and

support

for

creating

custom

tags
.

Custom Tag Library:


MATLAB Tag Library and
MATLAB RMI Tag Library

JSP Standard Tag Library

The

JavaServer

Pages

Standard

Tag

Library

(JSTL)

goes

beyond

the

JSP

standard

tags,

providing

custom

tags

that

encapsulate

core

functionality

common

to

many

Web

applications
.

JSTL

has

support

for

structural

tasks

such

as

iteration

and

conditionals,

tags

for

manipulating

XML

documents,

internationalization

tags,

SQL

tags,

and

commonly

used

functions
.


Support for;



Expression language,



Iterations,



Conditional,



SQL,



XML,



Formatting,

in MSP.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP Technologies


Technology

Description

Implementation

JavaServer Faces

JavaServer

Faces

or

JSF

simplify

the

development

of

user

i nterfaces

for

J
2
EE

applications

using

JavaServer

Pages
.

It

is

a

framework

for

building

user

interfaces

for

web

applications
.

It

includes
:




A

set

of

APIs

for

representi ng

UI

components

and

managing

their

state,

handli ng

events

and

input

validation,

defi ning

page

navigation,

and

supporti ng

internationalization

and

accessibility




A

JavaServer

Pages

(JSP)

custom

tag

library

for

expressing

a

JavaServer

Faces

interface

within

a

JSP

page
.


(MSP uses MyFaces from Apache
Software Foundation Group.)


Support for;




MATLAB Beans: To define
Business Logic and Business
Rules.



Advanced UI Components like
Upload Form, Validation etc.


in MSP.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP Technologies


Technology

Description

Implementation

Java DataBase Connectivity

Java

DataBase

Connectivity
.

JDBC

is

a

Java

API

that

enables

Java

programs

to

execute

SQL

statements
.

This

allows

Java

programs

to

i nteract

with

any

SQL
-
compliant

database
.

Since

nearly

all

relational

database

management

systems

(DBMSs)

support

SQL,

and

because

Java

itself

runs

on

most

platforms,

JDBC

makes

it

possible

to

write

a

single

database

application

that

can

run

on

different

platforms

and

interact

with

different

DBMSs
.

Work

with

JSTL

and

JDBC

Drivers

to

store

data

from

MATLAB

to

DB

and

retrieve

data

from

DB

to

MATLAB
.


Uses

JSTL

SQL

Tag

Library

and

MSP

Core

Package

“line”

to

process

requests
.

Remote Method Invocation

Java

Remote

Method

Invocation

(Java

RMI)

enables

the

programmer

to

create

distributed

Java

technology
-
based

to

Java

technology
-
based

applications,

in

which

the

methods

of

remote

Java

objects

can

be

invoked

from

other

Java

virtual

machines,

possibly

on

different

hosts
.

RMI

uses

object

serialization

to

marshal

and

unmarshal

parameters

and

does

not

truncate

types,

supporting

true

object
-
oriented

polymorphism
.


Custom Tag Library:


MATLAB RMI Tag Lib.


Enables

web

developers

to

develop

web

pages

using

a

remote

MATLAB

just

like

it

is

on

local
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP Technologies


Technology

Description

Implementation

Java 4 Web Services

Web

services

are

Web
-
based

enterprise

applications

that

use

open,

XML
-
based

standards

and

transport

protocols

to

exchange

data

with

calling

clients
.

Java

2

Platform,

Enterprise

Edition

(J
2
EE)

provides

the

APIs

and

tools

you

need

to

create

and

deploy

interoperable

Web

services

and

clients
.


The

Java

2

Platform,

Enterprise

Edition

platform

provides

the

APIs

and

tools

that

is

needed

to

quickly

design,

develop,

test,

and

deploy

Web

services

and

clients

that

fully

interoperate

with

other

Web

services

and

clients

running

on

any

platform
.

This

full

interoperability

is

possible

because

application

data

is

translated

"behind
-
the
-
scenes"

to

a

standardized

XML
-
based

data

stream
.


(MSP

uses

Axis

from

Apache

Software

Foundation

Group
.
)


MSP

uses

Java
2
WSDL

for

generating

of

MATLAB

Web

Services
.


MSP

supports

two

WSDLs

and

one

of

them

is

WS
-
I

Compatible
.


MSP

supports

BPEL
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Tag Library

Tag

Description

Parameters

Example

Clean

Deletes all MAT,
JPG and BMP
files.

<matlab:Clean/>

Command

MATLAB
Command
Interface

cmd: MATLAB Command

<matlab:Command
cmd="a=magic(10)"/>

Debug

Debugs MATLAB
Commands and
Tags

type: For Debugging M
-
File or MLSP:
Code, For Simulink: Model

<matlab:Debug type=“Code”>
<matlab:Command
cmd="a=magic10)"/>
</matlab:Debug>

Engine

Starts and Ends
MATLAB

<matlab:Engine>
<matlab:Command cmd="'Hello
World'"/> </matlab:Engine>


EvalMDL

Runs Simulink
Models


modelname: Simulink Model Name

laodname: If Simulink uses workspace
variables. Before using EvalMDL save
variables and load them from EvalMDL.
Save variables under Code Dir.

savename: Save Simulink variables to a
mat file. Load this file from Code dir

<matlab:EvalMDL
modelname="sim1"
loadname="sim1in"
savename="sim1out"/>

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Tag Library

Tag

Description

Parameters

Example

EvalMFile

Evaluates
MATLAB M
-
File

name: Name of M
-
File

<matlab:EvalMFile
name="mspmfile"/>
<matlab:EvalMFile name="s =
mspmfile([1 2 3]);"/>

EvalMLSF

Evaluates MLSF
files and writes
output.

input: MSP Input File (Bulk of
Commands)

output: MSP Output File (Variables to be
written on page)

<matlab:EvalMLSF input="input1"
output="output1"/>

GetArray

Gets MATLAB
2D Array

name: Name of MATLAB variable


Saves the MATLAB variable to goOnline
Java Class “array” variable.

<matlab:GetArray name="a"/>
goOnline goOnline =
(goOnline)pageContext.getAttribute
("goOnline");

double[][] a = goOnline.getArray();


or for ex:


<c:out
value="goOnline.array[0][0]"/>

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Tag Library

Tag

Description

Parameters

Example

GetVector

Gets MATLAB
1D Array

name: Name of MATLAB variable


Saves the MATLAB variable to
goOnline Java Class “vector” variable.


<matlab:GetVector name="b"/>
goOnline goOnline =
(goOnline)pageContext.getAttribute(
"goOnline");

double[] b = goOnline.getVector();

GetScalar

Gets MATLAB
Double

name: Name of MATLAB Variable


Saves the MATLAB variable to
goOnline Java Class “scalar” variable.

<matlab:GetScalar name="c"/>
goOnline goOnline =
(goOnline)pageContext.getAttribute(
"goOnline");

double c = goOnline.getScalar();

GetCharArray

Gets MATLAB
String Array

name: Name of MATLAB Variable


Saves the MATLAB variable to
goOnline Java Class “chararray”
variable.

matlab:GetVector name="d"/>
goOnline goOnline =
(goOnline)pageContext.getAttribute(
"goOnline");

String[] d = goOnline.getChararray();

You can use Expression Language in these tags as in GetArray.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Tag Library

Tag

Description

Parameters

Example

GetParam

Gets form text area
of form and
converts to MLSF.

parameter: Name of Text Area

Filename: Saving file name.

<matlab:GetParam
parameter=“textArea1"
filename="webin"/>

MultiCommand

Evaluates Multiple
MATLAB
Commands.

<matlab:MultiCommand>


a=magic(10);


b=a*rand(10);


c=det(b);

</matlab:MultiCommand>

PlotData

Plots MATLAB
Figures

cmd: Plotting Command

handle: Figure Handle

Filename: Saving name of figure

width: Image Width

height: Image Height

<matlab:PlotData
cmd="mesh(peaks)" handle="h1"
filename="test1“/>

PlotModel

Draws Simulink
Model

filename: Saving file name.

simname: Simulink Model name.

orientation: Orientation to draw.

<matlab:PlotModel
filename="draw1"
simname="sim1"/>


http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Tag Library

Tag

Description

Parameters

Example

PlotSim

Scopes Simulation
Result

handle: Figure Handle

filename: Saving file name

simresult: Simulation result
variable

height: Scope Height

width: Scope Width

<matlab:PlotSim filename="draw1"
handle="h1" simresult="simout1“/>

PutArray

Send Java 2D
Array to MATLAB

name: MATLAB variable name


double[][] array = {{1, 2, 3},{4, 5, 6}};

goOnline goOnline =
(goOnline)pageContext.getAttribute("g
oOnline");

goOnline.setArray(array);


<matlab:PutArray variable="Array"/>

PutVector

Send Java 1D
Array to MATLAB

name: MATLAB variable name

double[] vector = {
-
1, 0, 1};

goOnline goOnline =
(goOnline)pageContext.getAttribute("g
oOnline");

goOnline.setVector(vector);


<matlab:PutVector variable="Vector"/>

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Tag Library

Tag

Description

Parameters

Example

PutScalar

Send Java Double
to MATLAB

name: MATLAB variable
name

double[] scalar = 73;

goOnline goOnline =
(goOnline)pageContext.getAttribute("goO
nline");

goOnline.setScalar(scalar);


<matlab:PutScalar variable="Scalar"/>

SessionStart

Starts MATLAB as
Session

name: Session name

<matlab:SessionStart name="session1"/>

SessionGet

Connects to a
MATLAB Session

name: Session name

<matlab:SessionGet name="session1"/ >

SessionEnd

Ends MATLAB
Session

name: Session name

<matlab:SessionEnd name="session1"/>

Thumbnail

Thumbnails the
MATLAB Figure

imagename: Saved file
name

width: New width

height: New height


<matlab:PlotData cmd="mesh(peaks)"
handle="h1" filename="test1">
<matlab:Thumbnail imagename="test1"
width="600" height="600"/>
</matlab:PlotData>

WriteData

Writes MATLAB
Variable to Page

name: MATLAB variable
name

<matlab:WriteData name= " a " />

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB RMI Tag Library

Tag

Description

Parameters

Example

Clean

Deletes all MAT,
JPG and BMP
files.

<matlabRMI:Clean/>

Command

MATLAB
Command
Interface

cmd: MATLAB Command

<matlabRMI:Command
cmd="a=magic(10)"/>

Debug

Debugs MATLAB
Commands and
Tags

type: For Debugging M
-
File or MLSP:
Code, For Simulink: Model

<matlabRMI:Debug type=“Code”>
<matlabRMI:Command
cmd="a=magic10)"/>
</matlabRMI:Debug>

Engine

Starts and Ends
MATLAB

<matlab
RMI
:Engine>
<matlab
RMI
:Command cmd="'Hello
World'"/> </matlab
RMI
:Engine>


EvalMDL

Runs Simulink
Models


modelname: Simulink Model Name

laodname: If Simulink uses workspace
variables. Before using EvalMDL save
variables and load them from EvalMDL.
Save variables under Code Dir.

savename: Save Simulink variables to a
mat file. Load this file from Code dir

<matlabRMI:EvalMDL
modelname="sim1"
loadname="sim1in"
savename="sim1out"/>

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB RMI Tag Library

Tag

Description

Parameters

Example

EvalMFile

Evaluates
MATLAB M
-
File

name: Name of M
-
File

<matlabRMI:EvalMFile
name="mspmfile"/> <matlab:EvalMFile
name="s = mspmfile([1 2 3]);"/>

EvalMLSF

Evaluates MLSF
files and writes
output.

input: MSP Input File (Bulk of
Commands)

output: MSP Output File (Variables to
be written on page)

<matlabRMI:EvalMLSF input="input1"
output="output1"/>

GetArray

Gets MATLAB
2D Array

name: Name of MATLAB variable


Saves the MATLAB variable to
goOnline Java Class “array” variable.

<matlabRMI:GetArray name="a"/>
goOnlineClient goOnlineClient =
(goOnlineClient)pageContext.getAttrib
ute("goOnlineClient"); double[][] a =
goOnlineClient.getArray();


or


<c:out
value=“${goOnlineClient.array[0][0]}”/>

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB RMI Tag Library

Tag

Description

Parameters

Example

GetVector

Gets MATLAB
1D Array

name: Name of MATLAB variable


Saves the MATLAB variable to
goOnline Java Class “vector” variable.


<matlabRMI:GetVector name="b"/>
goOnlineClient goOnlineClient =
(goOnlineClient
)pageContext.getAttribute("
goOnlineClient "); double[] b =
goOnlineClient .getVector();

GetScalar

Gets MATLAB
Double

name: Name of MATLAB Variable


Saves the MATLAB variable to
goOnline Java Class “scalar” variable.

<matlabRMI:GetScalar name="c"/>
goOnlineClient goOnlineClient =
(goOnlineClient
)pageContext.getAttribute("
goOnlineClient "); double c =
goOnlineClient .getScalar();

GetCharArray

Gets MATLAB
String Array

name: Name of MATLAB Variable


Saves the MATLAB variable to
goOnline Java Class “chararray”
variable.

matlabRMI:GetVector name="d"/>
goOnlineClient goOnlineClient =
(goOnlineClient
)pageContext.getAttribute("
goOnlineClient "); String[] d =
goOnlineClient .getChararray();

You can use Expression Language in these tags as in GetArray.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB RMI Tag Library

Tag

Description

Parameters

Example

GetParam

Gets form text area
of form and
converts to MLSF.

parameter: Name of Text Area

Filename: Saving file name.

<matlabRMI:GetParam
parameter=“textArea1"
filename="webin"/>

MultiCommand

Evaluates Multiple
MATLAB
Commands.

<matlabRMI:MultiCommand>


a=magic(10);


b=a*rand(10);


c=det(b);

</matlabRMI:MultiCommand>

PlotData

Plots MATLAB
Figures

cmd: Plotting Command

handle: Figure Handle

Filename: Saving name of figure

width: Image Width

height: Image Height

<matlabRMI:PlotData
cmd="mesh(peaks)" handle="h1"
filename="test1“/>

PlotModel

Draws Simulink
Model

filename: Saving file name.

simname: Simulink Model name.

orientation: Orientation to draw.

<matlabRMI:PlotModel
filename="draw1"
simname="sim1"/>


http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB RMI Tag Library

Tag

Description

Parameters

Example

PlotSim

Scopes Simulation
Result

handle: Figure Handle

filename: Saving file
name

simresult: Simulation
result variable

height: Scope Height

width: Scope Width

<matlabRMI:PlotSim filename="draw1"
handle="h1" simresult="simout1“/>

PutArray

Send Java 2D
Array to MATLAB

name: MATLAB
variable name


double[][] array = {{1, 2, 3},{4, 5, 6}};

goOnlineClient goOnlineClient =
(goOnlineClient )pageContext.getAttribute("
goOnlineClient ");

goOnlineClient.setArray(array);


<matlabRMI:PutArray variable="Array"/>

PutVector

Send Java 1D
Array to MATLAB

name: MATLAB
variable name

double[] vector = {
-
1, 0, 1};

goOnlineClient goOnlineClient =
(goOnlineClient)pageContext.getAttribute("go
OnlineClient");

goOnlineClient.setVector(vector);


<matlabRMI:PutVector variable="Vector"/>

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB RMI Tag Library

Tag

Description

Parameters

Example

PutScalar

Send Java Double
to MATLAB

name: MATLAB variable
name

double[] scalar = 73;

goOnlineClient goOnlineClient =
(goOnlineClient)pageContext.getAttribute("
goOnlineClient");

goOnlineClient.setScalar(scalar);


<matlabRMI:PutScalar variable="Scalar"/>

SessionStart

Starts MATLAB as
Session

name: Session name

<matlabRMI:SessionStart
name="session1"/>

SessionGet

Connects to a
MATLAB Session

name: Session name

<matlabRMI:SessionGet name="session1"/
>

SessionEnd

Ends MATLAB
Session

name: Session name

<matlabRMI:SessionEnd
name="session1"/>

Thumbnail

Thumbnails the
MATLAB Figure

imagename: Saved file
name

width: New width

height: New height


<matlabRMI:PlotData cmd="mesh(peaks)"
handle="h1" filename="test1">
<matlab:Thumbnail imagename="test1"
width="600" height="600"/>
</matlabRMI:PlotData>

WriteData

Writes MATLAB
Variable to Page

name: MATLAB variable
name

<matlabRMI:WriteData name= " a " />

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MATLAB Web Service

Method

Description

Parameters

Example

engineOpen()

Starts MATLAB

matlabService.engineOpen()

engineClose()

Ends MATLAB

matlabService.engineClose()

eval()

Evaluates MATLAB
Command

Command as String

matlabService.eval(“a=3”)

getArray()


Gets MATLAB 2D
Array

MATLAB Variable Name as String

double[][] a = matlabService.getArray(“a”)

getVector()


Gets MATLAB 1D
Array

MATLAB Variable Name as String

double[] b = matlabService.getVector(“b”)

getScalar()


Gets MATLAB
Double

MATLAB Variable Name as String

double c = matlabService.getScalarf(“c”)

putArray()

Puts 2D Double
Array to MATLAB

MATLAB Variable Name as String and
Value as Array of Double Array

double[][] a = {{1,2},{3,4}}

matlabService.putArray(“a”,a)

putVector()

Puts 1D Double
Array to MATLAB

MATLAB Variable Name as String and
Value as Array of Double

double[] b = {1,2}

matlabService.putVector(“b”,b)

putScalar()

Puts Double to
MATLAB

MATLAB Variable Name as String and
Value as Double

double c = 1

matlabService.putScalar(“c”,c)

getImage()

Gets MATLAB Figure
as Base64 Encoded

Command as String, Width as String,
Height as String, Save Name as String

String Base64Image =
matlabService.getImage(“mesh(peaks)”,
“640”, “480”, “temp”)

http://sourceforge.net/projects/msp http://msp.sourceforge.net


A Simple Code: MSP Says Time

MATLAB

Server

Pages
:

HelloWorls
.
mlsp


<html>

<head>

<
%
@

include

file="/Scripts/header
.
inc"

%
>

<title>

Hello

World!

</title>

</head>


<body>


<h
1
>Hello

World</h
1
>


<matlab
:
Engine>


<p>Its

current

value

is
:
</p>


<matlab
:
Command

cmd="a=clock"/>


<matlab
:
WriteData

name="a"/>


</matlab
:
Engine>

</body>


</html>

webMathematica
:

HelloWorls
.
jsp


<html>


<head>


<title>Hello

World</title>


</head>



<body>


<h
1
>Hello

World</h
1
>


<msp
:
allocateKernel>



<p>Its

current

value

is
:
</p>



<msp
:
evaluate>



Date[]


</msp
:
evaluate>


</msp
:
allocateKernel>


</body>


</html>

http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP & MATLAB Equivalance Table
*

The MathWorks
Inc MATLAB
Toolbox

Description

Price
**

MSP Equivalent

MATLAB Web Server

The

MATLAB
®

Web

Server

enables

you

to

create

MATLAB

applications

that

use

the

capabilities

of

the

World

Wide

Web

to

send

data

to

MATLAB

for

computation

and

to

display

the

results

in

a

Web

browser
.

2000$

MATLAB Server Pages
Engine

MATLAB Database
Toolbox

The

Database

Toolbox

is

one

of

an

extensive

collection

of

toolboxes

for

use

with

MATLAB®
.

The

Database

Toolbox

enables

you

to

move

data

(both

importing

and

exporting)

between

MATLAB

and

popular

relational

databases
.

1000$

MSP and JSTL Connectivity

MATLAB Distributed
Computing Products

The

Distributed

Computing

Toolbox

and

the

MATLAB

Distributed

Computing

Engine

enable

you

to

coordinate

and

execute

independent

MATLAB

operations

simultaneously

on

a

cluster

of

computers,

speeding

up

execution

of

large

MATLAB

jobs
.

1900$

MSP Remote Procedure
Calls and Web Services

MATLAB Compiler

Compiles

MATLAB

M
-
Files

to

system

libraries

or

executable

files
.

5000$

Commonly used for System
Library (For ex: DLL)
generation, which will be
used in other applications.

* This is used for similarity. These toolboxes may still be needed. ** US


Individual Commercial Use / September

http://sourceforge.net/projects/msp http://msp.sourceforge.net

How to Call MATLAB & How MSP works?


There

are

three

ways

to

call

MATLAB
:

C

Engine

Library,

COM

and

Runtime

Invokes
.


It

is

possible

to

call

MATLAB

from

Java

and

C#
.


In

C#

using

DLLImports

enables

to

use

unmanaged

code

in

managed

code
.


Developing

a

wrapper

class

can

handle

communication

with

MATLAB
.

MATLAB

has

a

documentation

of

its

C

Engine

Library
.


But,

it

is

unusual,

it

is

not

seem

possible

to

use

this

wrapper

class

in

developing

Web

Service

applications
.

It

throws

an

“Unsupported

feature”

exception
.


In

Java
;


Java

Native

Interface

enable

to

use

C

Engine

Library
.

MSP

uses

this

method

with

a

Java

wrapper

class

developed

by

Stefan

Mueller

(
http
:
//sourceforge
.
net/projects/jmatlink
)
.

JMatLink

uses

C

Engine

Library

and

converts

some

of

its

features

to

a

Java

class
.


Using

COM

or

Runtime

Invokes

increases

the

time

and

limit

the

usage

areas
.

For

example

retrieving

a

200
x
200

dimensional

array

from

MATLAB

takes

30

ms

over

COM

and

902

ms

over

Runtime

Invoke

(Not

including

time

until

MATLAB

starts,

tested

by

using

tic



toc

MATLAB

commands)
.

Beside

it

is

10

ms

for

C

Engine

Lib

wrapper

class
.



(Ref
:

http
:
//www
.
codeproject
.
com



Article
:

1
.
2
.
3
..

Ways

to

integrate

MATLAB

with

.
NET)


Also

it

is

possible

to

call

compiled

MATLAB

M
-
Files

(DLLs)

from

any

application

or

C#/Java
.

But

this

forces

programmers

to

compile

each

needed

MATLAB

functions
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Methodology Used in Development of MSP


MATLAB

Server

Pages

is

a

green

field

project
.

This

project

targeted

to

co
n
vert

MATLAB

abilities

to

a

“Technical

Web

Programming

Language”
.

As

a

methodology

“Rapid

Development”

technique

is

chosen

to

handle

the

project,

because

there

is

no

other

work

to

inspire

from

and

it

is

a

must

to

measure

user

demands

needs

in

these

types

of

projects
.

MSP

takes

into

consideration

of

some

customer

compliments

about

MATLAB

Web

Server

product

to

not

to

make

same

mistakes
.




Before

release

of

MSP,

prototypes

of

MSP

are

created

and

is

distributed

over

open

source

community

spaces
.

User

opinions

are

added

to

project
.

This

development

methodology

handles

to

see

bugs

and

application

problems

in

development

state
.

So

it

is

much

easer

to

adobe

changes
.


http://sourceforge.net/projects/msp http://msp.sourceforge.net

MSP Installation Packages


There

are

several

packages

at

http
:
//sourceforge
.
net/projects/msp

for

MSP
.


All

in

One
:

32
-
bit

Windows

Installer

Includes

Tomcat

and

MATLAB

Server

Pages

Engine
.

End

user

only

has

to

edit

property

files
.


WAR

Archive
:

It

provides

setup

for

MATLAB

Server

Pages

to

other

J
2
EE

Container
.

For

ex
:

JBoss
.


Add

Ons
:

Samples

application

for

MATLAB

Server

Pages

Web

Service
:

MIDLET

Http

Connection

to

MSP,

MIDLET

Web

Service

Connection

to

MSP

Web

Service,

C#

Windows

Client

for

MSP

Web

Service,

C#

ASP
.
NET

Client

for

MSP

Web

Service,

C#

Smart

Application

for

MSP

Web

Service,

Excel



MSP

Web

Service

Connectivity
.


Tutorial
:

Online

Flash

based

video

tutorial

for

MATLAB

Server

Pages

(
http
:
//msp
.
sourceforge
.
net
)



http://sourceforge.net/projects/msp http://msp.sourceforge.net

The MathWorks Inc. License Agreement & MSP


Some

parts

of

Agreement

are
:


Provide

access

(directly

or

indirectly)

to

The

MathWorks

Inc
.

Programs

via

Web

or

Internet

Application,

or

any

file
-
sharing

method

or

system,

without

acquiring

an

express

license

from

MathWorks

to

do

so
.


The

licensed

programs

may

not

be

operated

from

within

a

Web

Application

without

acquiring

a

MATLAB

Web

Server

License

(From

Deployment

Addendum)
.



Users

have

to

take

attention

for

legal

issues

that

interests

them,

while

using

MSP
.

Such

as

Licensee

shall

not,

and

shall

not

permit

any

Third

Party

to

;


Create

a

server,

for

code

generation,

compilation,

or

other

The

MathWorks

Inc
.

programs
.


Access

or

use

The

MathWorks

Inc
.

programs

that

Licensee

is

not

currently

licensed

to

access

or

to

use
.


MATLAB Server Pages is designed for in company use, take attention to not to make
public services due to license agreements.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Upcoming Improvements


Providing
Report Generation

Mechanism
: PDF, Excel, HTML, Doc and PowerPoint Slides.


Providing a web based user interface, which seems like Excel, to make a more user
friendly environment.


Providing Add
-
Ons for BPEL based applications.


Arranging more secure RMI and Web Service features to MSP.


Adding audio and video multimedia support to MATLAB Tags.


Adding servlets for some figure operations like zooming an area in figure.


Adding an online MLSP editor.


Adding an Administrator console to set properties easily.


Adding Load Balance to MSP Systems.


Adding connection limits to MSP.


Fixing code in tag libs for user demands.


Fixing WS
-
I Compability issues for goOnlineDotNet.wsdl.


Fixing bugs found by users.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Frequently Asked Questions


May

I

use

MATLAB

Server

Pages

in

Linux

or

Solaris?


Check

Add

Ons

from

MSP

homepage
.

This

package

includes

make
-
files

for

these

OSs
.


Is

there

any

projects

like

MSP?


Stefan

Mueller

has

a

serv
l
et

tag

to

use

his

JMatLink

class

in

HTML

pages
.

It

has

limited

features
.


Also,

The

Ohio

State

University

has

a

project

called

“A

Java

Based

Web

Interface

to

MATLAB”
.

It

is

also

based

on

HTML

embedded

servlets
.

It

is

limited

to

Unix/Linux

platforms,

does

not

has

JavaScript

interactivity,

does

not

has

tag

libraries

for

rapid

development,

does

not

has

web

services,

has

a

harder

syntax

and

is

not

open

source
.


When

I

try

to

install

from

WAR

file,

I

can

not

run

MSP?


Please

deploy

JMatLink
.
dll

to

Windows

directory

from

MSP_Installation_Dir/JMatLink
.


Register

MATLAB

as

COM

Server
.


Add

MATLAB

Bin

directory

to

path
.


What

are

the

types

of

WSDLs?


goOnline
.
wsdl

is

Document/Literal

Wrapped

formatted,

goOnlineDotNet
.
wsdl

is

RPC/Encoded
.

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Challenges

in Development


JMatLink

is

only

usable,

when

it

is

not

in

a

package

format

for

JSP
.

The

reason

for

this

is

its

C

Code

among

the

Java

Native

Interface
.

This

situation

causes

Java

Server

Pages

ability

to

be

unusable

in

current

development

kits,

because

it

only

supports

“package”

hierarchies
.

To

avoid

this

paradox,

I

used

Java

Compiler

1
.
3

version
.

Javac

1
.
3

supports

“packageless”

forms

in

JSPs
.


Axis

Tomcat

add
-
in

needs

Java

Run

Time

1
.
4
.
x

to

run
.

Latest

versions

of

Tomcat

are

coming

JRE

1
.
5

compatible
.

To

run

Axis

web

services,

Tomcat

has

to

be

made

runnable

with

JRE

1
.
4
.
x
.

Tomcat

has

another

extension

called

“compat”

that

handles

Axis

and

Tomcat

functionalities

run

smoothly

together
.


J
2
ME

only

supports

HTTP

Connections

in

threats

to

avoid

deadlocks
.


Pocket

PC,

ASP
.
NET

and

Windows

Clients

for

MSP

Web

Services

have

a

common

WSDL

proxy

generation

bug
.

C#

does

not

understand

array

of

double

arrays
.

It

needs

manually

editing

from

reference

files
.


J
2
EE

Web

Services

using

keywords

of

C#

have

interoperability

problem

for

C#

in

proxy

class

generation
.

(For

ex
:

value)


ASF

MyFaces

does

not

run

on

Tomcat,

if

Sun’s

JSP

compiler

class

library

is

installed
.


Smart

Application

runs

only

with

IP

address

when

using

MSP

Web

Service
.


http://sourceforge.net/projects/msp http://msp.sourceforge.net

References


The

MathWorks

Inc
.

MATLAB

Documentations
.


Sun’s

Java

Developer

Forums


Sun

Java

Tutorials


Apache
.
org


JGuru
.
com


TheServerSide
.
com


CodeProject
.
com


Held
-
mueller
.
de/JMatLink


Sourceforge
.
net


IBM

Java

developersWork


Wolfram

Inc
.

Online

Tutorials


Codecomments
.
com


MSDN

Library


Experts
-
exchange
.
com


Techworld
.
com


Codezoo
.
com


Javaalmanac
.
com


C
-
sharpcorner
.
com


Dotnetforums
.
com


Oreilly

Network


Onjava
.
com


Javaranch
.
com

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Used Development & Tutorial Tools for MSP


Development

Tools


Eclipse

3
.
1

(Free

to

use)


Visual

Studio

.
NET

2003


Eclipse

WTP

0
.
7
R

(Free

to

use)


EclipseME

(Free

to

use)


Genady

RMI

(Free

to

use)


Sun

Wireless

Toolkit

Platform

(Free

to

use)


Tutorial

Tools


Microsoft

PowerPoint


Install

Creator

(Free

to

use)


Wink

(Free

to

use)

http://sourceforge.net/projects/msp http://msp.sourceforge.net

Questions?


E
-
mail
: alikizil@gmail.com