24
SOA WITH C, C++, PHP … Supun Kamburugamuva [email protected]

WSO2 SOA with C and C++

  • Upload
    wso2

  • View
    2.177

  • Download
    4

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: WSO2 SOA with C and C++

SOA WITH C, C++, PHP …Supun [email protected]

Page 2: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Language of your choice

You must have Freedom to choose You must have Reasons to choose

Page 3: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Why C?

Most portable Less memory Faster Many interesting applications written in C

HTTPD Ruby MySQL PHP

Page 4: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Why C++?

Widely used (and some legacy) Financial, Banking, Telco, DBMS, Embedded

Performance, Flexibility, Control

Page 5: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Why PHP?

Installed on over 20 million websites 1 million web servers Easiest way to write services and clients

Page 6: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

SOA in a Heterogeneous World

Page 7: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Expectations

Tooling for WSDL Security Interoperability Binary attachments Reliability Support

Page 8: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

PHP Web Services Frameworks

Package Written in WSDL Security Attachments Reliability

PHP5 SOAP Ext C Partial N o N o N o

PHP Yes N o N o N o

SCA with PHP(IBM) PHP Yes N o N o N o

WSO2 WSF/PHP C Yes Yes Yes Yes

NuSOAP

Page 9: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Framework that improves PHP user’s ability to provide and consume Web services

Capable of dealing with secure and reliable messaging even with binary data, the only PHP software package to offer those features

The framework is inter-operable with non-PHP implementations, allowing it to be integrated with enterprise applications seamlessly

Page 10: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Page 11: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

PHP Example – Secure Service

1. function echoFunction($inMessage) {

2. $returnMessage = new WSMessage($inMessage->str);

3. return $returnMessage;

4. }

1. $pub_key = ws_get_cert_from_file("../keys/alice_cert.cert");

2. $pvt_key = ws_get_key_from_file("../keys/bob_key.pem");

1. $operations = array("echoString" => "echoFunction");

1. $sec_array = array("encrypt" => TRUE, "algorithmSuite" => "Basic256Rsa15",

2. "securityTokenReference" => "IssuerSerial");

1. $actions = array("http://php.axis2.org/samples/echoString" => "echoString");

1. $policy = new WSPolicy(array("security"=>$sec_array));

2. $sec_token = new WSSecurityToken(array("privateKey" => $pvt_key,

3. "receiverCertificate" =>$pub_key));

1. $service = new WSService(array("actions" => $actions,

2. "operations" => $operations,

3. "policy" => $policy, "securityToken" => $sec_token));

1. $service->reply();

Page 12: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

PHP Example – Secure Client

1. $rec_cert = ws_get_cert_from_file("../keys/bob_cert.cert");2. $pvt_key = ws_get_key_from_file("../keys/alice_key.pem");

1. $reqMessage = new WSMessage($reqPayloadString, array("to"=>2. "http://localhost/samples/security/encryption/encrypt_service.php",3. "action" => "http://php.axis2.org/samples/echoString"));

1. $sec_array = array("encrypt"=>TRUE, "algorithmSuite" => "Basic256Rsa15",2. "securityTokenReference" => "IssuerSerial");

1. $policy = new WSPolicy(array("security"=>$sec_array));2. $sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, 3. "receiverCertificate" => $rec_cert));

1. $client = new WSClient(array("useWSA" => TRUE, "policy" => $policy, 2. "securityToken" => $sec_token));

1. $resMessage = $client->request($reqMessage);

1. printf("Response = %s \n", $resMessage->str);

Page 13: WSO2 SOA with C and C++

SOA WorkshopSanta ClaraHow to adapt a C++ Application as

Web Services

Page 14: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

C/C++ Web Services Frameworks

Package WSDL Security Attachments Reliability

Partial N o Partial N o

Yes Partial Yes N o

WSO2 WSF/C Partial Yes Yes Yes

WSO2 WSF/C++ Partial Yes Yes Yes

HydraExpress

gSOAP

Page 15: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Designed for embedding within C or C++ software stacks to enable Web services

All-in-one solution for the building and deploying of Web services

Widest range of WS-* specifications implementations

WS-Addressing, WS-Policy, WS-Security, WS-SecurityPolicy, WS-Reliable Messaging, MTOM and WS-eventing

Page 16: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

C++ Example - Service1. #include <ServiceSkeleton.h>

1. using namespace wso2wsf;

1. class Echo: public ServiceSkeleton

2. {

3. public:

4. WSF_EXTERN WSF_CALL Echo(){};

1. OMElement* WSF_CALL invoke(OMElement *message, MessageContext *msgCtx);

1. OMElement* WSF_CALL onFault(OMElement *message);

1. void WSF_CALL init(){};

2. };

1. OMElement* Echo::invoke(OMElement *element, MessageContext *msgCtx)

2. {

3. OMElement *echoElement = new OMElement(element->getLocalname(),

4. new OMNamespace(element->getNamespace(false)->getURI(),

5. element->getNamespace(false)->getPrefix()));

6. OMElement *textElement = new OMElement("messsage");

7. echoElement->addChild(textElement);

8. textElement->setText("Hello World");

9. return echoElement;

10. }

Page 17: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

C++ Example - Client1. ServiceClient serviceClient(client_repo, end_point);

1. OMNamespace * ns = new OMNamespace("http://ws.apache.org/rampart/c/samples", "ns1");

2. OMElement * payload = new OMElement(NULL, "echoIn", ns);

3. OMElement * child = new OMElement(payload, "message", NULL);

4. child->setText("Hello Service!");

1. try

2. {

3. OMElement* response = serviceClient.request(payload,

4. "http://example.com/ws/2004/09/policy/Test/EchoRequest");

5. if (response)

6. {

7. cout << endl << "Response: " << response << endl;

8. }

9. }

10. catch (AxisFault & e)

11. {

12. if (serviceClient.getLastSOAPFault())

13. {

14. cout << endl << "Fault: " << serviceClient.getLastSOAPFault() << endl;

15. }

16. else

17. {

18. cout << endl << "Error: " << e << endl;

19. }

20. }

21. delete payload;

Page 18: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Web Services are Fast

Page 19: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Web Services are Faster

Page 20: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Web Services are Still Faster

For secure services 10K messages C implementation x10 – x15 times

faster than Java 100k messages C implementation x6 – x8 times faster

than Java

Page 21: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

WSF/C++ Features

SOAP 1.1 and SOAP 1.2 WS-Addressing

1.0

Submission

MTOM and SwA Support for caching large attachments

WS-Security Base security standards mean that messages can be protected using

Encryption, Authentication and Signature Including WS-SecureConversation and WS-Trust

WSDL2CPP Code Generation tool Supports generating client stubs, service skeletons, build scripts and

deployment scripts

Page 22: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

WSF/C++ Features

WS-Policy and WS-Security Policy Enables using industry standard XML to confgure security

SSL Enabled Transport Layer Reliable Messaging 1.0, 1.1 and WS-RMPolicy

Enables reliability between platforms including message resending, duplicate detection and persistence

Full REST support (GET, PUT, DELETE, POST) with custom URI Mapping

Enables mapping a REST API easily and naturally

Useful tools Tcpmon wsclient

Page 23: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

References

Various Web Services Frameworks http://wso2.org/projects/wsf

Apache Axis2/C Web Services Performance http://wso2.org/library/3532

Example applications for SOA http://incubator.apache.org/stonehenge/

PHP Web Services Blog http://phpwebservices.blogspot.com/

Page 24: WSO2 SOA with C and C++

SOA WorkshopSanta Clara

Thank You!

Q & A