Monday, July 22, 2013

Java Web Service Tutorial (With SOAP UI)- Part 03

  In the last part (02) we saw about SOAP elements, SOAP Specifications and  SOAP Faults.
  Now we will see SOAP encoding : 

 - Soap includes a built in set of rules for encoding Data types. 
 - These data types can be float,integers,String,Arrays etc
        They are two SOAP Data types :  
        1. Scalar 2. Compound

  1. Scalar : Scalar types contains only one value such as "Last Name","Price" etc.

  2.Compound : Compound Types contains multiple values such as "Purchase of orders" ,"List of Stock  Quotes."Compound types are further subdivided into arrays and structs. Arrays contain multiple values,  each of which is specified by an ordinal position. Structs also contain multiple values, but each element is    specified by an accessors name.

-  The encoding style for a SOAP message is set via the SOAP-ENV:encodingStyle attribute.
-  To use SOAP 1.1 encoding, use the value
-  To use SOAP 1.2 encoding, use the value

Ex: Scalar Type

<?xml version='1.0' encoding='UTF-8'?>
<return xsi:type="xsd:double">54.99</return>


- The encoding Style Attribute is used to set the Encoding Style.
- Scalar types includes int,short,long,double,boolean,float,date,time etc.
- The SOAP specification provides several options for indicating the data type of a specific XML element.        The first option is to specify an xsi:type attribute for each element. The second option is to store data type      information within an external XML Schema or even within human-readable documentation.

Ex: Compound Type (Array)

Here is a sample SOAP response with an array of double values:

<?xml version='1.0' encoding='UTF-8'?>
xsi:type="ns2:Array" ns2:arrayType="xsd:double[2]">
<item xsi:type="xsd:double">54.99</item>
<item xsi:type="xsd:double">19.99</item>


Here , Array size is declared as 2, so two values has been send in the response for the Array.

Compound Type (Struct)

In contrast to arrays, structs contain multiple values, but each element is specified with a unique accessor element.
For example, consider an item within a product catalog. In this case, the struct might contain a product SKU, product name, description, and price. Here is how such a struct would be represented in a SOAP message:

<?xml version='1.0' encoding='UTF-8'?>
<return xmlns:ns2="urn:examples" xsi:type="ns2:product">
<name xsi:type="xsd:string">Red Hat Linux</name>
<price xsi:type="xsd:double">54.99</price>
<description xsi:type="xsd:string">
Red Hat Linux Operating System
<SKU xsi:type="xsd:string">A358185</SKU>


Each element in a struct is specified with a unique accessor name.
For example, the message above includes four accessor elements: name , price , description , and SKU. Each element can have its own data type; for example, name is specified as a string , whereas price is specified as a double.

Literal Encoding:

We are not required to use the SOAP encoding style. In fact,occasionally you may want to ignore the SOAP encoding rules completely and embed an entire XML document (or just a portion of the document) directly into your SOAP message.

Doing so is referred to as literal XML encoding, and it requires that you specify a literal XML encoding style. Within Apache SOAP, the literal XML style is specified with the namespace

For example, the following is a second option for encoding product information. Rather than encoding the product as a SOAP struct, the data is encoded as a literal XML document:

<?xml version='1.0' encoding='UTF-8'?>

<product sku="A358185">
<name>Red Hat Linux</name>
<description>Red Hat Linux Operating System</description>


So this ends the SOAP Part of Webservice, So far we have learnt about SOAP Specifications,SOAP   Messaging elements, SOAP Faults and SOAP Encoding.All these will help to understand the SOAP Request even without writing the code, and helps to write our own soap request and test it in the SOAP Tools. 

One of the major tool use for testing web service is "SoapUI". Now test a sample service withour SOAP knowledge in SOAP UI.For this we need to install SOAP UI Software.

Download SOAP UI from . It has "2" version pro version which is not a free ware and SOAP UI open source version which is a free ware ,You can download any one of these.

We are going to test the Sample Webservice provided by called "TempConversion" which has the below wsdl url .


This service accepts accept Celsius as "String" and returns the Fahrenheit as "String".If you hit the following URL in browser an XML document will be open which is called as "WSDL" document .Dont worry if you dont understand we will discuss WSDL in our next post in detail.

After installation Open the SOAP UI :

1. Create New SoapUI Project by right clicking on the Project Node:

2. Copy the WSDL URL and paste in the Initial WSDL/WADL Text Box , and the Project Name will automatically show up and click "ok" button.

3. Now Double click on the "Request Node" Inside the "CelciusTo Fahrenheit " Node.A request window will be open with default Soap Request.

Request :

<soapenv:Envelope xmlns:soapenv="" xmlns:tem="">
<tem:Celsius>122</tem:Celsius> <!-- Change the "? " to 122 in the Request -->

Mention a String value in the Celsius Tag and click the Run Button , You can see the Response in the Right Side.


<soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd="">
<CelsiusToFahrenheitResponse xmlns="">

If we  see the Request we can see the Envelope,Header,Body with Method and Parameters is present which we discuss in earlier parts, So now we can easily understand any SOAP Request now.

In this way , we can test our web service without writing client code, In the next post we will discuss about WSDL and it's contents.

<< Previous                                 Index                                   Next>>                

Please comment your thoughts...

Technology Blogs



  1. Good Tutorial...

  2. This comment has been removed by the author.

  3. Easy to follow...

  4. Hi,The publishing and transaction environments that sit behind the site are sympathetic in Web Design Cochin to the needs of the business management processes as well as the needs of those who must support and maintain the site.Thanks............


  5. Hurrah, that?s what I was looking for, what a information! present here at this weblog, thanks admin of this web page. by ACC 290 Final Exam

  6. I must thank you for the efforts you have put in writing this website.
    I'm hoping to see the same high-grade content by you in the future as well.

    In truth, your creative writing abilities has encouraged
    me to get my very own website now ;)

    Also visit my blog ... New Balance Store

  7. Admiring the time and effort you put into your website
    and in depth information you present. It's nice to come across a blog every once in a while
    that isn't the same outdated rehashed information. Fantastic read!
    I've bookmarked your site and I'm adding your RSS feeds to my Google

    Also visit my weblog ... Dr Dre Beats Tour

  8. Good way of explaining, and good article to obtain information about my presentation focus, which i am going to
    present in academy.

    Here is my webpage ... Cheap Dr Dre Beats

  9. We are a group of volunteers and starting a brand new scheme in our community.
    Your site provided us with helpful information to work on. You've performed an impressive job and our whole community will be thankful to you.

    Feel free to surf to my webpage - Beats Monster

  10. My spouse and I stumbled over here from a different web address
    and thought I might as well check things out. I
    like what I see so i am just following you. Look forward to
    looking into your web page for a second time.

    My web site: Christian Louboutin Boots

  11. This is my first time go to see at here and i am really impressed to read everthing at
    single place.

    My web page Christian Louboutin Pumps

  12. Heya i am for the first time here. I found this board and I
    find It really useful & it helped me out much.
    I hope to give something back and help others like you
    aided me.

    my web blog - Monster Beats

  13. I blog frequently and I truly appreciate your information. Your
    article has truly peaked my interest. I am going to take a note of your site and keep checking for new information about once per week.

    I opted in for your RSS feed as well.

    Look at my site - Running Shoes

  14. Right here is the right webpage for anyone who hopes to find out about this topic.
    You understand so much its almost hard to argue with you (not that
    I really will need to…HaHa). You definitely put a fresh spin on a subject which
    has been discussed for ages. Excellent stuff, just wonderful!

    my blog; Louis Vuitton Outlet UK

  15. I think this is among the most important info for me.
    And i'm glad reading your article. But want to remark on few general
    things, The web site style is wonderful, the articles is really nice : D.
    Good job, cheers

    my website ... Louis Vuitton Sale

  16. May I simply say what a comfort to find a person that
    genuinely knows what they are discussing over the internet.
    You actually know how to bring a problem to light and make
    it important. More and more people must look at this and understand this side of your
    story. It's surprising you are not more popular given that you most certainly have the gift.

    Look at my homepage: Cheap Louis Vuitton

  17. I'd like to thank you for the efforts you have
    put in writing this site. I really hope to view the same high-grade blog posts from you later
    on as well. In fact, your creative writing abilities has motivated me to get my own blog now ;)

    Also visit my web site Louis Vuitton Outlet []

  18. Hey There. I discovered your blog using msn. That
    is a very smartly written article. I'll make sure to bookmark it and come back to learn more of your helpful info.
    Thanks for the post. I'll definitely return.

    my web page :: Discount Christian Louboutin

  19. Incredible points. Solid arguments. Keep up the great effort.

    my web site Louis Vuitton Online

  20. Hey there! I'm at work browsing your blog from my new iphone 3gs!
    Just wanted to say I love reading your blog and look forward
    to all your posts! Keep up the outstanding work!

    Look into my homepage: Cheap Christian Louboutin

  21. This article provides clear idea in favor of the new people
    of blogging, that really how to do blogging.

    my web page :: Christian Louboutin

  22. I hardly create comments, but i did a few searching and wound up here "Java Web Service Tutorial (With SOAP UI)- Part 03".
    And I do have a couple of questions for you if it's allright.
    Could it be simply me or does it look as if like some of these responses
    look like they are coming from brain dead people?
    :-P And, if you are writing at other online social sites,
    I would like to follow everything fresh you have
    to post. Could you list of every one of all your shared pages like your twitter feed, Facebook page or
    linkedin profile?

    My site ... Running Shoes


  23. wow....Thanks for sharing this great source full of SOAP UI related posts.realy great work onece again thanks me and leadonlinetraining.

  24. Thanks for sharing these information. It’s a very nice topic. We are providing online training classes soapuionlinetraining

  25. hi,we provide online training & video tutorial for soapui
    for free videos refer

  26. Thank for sharing this useful information;
    It is very useful to me and who are wanted to learn or update their knowledge on SOAP UI through SOAP UI online training or offline training.