Professional Documents
Culture Documents
1 2
3 4
1
API for XML processing JAXP API for XML Binding (JAXB)
We need to parse and transform XML: In Web Services, there is no standard binding
between data types in a language (e.g. Java) and
XML parsers with different interface levels:
XML Schema
SAX-event and DOM-tree levels
Best practices and guarantee for interoperability
Document Object Model (DOM) due to WS-Interoperability organization
implementation itself JAXB as used by default follows this recommendation
XSLT processing of XML translation Special closed world applications could benefit from
tailored mappings
JAXB additionally provides the framework to define
special mappings
7 8
API for XML-based RPC (JAX-RPC) SOAP with Attachments API (SAAJ)
Default serialization / deserialization of Java Used by JAX-RPC and using itself JAXP
data types Writing SOAP messages directly
Remote Procedure Call (RPC) to endpoint SOAP is a messaging and processing
addresses framework that goes beyond its use in Web
Support for WS-I Services.
Basic Profile 1.1
Attachment Profile 1.0
Simple SOAP Binding Profile 1.0
9 10
WSDL
registries.) Using Axis
SOAP
Java XML
XML
Libraries
Apache - Tomcat ( HTTP, FTP )
11 12
2
Simple Web Service
public class TestWS {
public String testMethod(String in){
WS-Security
return in + "?";
BPEL
}
UDDI
}
WSDL
Using / Axis
Implementing SOAP
Java XML XML
Libraries Apache - Tomcat ( HTTP, FTP )
13 14
% Got result : A test client ? Create a handle for the Gets SOAP request
server and a request object Possibly compiles/loads
Set target WS the requested WS class
Set parameter types and creates object of that
Set actual parameter class
Call Executes the method on
Serializes request to SOAP the actual parameters and
Deserializes the SOAP reply computes the result (if any)
to a Java object
Returns the SOAP reply
17 18
3
Java Web Services (JWS) SOAP Monitor
Pros: Cons: Allows you to check for SOAP messages
Simple to create No user defined exchanged between client and server
Simple to deploy binding of service Works like a proxy:
Simple to start with name and
implementation class Client calls localhost’s monitor with the SOAP
request
No WSDL
Hard to publish
Monitor displays the SOAP request and forwards
it to the actual server
Hard to administrate
No remote transparency SOAP reply gets displayed and forwarded to
client
19 20
Add monitor
21
New monitor …
Change Simple Web Client
import … Monitor
public class TestClient { address
public static void main(String [] args) throws Exception {
… waits for messages String endpoint =
"http://localhost:1234/axis/TestWS.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName("testMethod");
call.addParameter("in",
XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType( XMLType.XSD_STRING );
One could actually run several
String ret=(String) call.invoke(new Object[]{“test”});
monitors at the same time
System.out.println("Got result: " + ret);
}}
24
4
Re-compile and Re-start the Client
% javac –classpath "…" TestClient.java
Recent calls
% java –classpath "…" TestClient
SOAP reply
25
29 30
5
Deploying / Undeploying Another Web Service
package test;
% java -classpath "…" org.apache.axis.client.AdminClient
-h<host> public class TestWS2 {
-p<port>
private int count = 0;
-u<user>
-w<password public String testMethod(String in){
<deployment file>.wsdd return in + "(calls: " + count++ + ")";
}
% java -classpath "…" org.apache.axis.client.AdminClient }
-h
…
<undeployment file>.wsdd
31 32
6
Web Services Classes –
deployment using WSDD Remote transparency: WSDL
37 38
39 40
41 42
7
Web Service deployment Compile and Start the Client
% javac tutorial/ *.java % javac -classpath "…" GoogleClient.java
% java -classpath "…" % java -classpath "…" GoogleClient search WSCC
org.apache.axis.client.AdminClient
-hlocalhoset –p8180 –uUser –wPassword % Answer: …
tutorilal/deploy.wsdd [
% ftp <local>/tutorial/*.class URL = "http://
http://wscc
http://wscc.info/
wscc.info/"
.info/
Title = "This site was created using SiteDirect from Wipmind <b>...</b>"
<webapp>/WEB-INF/classes/tutorial/*.class
Snippet = "This site was created using SiteDirect from Wipmind
webbpublicering webdesign web<br> content management publiceringsverktyg wcm
e-handel e-business e-shop webshop <b>...</b> "
% deployGoogle.bat Directory Category = {SE="", FVN=""}
% ftp <local>/tutorial/*.class Directory Title = ""
<webapp>/WEB-INF/classes/tutorial/*.class Summary = ""
Cached Size = "2k"
Related information present = true
Host Name = ""
], …
43 44
Client Server WS WS
Interface Interface
Create a locator object Skeleton gets SOAP Implements Implements
Web Services –
Resources
generated using WSDL