Accessing and Deploying Web Services

computerharpySoftware and s/w Development

Dec 2, 2013 (3 years and 6 months ago)

46 views

Accessing and Deploying
Web Services

Purpose: To build distributed
Internet and Intranet applications
using standards that allow other
applications to share your data and
other resources.

Access and Deploying Web
Services Presentation



Synergy 2000


Copyright Sept. 2000, Data Access
Worldwide


Warning: The information described in
the following document describes
development of a research project that
may change before it becomes a product.

Web Protocols


Transport


FTP


HTTP


SMTP

Web Protocols
-

Data


XML

Important Distributed
Programming Protocols


COM


Component Object Model


CORBA


Common Object Request Broker
Architecture


Java Remote Method Invocation RMI


XML RPC


Barebones spec for XML HTTP
transfer


SOAP


Simple Object Access Protocol

SOAP


Simple Object Access Protocol 5/8/2000


SOAP is a lightweight protocol for exchange of
information in a decentralized, distributed
environment.


Passes the arguments and metadata in XML.


Vendor Support: MS, IBM, Sun, Apache


http://www.w3.org/TR/SOAP/


Supports all web transmission protocols


Simple Object Access Protocol (SOAP) 1.1 in
development

SOAP Packet Architecture


It is an XML based protocol that consists
of three parts: an envelope that defines a
framework for describing what is in a
message and how to process it, a set of
encoding rules for expressing instances
of application
-
defined data types, and a
convention for representing remote
procedure calls and responses.

What SOAP Packets Describe


The SOAP envelope construct defines an overall
framework for expressing
what

is in a message;
who

should deal with it, and
whether

it is optional
or mandatory.


The SOAP encoding rules defines a serialization
mechanism that can be used to exchange
instances of application
-
defined data types.


The SOAP RPC representation defines a
convention that can be used to represent remote
procedure calls and responses.

Example of Request Packet


POST /StockQuote HTTP/1.1

Host: www.stockquoteserver.com

Content
-
Type: text/xml; charset="utf
-
8"

Content
-
Length: nnnn

SOAPAction: "Some
-
URI"


<SOAP
-
ENV:Envelope


xmlns:SOAP
-
ENV="http://schemas.xmlsoap.org/soap/envelope/"


SOAP
-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">


<SOAP
-
ENV:Body>


<m:GetLastTradePrice xmlns:m="Some
-
URI">


<symbol>DIS</symbol>


</m:GetLastTradePrice>


</SOAP
-
ENV:Body>

</SOAP
-
ENV:Envelope>

Example of Response Packet


HTTP/1.1 200 OK

Content
-
Type: text/xml; charset="utf
-
8"

Content
-
Length: nnnn


<SOAP
-
ENV:Envelope


xmlns:SOAP
-
ENV="http://schemas.xmlsoap.org/soap/envelope/"


SOAP
-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding
/"/>


<SOAP
-
ENV:Body>


<m:GetLastTradePriceResponse xmlns:m="Some
-
URI">


<Price>34.5</Price>


</m:GetLastTradePriceResponse>


</SOAP
-
ENV:Body>

</SOAP
-
ENV:Envelope>

Client Server Architecture


Diagram that shows SOAP client server
invocation.


When SOAP uses HTTP wire transfer
protocol, it can leap across firewalls,
because the port it uses is the same port
your web server expects to receive
browser requests.

SOAP Client


Class
Hierarchy


cSoapPackager.


cWireTransfer


cServiceDescriptor


cSDMethodInfo


cSDEndPointInfo


cSDParameterInfo

cSoapPackager


F
unction SOAP_LoadServicesDescription
Loads a
service descriptor language file into an object.


Function
SOAP_IsMethodAvailable

Allows you to
determine whether a method is available at a
remote site.


Function SOAP_MethodStruct


Allows you to
query for metadata of a method.




More cSoapPackager


Set SOAP_PayloadData


Prepares the
method

element of a SOAP <body> for
call/return.


Set SOAP_Payload


Prepares Soap
Envelope for call/retrun.


Function SOAP_Payload


returns the
current contents of the SOAP_Payload


Even More cSoapPackager



Set SOAP_Parameter

-

Sets the
parameter or a return value of a method
to a value.


Function
SOAP_Parameter


Gets the
value of a parameter or (in a response
object) the return value of a method
invocation.



cWireTransfer


SOAP_PostDataToURI

-

Sends a request
packet to a URI


Procedure
SOAP_AddStdSoapHeaders


Sets common values (the URI, the
method name, and the length of the
request/response packet)



Simple Method Invocation


Get SOAP_LoadServicesDescription


Get SOAP_MethodStruct


Set SOAP_PayloadData

for icRequest


Set Parameter Values (by name) using Set
SOAP_Parameter


Get SOAP_Payload of Request


Send SOAP_AddStdSoapHeaders


Invoke Get Soap_PostDataToUri


Set SOAP_Payload of Response


Get SOAP_Parameter

SOAP Client


External Calls


SOAP_FUNCTION ArticlePrice

“GetArticlePrice" ;

"http://192.168.1.2/soapsample/services.xm
l";

icURI;

"http://192.168.1.2/soapsample/services.as
p";

String "articleId" RETURNS string
"price“


Move (ArticlePrice(sArticleId)) to sPrice


ASP File

<%@ Language=VBScript %>

<%


OPTION EXPLICIT


Response.Expires = 0


CONST SOAP_SDLURI =
"http://192.168.1.2/soapsample/services.xml" 'URI of SDL
file

%>

<!
--
#include file="listener.asp"
--
>

<%


Function GetArticlePrice(articleId)
GetArticlePrice=oarticles.Call("get_ArticlePrice",articleId)


End Function

%>

Web App Server
-
NT

Object o
A
rticles is a cWebBusinessProcess


Function ArticlePrice Integer articleId Returns Number


Clear Articles


Move articleId to Articles.Article_Id


Find Eq Articles By Index.1


Function_Return Articles.Price


End_Function



Send RegisterInterface get_ArticlePrice "get_ArticlePrice" "articleId" "Returns
price"


End_Object // o
A
rticles

The Glue
-

SDL File


Describes methods that can be invoked
for a given service.


Describes request and response packets.


Describes parameter order


Defines schemas and namespaces


The WebApp Server for Linux


Linux 2.x (e.g. Redhat)


Any web server (e.g. Apache)


JDK (e.g. Blackdown)


Java Servlet Engine (e.g. Tomcat)


Web App Server

Web App Server Environments

Win32

Linux

Robustness

Good

Very good

Management of System
Resources

Fair

Very good

Platform Web Server
Independence

No

Yes

ComponentizedLoad
Balancing

No

Yes

Proprietary Implementation

Yes

No

Contrasting ASP & JSP

ASP

JSP

Reusable Components

Yes

Yes

Runs on Unix/Linux

No

Yes

Runs on Windows

Yes

Yes

Independent Web Server
Platform

No

Yes

Open Development

No

Yes

Customizable Tags

No

Yes

Java Servlet & Java Server Pages



Servlets are java programs that are invoked by a
web server. They have a simple interface, because
they have no UI.


The server initializes itself with the init method.


The main behavior of the servlet is to respond to a
connection at the server, which invokes the
service method.


The service method takes 2 parameters,
ServletRequest and ServletResponse.


The servlet is not protocol
-
specific.


The Java Server Page engine is a special servlet
that processes (and compiles if necessary) JSPs.



A Simple Servlet

public class SimpleServlet extends HTTPServlet {


public void init() {}


public void service(HttpServletRequest req,
HttpServletResponse res) {


try {


ServletOutputStream out = resp.getOutputStream();


resp.setContentType(“text/html”);


resp.setStatus(HttpServletResponse, SC_OK);


out.println(“<html><head><title>Simple
Servlet</title></head>”);


etc


}

}

Apache SOAP Implementation


You register a SOAP service using a tool provided
by Apache. The name of the java object, the
methods you may invoke, and its class (along
with other features) are entered.


When a POST
-
ed envelope is receive the
arguments are unpacked and a call object is
created.


The method is then invoked.


The return value is then packed into a HTTP
response and sent to the caller.


Java link to Web App

public class Articles extends WebAppSoapBridge

{


public Articles() {


super("SoapSample","oArticles");


}


public String getQuantityOnHand(String sArticleID)

{


if

(!setupConnection())





return null;


String retVal=call("get_QuantityOnHand", sArticleID);


releaseConnection();


return retVal;


}

}


Web App Service

Object oArticles is a cWebBusinessProcess


Function QuantityOnHand String articleId Returns String


Clear Articles


Move articleId to Articles.Article_Id


Find Eq Articles By Index.1


Function_Return Articles.QTY


End_Function // RunCustomerReport



Send RegisterInterface get_QuantityOnHand "get_QuantityOnHand"
""

"Returns QOH"

End_Object


Demonstration


1. Show VB app and VDF app clients.


2. Show Web App services on NT


3. Show Web App services on Linux.


4. Bring it all together.


5. Use char mode Unix program to change
price on Linux box.


6. Show that the change is reflected.

Bibliography


http://java.sun.com/products/servlet/

-

Defines
the Java Servlet Specification


http://java.sun.com/products/jsp/

-

Defines the
Java Server Pages Specification


http://jakarta.apache.org/faq/faqindex.html

-

Great links to FAQs for related technologies


http://xml.apache.org/soap/


www.developer.com


www.msdn.microsoft.com


www.alphaworks.ibm.com

Product Implications


Chip will discuss our SOAP initiative and
what the consequences and ramifications
are for our customers.

Q & A


This is your chance to ask us any
technical questions about what you have
seen.