SOA with C, C++, PHP and more
-
Upload
wso2 -
Category
Technology
-
view
6.175 -
download
1
description
Transcript of SOA with C, C++, PHP and more
![Page 1: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/1.jpg)
SOA with C, C++, PHP …Samisa AbeysingheDirector, EngineeringWSO2, Inc
![Page 2: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/2.jpg)
SOA is about
Architectural Design
And
We need implementation techniques & tools to build it
![Page 3: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/3.jpg)
Language of your Choice
You should have freedom to chooseYou might also have reasons to choose
![Page 4: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/4.jpg)
Why C?
Because it is the most portable
And bunch of other reasonslike
Many interesting applications written in Chttpd, PHP, Ruby, MySQL
![Page 5: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/5.jpg)
Why C++?
Widely used (and some legacy)Financial, Banking, Telco, DBMS, Embedded
And like C it offers:Performance, Flexibility, Control
![Page 6: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/6.jpg)
Why PHP?
Installed on over 20 million websites and
1 million web servers
http://www.php.net/usage.php
![Page 7: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/7.jpg)
Chances
Your other application (legacy or green-field) can be C, C++, PHP or the like
Can we get them on the SOA?
![Page 8: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/8.jpg)
SOA in a Heterogeneous World
![Page 9: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/9.jpg)
Expectations
Tooling for WSDL Security
Interoperability
Binary AttachmentsReliability
![Page 10: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/10.jpg)
Interoperability - PHP
![Page 11: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/11.jpg)
PHP Web Services Frameworks
Package Written in WSDL Security Attachments Reliability
PHP5 SOAP Ext C Partial No No No
PHP Yes No No No
SCA with PHP(IBM) PHP Yes No No No
WSO2 WSF/PHP C Yes Yes Yes Yes
NuSOAP
![Page 12: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/12.jpg)
Framework that improves PHP user’s ability to provide and consume Web services
Capable of dealing with secure and relabel messaging even with binary data, the only PHP software package to
offer those features
The framework is inter-operable with non-PHP imple-mentations, allowing it to be integrated with enterprise
applications seamlessly
![Page 13: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/13.jpg)
![Page 14: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/14.jpg)
PHP Example – Secure Service
1. function echoFunction($inMessage) {2. $returnMessage = new WSMessage($inMessage->str);3. return $returnMessage;4. }5.6. $pub_key = ws_get_cert_from_file("../keys/alice_cert.cert");7. $pvt_key = ws_get_key_from_file("../keys/bob_key.pem");8.9. $operations = array("echoString" => "echoFunction");10.11. $sec_array = array("encrypt" => TRUE, "algorithmSuite" => "Basic256Rsa15",12. "securityTokenReference" => "IssuerSerial");13.14. $actions = array("http://php.axis2.org/samples/echoString" => "echoString");15.16. $policy = new WSPolicy(array("security"=>$sec_array));17. $sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, 18. "receiverCertificate" =>$pub_key));19.20. $service = new WSService(array("actions" => $actions, 21. "operations" => $operations, 22. "policy" => $policy, "securityToken" => $sec_token)); 23.24. $service->reply();
![Page 15: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/15.jpg)
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");3.4.$reqMessage = new WSMessage($reqPayloadString, array("to"=>5. "http://localhost/samples/security/encryption/encrypt_service.php",6. "action" => "http://php.axis2.org/samples/echoString"));7.8.$sec_array = array("encrypt"=>TRUE, "algorithmSuite" => "Basic256Rsa15",9. "securityTokenReference" => "IssuerSerial");10.11.$policy = new WSPolicy(array("security"=>$sec_array));12.$sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, 13. "receiverCertificate" => $rec_cert));14.15.$client = new WSClient(array("useWSA" => TRUE, "policy" => $policy, 16. "securityToken" => $sec_token));17.18.$resMessage = $client->request($reqMessage);19.20.printf("Response = %s \n", $resMessage->str);
![Page 16: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/16.jpg)
How to adapt a C++ Application as Web Services
![Page 17: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/17.jpg)
C/C++ Web Services Frame-works
Package WSDL Security Attachments Reliability
Partial No Partial No
Yes Partial Yes No
WSO2 WSF/C Partial Yes Yes Yes
WSO2 WSF/C++ Partial Yes Yes Yes
HydraExpress
gSOAP
![Page 18: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/18.jpg)
Designed for embedding within C or C++ soft-ware stacks to enable Web services
All-in-one solution for the building and deploy-ing of Web services
Widest range of WS-* specifications imple-mentations
WS-Addressing, WS-Policy, WS-Security, WS-SecurityPolicy, WS-Reliable Messaging, MTOM
and WS-eventing
![Page 19: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/19.jpg)
C++ Example - Service1.#include <ServiceSkeleton.h>2.3.using namespace wso2wsf;4.5.class Echo: public ServiceSkeleton 6.{7. public:8. WSF_EXTERN WSF_CALL Echo(){};9.10. OMElement* WSF_CALL invoke(OMElement *message, MessageContext *msgCtx);11.12. OMElement* WSF_CALL onFault(OMElement *message);13.14. void WSF_CALL init(){};15.};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 20: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/20.jpg)
C++ Example - Client1.ServiceClient serviceClient(client_repo, end_point);2.3.OMNamespace * ns = new OMNamespace("http://ws.apache.org/rampart/c/samples", "ns1");4.OMElement * payload = new OMElement(NULL, "echoIn", ns);5.OMElement * child = new OMElement(payload, "message", NULL);6.child->setText("Hello Service!");7.8.try9.{10. OMElement* response = serviceClient.request(payload, 11. "http://example.com/ws/2004/09/policy/Test/EchoRequest");12. if (response)13. {14. cout << endl << "Response: " << response << endl;15. }16.}17.catch (AxisFault & e)18.{19. if (serviceClient.getLastSOAPFault())20. {21. cout << endl << "Fault: " << serviceClient.getLastSOAPFault() << endl;22. }23. else24. {25. cout << endl << "Error: " << e << endl;26. }27.}28.delete payload;
![Page 21: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/21.jpg)
Web Services are Fast
![Page 22: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/22.jpg)
Web Services are Faster
![Page 23: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/23.jpg)
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 24: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/24.jpg)
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 25: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/25.jpg)
WSF/C++ Features WS-Policy and WS-Security Policy
Enables using industry standard XML to configure security
SSL Enabled Transport Layer WS-Reliable Messaging 1.0, 1.1 and WS-RMPolicy
Enables reliability between platforms including message resending, duplicate detec-tion 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 26: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/26.jpg)
ReferencesVarious Web Services Frameworks
http://wso2.org/projects/wsfSharePoint Web Services
http://msdn.microsoft.com/en-us/library/bb862916.aspxApache Axis2/C Web Services Performance
http://wso2.org/library/3532Example applications for SOA
http://incubator.apache.org/stonehenge/ PHP Web Services Blog
http://phpwebservices.blogspot.com/
![Page 27: SOA with C, C++, PHP and more](https://reader034.fdocuments.in/reader034/viewer/2022051816/546ea377b4af9fa5268b4756/html5/thumbnails/27.jpg)
Q & A