Force.com Integration Using Web Services With .NET & PHP Apps

34
Integrations using Web Services Examples with .NET & PHP Martin Haagen, QlikTech, Systems Manager; CRM @sehaagen

description

Web Services streamline integration projects when using the Force.com platform with other languages and frameworks. Join us as we demonstrate, through hands-on code examples, some best practices around integration, discuss issues around security, and learn how to consume Web Services from Force.com .Net & PHP projects. We'll cover how to build the receiving Web Service and how to drive outbound Web Service calls from triggers, Visualforce pages, and workflows.

Transcript of Force.com Integration Using Web Services With .NET & PHP Apps

Page 1: Force.com Integration Using Web Services With .NET & PHP Apps

Integrations using Web ServicesExamples with .NET & PHP

Martin Haagen, QlikTech, Systems Manager; CRM@sehaagen

Page 2: Force.com Integration Using Web Services With .NET & PHP Apps

Safe HarborSafe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Page 3: Force.com Integration Using Web Services With .NET & PHP Apps

Martin HaagenSystems Manager; CRM@sehaagen

Page 4: Force.com Integration Using Web Services With .NET & PHP Apps

IntroductionMartin Haagen, QlikTech

Page 5: Force.com Integration Using Web Services With .NET & PHP Apps

What We Solved With Web Service integrationsSSO solution

▪ Expectations• Smooth and seem less experience for users• Minimize data maintenance for internal staff

▪ Authentication schemes: SAML, form posts, token based▪ Automatic mappings to company for new customer / partner▪ Easy user management for internal staff

Page 6: Force.com Integration Using Web Services With .NET & PHP Apps

What Have We Solved With Web Service integrationsDynamic Sharing

▪ Sharing set by field values on objects or related objects▪ Change of data can require sharing rule recalculation▪ Process expensive on SOQL limits

Page 7: Force.com Integration Using Web Services With .NET & PHP Apps

Session OutlineOutbound Web Services

▪ Originating in Salesforce targeting PHP / .NET web services▪ From APEX using triggers or Visual Force controllers▪ Outbound Message using Workflows

Inbound Web Services▪ Host your web service on the force.com platform

Security and lessons learned

Page 8: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound Web Service Calls

Page 9: Force.com Integration Using Web Services With .NET & PHP Apps

WSDLs▪ Web Service Description Language▪ XML – Contract▪ Salesforce provides WSDLs for the different SOAP APIs▪ Use WSDL to generate Service / Client interfaces▪ Custom or third party Web Services usually provides the WSDL by

adding ?wsdl to the endpoint.

Page 10: Force.com Integration Using Web Services With .NET & PHP Apps

Generate proxy from WSDL in SalesforceLimitations to WSDL parser (wsdl2apex)http://bit.ly/dudMQvNot supported:

▪ RPC/Encoded Services▪ Multiple ports / services▪ @imports

Page 11: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound – WSDL - .NET 2.0

Page 12: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound – WSDL - WCF

Page 13: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound - ConsiderationsIs @future (Callout = true) when called from triggers.

Cannot be called from Controller Constructor – use VisualForce – ”action”.

<apex:page

controller="CustomCreditStatusController"

action="{!doRedirectionNET}">

Page 14: Force.com Integration Using Web Services With .NET & PHP Apps

Governor Limits

Description LimitsTotal number of callouts in a transaction 10Maximum timeout for all callouts in a transaction 120 secondsTotal number of methods with the @future annotation allowed per Apex invocation 10

Maximum response data size is 3MB.

Page 15: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound

Demo - .NET / C#

Page 16: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound Messages

Page 17: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound message from a Workflow▪ Configure workflow with outbound message▪ Define endpoint▪ Use WSDL to create interfaces / proxy

Page 18: Force.com Integration Using Web Services With .NET & PHP Apps

Outbound message from a Workflow

Page 19: Force.com Integration Using Web Services With .NET & PHP Apps

.NET – Generate the interface▪ wsdl.exe /serverInterface file.wsdl▪ SvcUtil.exe – for MCF▪ Codeplex – Wscfblue

http://wscfblue.codeplex.com/▪ Use session to handle callbacks with SOAP API

Page 20: Force.com Integration Using Web Services With .NET & PHP Apps

PHP – Generate class / proxy▪ WSDL2PHP

http://sourceforge.net/projects/wsdl2php/▪ Use session with PHP Toolkit to handle callback

Page 21: Force.com Integration Using Web Services With .NET & PHP Apps

Demo PHP

Page 22: Force.com Integration Using Web Services With .NET & PHP Apps

Inbound Web Services

Page 23: Force.com Integration Using Web Services With .NET & PHP Apps

Web Service SOAP APIEnterprise WSDL

▪ Custom objects▪ Generated from the structure in the current Salesforce Org

Partner WSDL▪ Query field / object existence before use▪ General API

Page 24: Force.com Integration Using Web Services With .NET & PHP Apps

REST APIRepresentational State TransferShort about all the available APIs - http://bit.ly/nPrXHGTypical applications

▪ Mobile▪ Web Applications▪ Chatter

Page 25: Force.com Integration Using Web Services With .NET & PHP Apps

Host Web Service on force.comExpose class methods in APEX

▪ Class needs to be defined as “global”▪ Method needs to be declared as “webservice static”

Methods available via SOAP and REST.Generate WSDL from Classes list.

Page 26: Force.com Integration Using Web Services With .NET & PHP Apps

Security, Gotchas and Tip & Tricks

Page 27: Force.com Integration Using Web Services With .NET & PHP Apps

Security▪ Multi tenant platform – secure external Web Services▪ IP Filtering▪ Username and Passwords using Basic authentication▪ SSL certificates

Page 28: Force.com Integration Using Web Services With .NET & PHP Apps

Gotchas and Tip & TricksOutbound calls

▪ Limits and triggers• 10 outbound calls per context• 10 @future calls per context

▪ Avoid call in loops – just like SOQL▪ Make Web Service methods support collection of data

Page 29: Force.com Integration Using Web Services With .NET & PHP Apps

Gotchas and Tip & TricksTesting

▪ Test methods are aborted if containing outbound calls▪ Use Mock classes to

• Improve test coverage• Simulate responses from web services• @future calls runs / completes when test.stopTest() is done

Page 30: Force.com Integration Using Web Services With .NET & PHP Apps

Gotchas and Tip & TricksTraffic inspection

▪ In regular web service development: fiddler2 ▪ Force.com: use developer instance

Remember to add remote site settings

Page 31: Force.com Integration Using Web Services With .NET & PHP Apps

SummaryOutbound web service calls

▪ Triggers and VF pages▪ Workflow rules

Inbound web service callsSecurity considerationsTip & TricksDemo code on GitHubhttps://github.com/haagen/DF13_WebServices_NETPHP

Page 32: Force.com Integration Using Web Services With .NET & PHP Apps

Martin Haagen

Systems Manager; CRM,@sehaagen

Page 33: Force.com Integration Using Web Services With .NET & PHP Apps

We want to hear from YOU!

Please take a moment to complete our session survey

Surveys can be found in the “My Agenda” portion of the Dreamforce app

Page 34: Force.com Integration Using Web Services With .NET & PHP Apps