★ wanayoo — archive 1999 http://java.webdeveloper.com/tutorials/SOAP/index2.htmlNouvelle recherche | Portail wanayoo
Computer Digital Expo

The Event for Search Engine Marketing & Optimization


Find a Web Host With:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
Internet News
Internet Investing
IT
Windows Technology
Linux/Open Source
Developer
Interactive Marketing
xSP Resources
Small Business
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers
Be a Commerce Partner
Conference Calling
Build an Online Store
Promote Your Website
IT Training
Find a Web Host
Breathing Problems?
Web Hosting
Internet Jobs
Compare Prices & Shop
Track Defects Online
FlashKit
Gif.com
HierMenusCentral
JavaBoutique
JavaScript.com
JavaScriptSource
WebDev Jobs
JustSMIL
ScriptSearch
StreamingMediaWorld
Web Hosts
WebDevelopersJournal WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com
CGI
HTML
Java
JavaScript
Web Design and Promotion
Web Site Development
E-mail Address:


Can you receive
HTML e-mail?

Yes   No

Zip Code:


Tutorials : Using SOAP with Java :

by Samudra Gupta

Using SOAP with Java -Part 2

Welcome back to part two of the series. Hope you had a nice coding time and had no major problem in deploying your first SOAP application. If you had one, it is most likely a classpath related problem and you yourself could solve it. One of the easiest ways of solving these problems is to explicitly specify the required .jar files to the java runtime.

Anyway, it is time to explore SOAP in a greater detail; after all life is not always as simple as passing String data-types to the SOAP services. Often the world is much more complex with applications exchanging user-defined data-types. The major issue in handling these complex data-types in the SOAP context is to define a Serialization and Deserialization mechanism for them. The Apache SOAP API defines and implements a couple of default Serializers/Deserializers for primitive data types and Java Beans and it is also possible to create our own custom Serializers and Deserializers. In this installment, we will discuss issues related with the Serialization and Deserialization and will develop a Java Bean based SOAP application. Before we venture to do that, we need to understand the Serialization mechanism behind the SOAP implementations.

Serialization/Deserialization protocol in SOAP

First let us define the term Serialization and Deserialization in SOAP context. Serialization is a process of converting objects to the XML instance and Deserialization is the process of constructing objects out of the XML instance. In the context of a SOAP Remote Procedure Call, which we are developing throughout this series, there are two types of data exchange taking place.

  • The parameters to the SOAP Remote method.
  • The response from the SOAP remote service.

The exchange of data usually takes place using a methodology for transforming object graphs to XML, named as Section 5 encoding. All major SOAP implementations available today use this encoding scheme internally. Consider the following complex data type:

class Person
{
     String name;
     nt age;
}

and also consider a SOAP remote service accepting a Person data-type as a parameter:


class Aservice
{
   public String acceptPerson(Person p)
   {
       //do something here
       return “a string”;
    }
 }

If we invoke this remote method named acceptPerson as a part of the remote service Aservice, then the corresponsing SOAP representation of the RPC will look like:

<SOAP-ENV:Body>
  <ns1:accptPerson xmlns:ns1=”urn:the urn of the service” 
  SOAP-ENV:encodingStyle = “http://schemas.xmlsoap.org/soap/encoding/”>
      <serviceParam xmlns:ns2=”some uri” xsi:type=”ns2:Person”>
          <age xsi:type=” xsd:int”>22</age>
          <name xsi:type=xsd:string”>Samudra</name>
      </serviceParam>
    </ns1:acceptPerson>
 </SOAP-ENV:Body>

The above SOAP XML instance is a representation of a RPC call that dispatches the method call acceptPerson with a Person object as a parameter. The elements serviceParam, name, age are called accessors and they are the container of the values. The xsi:type attributes define the exact data-types of the elements. The SOAP provider and the client normally agree in advance on the data-types of parameters of each RPC but this exact specification becomes useful in a case where the service uses a generalised data-type which can potentially represent two or more data-types. Consider a case that a method accepts a java.lang.Object as a parameter. The Object might be an Integer or a String or anything else. In this case, the xsd:type attribute will strictly indicate the data-type to be used. The accessors with explicit xsd:type attribute are known as polymorphic accessors. The Apache SOAP serialization mechanism uses polymorphic accessors.

Simple data-types in SOAP

The Apache SOAP implementation supports most of the simple data-types except char. But it is a trivial task to implement a Serializer for the same. The list of the all supported simple types can be found within the Apache SOAP API documentation but for a handy note, the following table illustrates a few of them.

Data type SOAP type Serializer/Deserializer
String xsd:string StringSerializer
Integer xsd: int IntObjectSerializer
int xsd:int IntSerializer
---xxx--- --xxx--- ---xxxx-----
QName xsd:Qname QNameSerializer

If you have been tempted to overlook the table, you might have missed one or two important points. First of all, it is worth noticing that the primitive types and their wrapper(s) both are handled with a separate Serializer class but they are represented as the same data-type in the SOAP XML instance. Second, there is a rather curious data-type QName. This is a data-type designed to represent the user-defined compound data-types.

Compound types

A compound data-type is a type with constituent elements, which are either pure objects with one or more properties or a data structure. The Apache SOAP implementation supports the following Java based compound types:

Data type SOAP type Serializer/Deserializer
Array SOAP-ENC: Array ArraySerializer
Vector, Enumeration{http://xml.apache.org/xml-soap}Vector VectorSerializer
Hashtable{http://xml.apache.org/xml-soap}Map HashtableSerializer
Map{http://xml.apache.org/xml-soap}Map MapSerializer
Java Bean User-defined Qname BeanSerializer

As you can see from the above table that arbitrary Java bean classes which are compound data-types can be serialized with a BeanSerializer provided by the Apache SOAP, but to do that the compound data-type that you are using must follow the java bean specification which we will discuss in the relevant section.


Applet Index
(sorted alphabetically)

A B C D E F G H I J K
L M N O P Q R S T U
V W X Y Z #s
The Java Source
(applets w/source code)

A B C D E F G H I J K
L M N O P Q R S T U
V W X Y Z

How to Add Java Applets to Your Site

New on the Java Boutique:

New Article:
J2EE Deployment Specification
Why is it that J2EE applications written in the same language, Java, may not coexist on different servers? While the answer isn't simple Sun has set out to alleviate these problems with the "J2EE Deployment Specification".
... [more articles]

New Tutorial:
Designing Packages for Stability
Are your designs stable? This month Samudra will focus on the change impact relationship involved in designing classes showing us how to take them into account when designing the package relationship.
... [more Tutorials]

Year in Review:
The Best of 2002
The year 2002 saw 201 new applets posted to JavaBoutique. Check out the 2 most popular apps from each month of 2002!
... [popular applets]

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

internet.com logo


Developer News

Deadline Looms for IBM's AIX

HP, Dell Pledge Java Support

Putting Java in ONE Cup



Database Journal Launched!
Jupiter Media has announced the launch of Database Journal. DBJ offers SQL courses and other database related resources for beginner to expert developers.



PhotoMap
PhotoMap is made of many pictures and links. You can travel in "photo map world" where you have never visit yet.
Download of the Week
BSCOutline v5.10
BSCOutline Java Outline Applet is a customizable tree view control for use in Web pages, similar to that used by Windows File Manager or Explorer. BSCOutline has been written to be the simple to use and small to store.

JB User Poll
How does .NET fit into your programming?
The JavaBoutique Top 15:
1. Webmatic
2. ChompText
3. PingPong
4. DJPopMenu
5. RushHour
6. Distorter
7. NavBar
8. 3DMaze
9. AScroll2
10. Nibbly
11. AnimLetters_anim
12. Encyclo
13. BMMenu
14. BMI
15. Viewer
Want more? Check out our Top 100!

Refer-It
Affiliate Program and Referral Directory.
New on internet.com
HP, Dell Pledge Java Support
Despite Microsoft's decision to drop Java from the Windows OS, HP and Dell say they will continue to ship the runtime environment as part of their OEM agreements.

Case Study: Tradeshop.com
This online jewelry craftsman focuses on one-on-one customer service, using an old-fashioned small business approach to create e-commerce success.

Information Technology in Context
Nicholas Carr's article in the Harvard Business Review has stirred up a firestorm of controversy about the relevance of IT to business strategy. Columnist George Spafford says before people completely discard what Carr has to say, there are some issues to take into account.


Reports on security issues of ecommerce environments

Jupitermedia Corp. is publisher of the internet.com and EarthWeb networks.
Copyright 2003 Jupitermedia Corporation All Rights Reserved.

Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.
http://www.internet.com/
http://www.earthweb.com/