Web Services in Practice - Ver1
Web Services in Practice - Ver1
Web Services in Practice - Ver1
1
Table of Contents
2
I. Developing and Using a Web Service
Open Microsoft Visual Studio .NET from start Menu to open the Start page of Microsoft
Development Environment
3
Click on New Project button on the start page to open New Project Dialog Box
Select Visual Basic Projects in the Project Types tree list and ASP.Net web service in the
Templates list box in the New Project Dialog box. Then give the location of the web
service to be created in the Location field. By default the location field points to local
host for the service to be created i.e., http://localhost/servicename where servicename
the virtual directory where service has to be created
4
Click on OK button to create a new solution that includes all files required to develop a
web service.
Right Click service1.asmx file and select view code from context menu to write the code
for operations in the code window
5
To write a single function(web service operation), prefix the function name with the
<webmethod()>
Now write code for 4 functions that accepts 2 numbers as input and does the addition,
subtraction, multiplication and division respectively. Below is the code for respective
functions
<WebMethod()> Public Function Add(ByVal FirstNum As Integer, ByVal SecondNum As Integer) As Integer
Dim out As Integer
out = FirstNum + SecondNum
Return (out)
End Function
<WebMethod()> Public Function Subtract(ByVal FirstNum As Integer, ByVal SecondNum As Integer) As Integer
Dim out As Integer
6
Now Build the solution by right clicking the solution explorer and selecting Build item
from context menu
Now execute the solution by pressing F5 and observe that a web page is opened with all
the operations
7
Now click on Muliplication hyperlink in the opened web page
A new page opens to accept parameters to perform Multiplication operation
8
Observe that a new page is opened with result of multiplication of 2 numbers provided
in the input in the xml format
9
Now the next part of the web service is to make it consumable by any of the client
application. We'll use the windows application as a client to access the service we
developed
To develop new windows application, right click the solution in the Solution Explorer and
add new project
10
When New Project dialog box opens, select Visual Basic Projects in the project types tree
list and windows application in the Templates list box.. Give the name for windows
application(WS_Client) and then click on OK button
11
Observe that a form is created
Create 2 text boxes to accept inputs and corresponding labels to describe those text
boxes and 4 buttons to invoke the respective operations of the web service and exit
button to close the application
12
Now right click the windows application in the Solution explorer and select Add Web
Reference item
13
Now click on Add Reference button and observe that a reference from web service has
been added to the windows application in the solution explorer
14
Now double click the windows application form to enter code window to write code to
call functions in the web service. When code window opens write the below code
MsgBox(ws.Add(TextBox1.Text, TextBox2.Text))
End Sub
End Sub
Now build the windows application and set the windows application as a start up project
by right clicking the windows application and selection set as startup project item
15
Now execute the solution by pressing F5 and observe windows application opens
To call web service operation, give the First Number and Second Number in the
available text boxes and click on any of the operation buttons
(Add/Subtract/Multiply/Divide) .
Then web service operation returns the value which the client application catches and
displays result in the message box
Locate the free web service available online by searching in the google
Here is one free web service that is available online . This service converts the text from
one language to another language like English to German, English to French.. This web
16
service accepts 2 input parameters, one for language string and another for Language
Mode.
Now go to Visual Studio and create one windows application to call this freely available
web service
17
Click on OK button in the New Project dialog box that creates a new windows application
Design the form to have one combo box that lists all language conversion modes and
one text box to accept the input string and a button to invoke the web service. Also fill
the Language Conversion combo box with the below language conversion modes
EnglishTOChinese
EnglishTOFrench
EnglishTOGerman
EnglishTOItalian
EnglishTOJapanese
EnglishTOKorean
EnglishTOPortuguese
EnglishTOSpanish
EnglishToRussian
EnglishToDutch
18
Now go to solution explorer, right click windows application and select Add web
reference item from the context menu to add reference to our free web service from
windows application
19
Now give the URL of free web service in the URL text box available in the Add Web
Reference dialog box and click on Go button
20
If service is found at the given URL then the page in the dialog box turns below
indicating the service is available
21
Now click on Add Reference button add web service reference from windows application.
Once the reference has been added, solution explorer will be updated to indicate the
service has been added
22
Now double click the form in the windows application to open code view and write the
below code to invoke the web service
MsgBox(ws.Translate(i, Trim(RichTextBox1.Text)))
End If
23
End Sub
Once the form is displayed , select the language conversion mode and enter the input
string to be converted
Then click on the Call Web Service button and observe the response from the web
service in the msgbox
24
III. Case Study on Web Service(SendLoanFile web service)
This StatusMart 3.0 Web Service is designed to provide remote communication between
StatusMart system and client applications such as NexOS, ADVANTedge, Edge etc
This SendLoanFile web method in the SendLoanFile web service is intended for loan
origination systems (such as EDGE, ADVANTedge, and NexOS) to submit loan information to
Status Mart for storage. Successful completion of this web method indicates the loan
information submission request has been queued for processing into Status Mart.
The web method accepts an optional reference ID parameter from the client application.
When the web method completes successfully, a status value “0” is returned. If a reference ID
was not provided, a reference ID will be returned as part of the SendLoanFileResponseEntity
object. The reference ID supplied by the client application or generated by Status Mart can be
utilized by the client application to check the processing status of the request.
When the web method completes with an error condition, a SOAP exception will be returned.
1 SendLoanFile
[SoapHeader(REQUEST_HEADER, Direction=SoapHeaderDirection.In)]
[SoapHeader(RESPONSE_HEADER, Direction=SoapHeaderDirection.Out)]
// some code
25
Entry Entry Name Type IsRequired Description
Category
ype
SourceSystem sourceSystemD string Optional Source system date time
tTm
SourceSystem sourceSystemN string Optional Machine that generates XML file
ame
XMLGenerator generatorName string Optional XML Generator module name
XMLGenerator generatorVersi string Optional XML Generator Rel.Ver.BuildNum
on
XMLGenerator generatorMilise string Optional Time in milliseconds that took XML
c Generator to generate XML file
StatusMartEve timeZone string Mandatory Time zone of the source system
ntDetail
StatusMartEve abbreviatedXM string Mandatory Flag to indicate is XML abbreviated.
ntDetail L abbreviatedXML = “N”
StatusMartEve currBrNum string Optional Branch number that sending events to
ntDetail StatusMart
StatusMartEve currBrSatNum string Optional Branch satellite number that sending
ntDetail events to StatusMart
StatusMartEve eventDtTm string Mandatory Event date time
nt
StatusMartEve eventType string Mandatory Event type. Please see Appendix D for all
nt event types
StatusMartEve preappNum string Optional Loan pre-application number
nt
StatusMartEve loanAcctNum string Optional Loan account number
nt
StatusMartEve chlUserNum string Mandatory User number of the user who created
nt event
StatusMartEve EditRights string Optional Flag that indicates if branch that sending
nt events has edit rights on the loan data
LoanFile LoanFile string Mandatory StatusMart subset of loan file XML data.
Please see Appendix A for details.
Atlas SOAP networkUserId string Mandatory Network user id of the caller. It is used
Header for logging and audit purpose.
Atlas SOAP generatorName string Mandatory Name of the program which generated
Header request/response message.
Atlas SOAP generatorVersi string Mandatory Version of the program which generated
Header on request/response message
Atlas SOAP moduleName string Mandatory Module name of the program which
Header generated request/response message
26
Entry Entry Name Type IsRequired Description
Category
Atlas SOAP systemType string Mandatory Details of the source system that owns
Header the request data
Atlas SOAP systemName string Mandatory Details of the source system that owns
Header the request data
Atlas SOAP systemDtTm string Mandatory Details of the source system that owns
Header the request data
Atlas SOAP regionNum string Optional Region number of the service requestor
Header
Atlas SOAP branchNum string Optional Branch number of the service requestor
Header
Atlas SOAP satelliteNum string Optional Satellite number of the service requestor
Header
Atlas SOAP orgUnitNum string Optional OrgUnit number of the service requestor
Header
Atlas SOAP businessSource string Optional Business sources number of the service
Header Num requestor
27
<UnderwritingCondition xsi:nil="true" />
</UnderwritingConditionCol>
</Loanfile>
</StatusMartEventRQ>
</sendLoanFileMessageIn>
</soap:Body>
</soap:Envelope>
28
Entry Entry Name Type IsRequired Description
Category
Header request/response message.
Atlas SOAP generatorVersion string Mandatory Version of the program which generated
Header request/response message
Atlas SOAP moduleName string Mandatory Module name of the program which generated
Header request/response message
Atlas SOAP systemType string Mandatory Details of the source system that owns the request
Header data
Atlas SOAP systemName string Mandatory Details of the source system that owns the request
Header data
Atlas SOAP systemDtTm string Mandatory Details of the source system that owns the request
Header data
Atlas SOAP statusCode int Mandatory Web method will return “0” to the client application
Header to indicate successful execution; “false” or SOAP
exception will indicate failure during web method
execution.
Scalability requirements
In peak market conditions, NexOS will send the following number of events to Status Mart:
29
CMD events per day: 500,000
CMD events per hour: 50,000
WLD events per day: 314,000
WLD events per hour: 31,400
FSL events per day: 163,000
FSL events per hour: 16,300
The service is designed with 24/7 availability in mind and is targeted towards 99.999%
availability.
Below is the page containing all web services provided by StatusMart including SendLoanFile
web service
30
If we want to access WSDL file of all StatusMart web services, then we have to just suffix
?WSDL to the StatusMart web services URL which then becomes
http://atlasnetqa/StatusMartWS/StatusMartWS.asmx?WSDL
Below is the web page of the WSDL file of the Statusmart web services
31
Steps to test SendLoanFile web service
32
Observe that it has URL combo box to accept URL of the web service and also Soap
Action combo box to accept the method to be called . It also has text area to provide
input data for the web service(In this case, a loan file xml data appended by SOAP
header, SOAP Envelope and SOAP body)
Also we have Start Run button to call the SendLoanFile web method.
When we click Start Run button, SendLoanFile method will be called and location of the
output xml file will be put in the Soap Response Text Area
33
Note : The tool, currently is throwing error related to the location of the output file. So, we will
put the soap output screenshots aftersome time
34