17
INFSO-RI-508833 Enabling Grids for E- sciencE www.eu-egee.org C/C++ source code generation for EMS-WS Author Anton Gusev Location Russia, Protvino, IHEP

INFSO-RI-508833 Enabling Grids for E-sciencE C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

Embed Size (px)

Citation preview

Page 1: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

INFSO-RI-508833

Enabling Grids for E-sciencE

www.eu-egee.org

C/C++ source code generation for EMS-WSAuthor Anton Gusev

Location Russia, Protvino, IHEP

Page 2: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

2

Enabling Grids for E-sciencE

INFSO-RI-508833

Objectives

• Web services overview

• EMS WS architecture

• SOAP/XML Web services in C/C++

• C++ source code building for EMS WS client

• gSOAP means

Page 3: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

3

Enabling Grids for E-sciencE

INFSO-RI-508833

Web service definition

• Definition: – A Web service is a software system identified by a URI, whose

public interfaces and bindings are defined and described using XML. Its definition can be discovered by other software systems. These systems may then interact with the Web service in a manner prescribed by its definition, using XML based messages conveyed by Internet protocols.

Page 4: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

4

Enabling Grids for E-sciencE

INFSO-RI-508833

WS means

• What is WS?– Application which allows remote procedure call over LAN/WAN

– WS is a messaging program system, messages are XML-based

• Why WS?– Business

WS-es are public, therefore business-partners may involve/export they business-process

Easy money of WS using and deployment

– Using WS-es are platform independent Most popular transport protocols support (TCP/IP, HTTP, SMTP,...) Most popular program language support (Java, Python, C/C++, C#,

Perl ant others) Succession of exist information systems Simple object access

Page 5: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

5

Enabling Grids for E-sciencE

INFSO-RI-508833

WS stack

Application

rpcrouter

SOAP

HTTP

TCP/IP

Infrastructure(Data link)

Application (servlet)

Web server

SOAP

HTTP

TCP/IP

Infrastructure(Data link)

• WS stack

SOAP

XMLenvelope

HTTP

Page 6: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

6

Enabling Grids for E-sciencE

INFSO-RI-508833

EMS architecture

• EMS – events producer is any PC

• Applications – app(1) are any programs which produce log file(s) and some

other system valuable information

– app(2) are produce system events in EMS event formate (EF)

– app(3) are convert log files of app(1) to EF

– app(2) and app(3) application provide EMS-events for EMS-WS

– EMS-events is XML document, SOAP enveloped.

app (2)app (1)

app (3)log files producer

rpcrouter SOAP

XML

envelope

HTTP

network

Page 7: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

7

Enabling Grids for E-sciencE

INFSO-RI-508833

EMS architecture

• relations between EMS producer and EMS-WS

EMS server

WEB-serverWEB-server

web-service EMS

• WEB server– includes EMS web service, which holds list of EMS-events in

RAM

– EMS-ws receives events from producers and sends events to clients by requests

app (2)app (1)

app (3)log files

HTML{SOAP

XML[]}

network

producer 1 producer N

Page 8: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

8

Enabling Grids for E-sciencE

INFSO-RI-508833

EMS server

WEB-server

web-service EMS

EMS architecture

• EMS architecture

app (2)app (1)

app (3)log files

producer 1

app consoleUI

listener 1 listener2

app DB

...listener j

app GUI

Request (Expat expression)

Response(set of EMS-events,

xml-string)

producer 2…

producer N

Page 9: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

9

Enabling Grids for E-sciencE

INFSO-RI-508833

C/C++ Web services clients

• SOAP/XML Web services clients in C/C++– What You Need

WSDL file • Generate by some SOAP tool

• Obtain from WS-provider SOAP engine installed

• Will translate wsdl file to c++ sources

• Provide SOAP-libraries for c++ C++ compiler installed

• For build WS-client application

WSDL SOAP Engine

WSDL WSDL C++C++

SOAP Engine

WSDL WSDL C++C++ C++

Client stub

XML

HC++

User code

XML

H

libslibsUser’s project

C++

compiler

Executable filesExecutable files

Page 10: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

10

Enabling Grids for E-sciencE

INFSO-RI-508833

Source code creation

• C++ source code building for EMS WS client (1)– EMS-WS WSDL file is available on

http://140.109.98.130/axis/services/urn:EMS?wsdl

– Assumes gSOAP use as SOAP engine Use gcc as c++ compiler RH-Linux as OS

– Command line issue// 1. prepare directory for c++ project $mkdir csources

// 2. download wsdl $wget http://140.109.98.130/axis/services/urn:EMS?wsdl

Page 11: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

11

Enabling Grids for E-sciencE

INFSO-RI-508833

Source code building

• C++ source code building for EMS WS client (2)– Command line issue

// 3. Generate h-file of WS $wget 'http://140.109.98.130/axis/services/urn%3AEMS?wsdl‘ //4. Readable name for file $mv urn\:EMS\?wsdl EMS.wsdl

//5. Obtain a header file from a WSDL document .

The gSOAP 'wsdl2h' WSDL parser tool converts the WSDL $wsdl2h -o ems.h EMS.wsdl

//6. The 'soapcpp2' compiler generates the skeleton routines and a WSDL description of the service

$soapcpp2 -I ../gsoap-2.7/soapcpp2/ ems.h

Page 12: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

12

Enabling Grids for E-sciencE

INFSO-RI-508833

C++ source code

• C++ source code building for EMS WS client (3)– Create the main.cpp file, which contents

#include <string> #include <iostream>

#include "soapEMSdemoPortSoapBindingProxy.h" #include "EMSdemoPortSoapBinding.nsmap“

using namespace std;

Page 13: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

13

Enabling Grids for E-sciencE

INFSO-RI-508833

C++ source code

• C++ source code building for EMS WS client (4)– the main.cpp file content(2)

int main(int argc, const char *argv[])

{

int gSOAP_result

= SOAP_EOM;

string str_gSOAP_result

= "";

ns1__getLatestEventResponse

ltstEvRs;

EMSdemoPortSoapBinding

*EMS;

Page 14: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

14

Enabling Grids for E-sciencE

INFSO-RI-508833

C++ source code

• C++ source code building for EMS WS client (5)– the main.cpp file content(3)

EMS = new EMSdemoPortSoapBinding();

EMS->endpoint = "http://140.109.98.130:80/axis/services/urn:EMS";

EMS->soap->proxy_host= "proxy.ihep.su";

EMS->soap->proxy_port= 3128

gSOAP_result =

EMS->ns1__getLatestEvent( ltstEvRs );

str_gSOAP_result= (gSOAP_result == SOAP_OK)? "Yes ": "No";

Page 15: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

15

Enabling Grids for E-sciencE

INFSO-RI-508833

C++ source code

• C++ source code building for EMS WS client (6)– main.cpp file content(4)

cout <<"\n Use endpoin:\t"

<< EMS->endpoint<< "\n Use proxy:\t"

<< EMS->soap->proxy_host << ":"

<< EMS->soap->proxy_port

<<"\n EMS->ns1__getLatestEvent( ltstEvRs ) responce:\n"

<< ltstEvRs.getLatestEventReturn

<<"\n SOAP_OK - "

<< str_gSOAP_result

<<"("

<< gSOAP_result

<<")\n";

Page 16: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

16

Enabling Grids for E-sciencE

INFSO-RI-508833

C++ source code

• C++ source code building for EMS WS client (7)– main.cpp file content(5)

if( EMS->soap->error ){ const char **s; if (!*soap_faultcode( EMS->soap )) soap_set_fault(EMS->soap);

cerr << (*soap_faultcode(EMS->soap))<< "\n" << (*soap_faultstring(EMS->soap))<< "\n" ; s = soap_faultdetail( EMS->soap ); if (s && *s)

cerr << "Detail: "<<(*s)<<"\n"; }

return 0;}; // end of main function

Page 17: INFSO-RI-508833 Enabling Grids for E-sciencE  C/C++ source code generation for EMS-WS AuthorAnton Gusev LocationRussia, Protvino, IHEP

17

Enabling Grids for E-sciencE

INFSO-RI-508833

Source code building

• C++ source code building for EMS WS client (8)– Command line issue

// 3. Compile c++ project $g++ -o emsclient main.cpp soapC.cpp soapClient.cpp -lgsoap

//4. try launch executable file emsclient $./emsclient

//5. issue example Use endpoin: http://140.109.98.130:80/axis/services/urn:EMS Use proxy: proxy.ihep.su:3128 EMS->ns1__getLatestEvent( ltstEvRs ) responce:<event><id>draco.ihep.su/1103785831/0</id><time>1103785831</

time><type>activate</type><category>___</category><severity>10</severity><priority>10</priority><producer><netname>draco.ihep.su</netname><appname>emsclient</appname><sign>agusev</sign></producer><subject><netname>___</netname><service>___</service></subject><message><code>OO</code><body>___</body><help>___</help></message></event>

SOAP_OK - Yes (0)