You are on page 1of 22

Creating webservices

TEMENOS EDUCATION CENTRE


Warning: This document, is protected by copyright law and international treaties. No part of this document
may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose, without the express written permission of TEMENOS HEADQUARTERS SA Unauthorized
reproduction or distribution of this presentation or any portion of it, may result in severe civil and criminal
penalties, and will be prosecuted to the maximum extent possible under applicable law. Information in this
document is subject to change without notice

Objectives

At the end of this session you will be able to

Create simple webservices using Eclipse


Learn to call these webservices using some tools
Describe the SOAP and WSDL used in these webservices

Slide 2

Webservices

JAVA WEBSERVICE

Slide 3

Webservice Definition again


Formal Definition

A software system designed to support interoperable Machine to


Machine interaction over a network (W3C)
The term Web services describes a standardized way of integrating
Web-based applications using XML based open standards over an
Internet protocol backbone (from webopedia.com)
Services are what you connect together using Web Services
Web Services refers to the technologies that allow for making
connections

Prerequisites

For java webservices

eclipse
Jboss 4.2.3

Slide 5

Lets create a web service using Eclipse

Slide 6

Creating a web service

Slide 7

Sample Java Code

Slide 8

Creating a web service

Slide 9

Creating a web service

Slide 10

Creating a web service

Slide 11

Creating a web service

Slide 12

How to view the WSDL file

Slide 13

SOAPUI Demo

Slide 15

Sample SOAP request

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cal="http://Calculate">
<soapenv:Header/>
<soapenv:Body>
<cal:Add>
<cal:a>10</cal:a>
<cal:b>20</cal:b>
</cal:Add>
</soapenv:Body>
</soapenv:Envelope>

Slide 16

Sample SOAP response

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:AddResponse xmlns:ns="http://Calculate">
<ns:return>30</ns:return>
</ns:AddResponse>
</soapenv:Body>
</soapenv:Envelope>

Slide 17

SOAP fault

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>For input string: "1o"</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

Slide 18

HTTP Request
POST http://localhost:8080/Caculation/services/FirstService.FirstServiceHttpSoap11
Endpoint/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:Add"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8080
Content-Length: 322
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cal="http://Calculate">
<soapenv:Header/>
<soapenv:Body>
<cal:Add>
<cal:a>10</cal:a>
<cal:b>20</cal:b>
</cal:Add>
</soapenv:Body>
</soapenv:Envelope>

Slide 19

HTTP Response

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA
date=200807181417)/JBossWeb-2.0
Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 21 Apr 2011 06:09:34 GMT
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:AddResponse xmlns:ns="http://Calculate">
<ns:return>30</ns:return>
</ns:AddResponse>
</soapenv:Body>
</soapenv:Envelope>

Slide 20

SOAP Action
POST http://localhost:8080/Caculation/services/FirstService.FirstServiceHttpSoap11
Endpoint/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:Add"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8080
Content-Length: 322
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cal="http://Calculate">
<soapenv:Header/>
<soapenv:Body>
<cal:Add>
<cal:a>10</cal:a>
<cal:b>20</cal:b>
</cal:Add>
</soapenv:Body>
</soapenv:Envelope>

Slide 21

Quiz State True or False

WSDL format is platform specific


SOAP messages change completely depend on the transport used
Eclipse generates .svc files

Slide 22

Summary

You should be able to

Create simple webservices using Eclipse


Call these webservices using some tools
Describe the SOAP and WSDL used in these webservices

Slide 24

You might also like