2002/06Robi Sen department 13 Building Service Oriented Architectures ColdFusion and Web Services.
-
date post
19-Dec-2015 -
Category
Documents
-
view
213 -
download
0
Transcript of 2002/06Robi Sen department 13 Building Service Oriented Architectures ColdFusion and Web Services.
2002/06 Robi Sen department 13
Building Service Oriented Building Service Oriented ArchitecturesArchitectures
ColdFusion and Web Services
2002/06 Robi Sen department 13
AgendaAgenda
What are Web ServicesHow you can create and consume Web
Services in ColdFusionWhat are Service Oriented ArchitecturesWhy are they importantHow to create them
2002/06 Robi Sen department 13
What is a Web ServiceWhat is a Web Service
W3CDefinition: A Web service is a software
application identified by a URI, whose interfaces and binding are capable of being defined, described and discovered by XML artifacts and supports direct interactions with other software applications using XML based messages via internet-based protocols
2002/06 Robi Sen department 13
My DefinitionMy Definition
Encapsulated, loosely coupled, contracted functions offered via standard protocols
2002/06 Robi Sen department 13
Three Major ThingsThree Major Things
Discovery/Description - WSDLPublish - UDDIBind – WSDL and SOAP
2002/06 Robi Sen department 13
Why WS/SOA’sWhy WS/SOA’sFrankly it’s the best application architecture
approach for large and distributed architectures.
More flexibility and more genericInteroperability is predefined and key which
leads to greater ROI, longer life cycles, greater usability
Makes more sense to “real people” Creates new opportunities for business,
revenue, creativity, and over all usefulness
2002/06 Robi Sen department 13
Web Services Stack EvolutionWeb Services Stack Evolution
2002/06 Robi Sen department 13
Buzz Word StackBuzz Word Stack
2002/06 Robi Sen department 13
SOAPSOAP
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><SOAPSDK1:getTemperature xmlns:SOAPSDK1="capeconnect:AirportWeather:com.capeclear.weatherstation.Station">
<arg0>KDCA</arg0></SOAPSDK1:getTemperature>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
2002/06 Robi Sen department 13
SOAPSOAPDefines a unit of communication (header,envelope, body)
Defines error handling through Soap faultDefines extensibility usually through custom
headersDefines mechanism for representing abstract data
including binary data, arrays, and complex dataDefines RPC – common format for distributed
computationDefines Document- Centric approach to
information exchange (i.e. B2B)
2002/06 Robi Sen department 13
SOAP- responseSOAP- response<?xml version="1.0"?><SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<cc1:getTemperatureResponse xmlns:cc1="capeconnect:AirportWeather:com.capeclear.weatherstation.Station">
<return xsi:type="xsd:string">The Temperature at null is null</return></cc1:getTemperatureResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
2002/06 Robi Sen department 13
Introducing Web Service and Introducing Web Service and CFCF
CF through CFINVOKE makes working with Web Services as easy as CFQUERY made working with Relation Databases
2002/06 Robi Sen department 13
WSDLWSDL http://www.w3.org/TR/wsdl WSDL is an XML format for describing network services as a set of
endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME.
2002/06 Robi Sen department 13
WSDL in layman's speakWSDL in layman's speak
Defines what a service does – methods and operations
How a service is accessed – details of data formats and protocols necessary to services operations
Where a service is located – details of the protocol-specific network address, such as a URI/URL
2002/06 Robi Sen department 13
WSDL in SpecificWSDL in Specific portType- abstract interface definition like a java
interface definition Message- Defines the set of parameters referred to by
method sigs or operations Types – Data type def’s Binding – contains details on how abstract interface is
converted to literal representation (I.e. SOAP over HTTP)
Port – specifies actual service node endpoint (I.e. your http url)
Service – bad name. Actual a series or list of ports which you can think of as a collection of web services that model a complex business process
2002/06 Robi Sen department 13
Data MappingsData MappingsColdFusion data type WSDL data type
numeric SOAP-ENC:double
boolean SOAP-ENC:boolean
string SOAP-ENC:string
array SOAP-ENC:Array
binary xsd:base64Binary
date xsd:dateTime
guid SOAP-ENC:string
uuid SOAP-ENC:string
void (operation returns nothing) NA
struct Map
query QueryBean
any complex type
component definition complex type
2002/06 Robi Sen department 13
ColdFusion Components ColdFusion Components (CFC)(CFC)
<cfcomponent> <cffunction name="square" returnType="string"
access="remote"> <cfargument name="num1" type="string">
<cfset sum = #arguments.num1#*#arguments.num1#>
<cfreturn #sum#> </cffunction></cfcomponent>
2002/06 Robi Sen department 13
InvocationInvocation
<cfinvoke webservice = "URLtoWSDL" method = "operationName" inputParam1 = "val1" inputParam2 = "val2" ... returnVariable = "varName" >
2002/06 Robi Sen department 13
WSDL – what we care aboutWSDL – what we care abouthttp://localhost:8500/xml/webservice/square.cfc?wsdlhttp://localhost:8500/xml/webservice/square.cfc?wsdl
<wsdl:message name="squareResponse">
<wsdl:part name="return" type="SOAP-ENC:string" />
</wsdl:message><wsdl:message
name="squareRequest"> <wsdl:part name="num1"
type="SOAP-ENC:string" /> </wsdl:message>
2002/06 Robi Sen department 13
Calling SquareCalling Square
<cfinvoke webservice="http://localhost:8500/xml/webservice/square.cfc?wsdl"
method="square" num1="5" returnVariable="var1"></cfinvoke><cfdump var="#var1#">
2002/06 Robi Sen department 13
Same thing with CFSCRIPTSame thing with CFSCRIPT
<cfscript> ws = CreateObject("webservice",
"http://localhost:8500/xml/webservice/square.cfc?wsdl");
resultVar = ws.getSquare(num1=“5"); writeoutput(var1);</cfscript>
2002/06 Robi Sen department 13
Consuming Web ServicesConsuming Web Services
Read the WSDL fileGet Parameters and figure data typesUse a invocation method
2002/06 Robi Sen department 13
CFC MetadataCFC Metadata
2002/06 Robi Sen department 13
Show MetadataShow Metadata
2002/06 Robi Sen department 13
getProductsgetProducts<cfcomponent>
<cffunction name="getProducts" returnType="query" access="remote" output ="no">
<cfargument name="ProductName" type="string" required="true">
<cfquery name="prosearch" datasource="icf" dbtype="ODBC">
SELECT Product.ProductID, Product.ProductName, Product.ProductPricePerUnit, Product.VendorID
FROM ProductWHERE Product.ProductName LIKE '#arguments.ProductName#%'
</cfquery><cfreturn #prosearch#></cffunction>
</cfcomponent>
2002/06 Robi Sen department 13
Complex DataComplex Data http://localhost:8500/xml/webservice/productsearch.c
fc?wsdl CFC does not deal well with Queries and Structs
<wsdl:message name="getProductsResponse">
<wsdl:part name="return" type="tns2:QueryBean" />
</wsdl:message>
<wsdl:message name="getProductsRequest">
<wsdl:part name="ProductName" type="SOAP-ENC:string" />
</wsdl:message>
2002/06 Robi Sen department 13
Dealing with Complex DataDealing with Complex Data
1. Minimize the use of ColdFusion complex types, such as query and struct, in the web services you create for publication. These types require consumers, especially those consuming the web service using a technology other than ColdFusion, to create special data structures to handle complex types.
2002/06 Robi Sen department 13
Complex DataComplex Data
<cfinvoke Webservice="http://localhost:8100/xml/webservice/productsearch.cfc?wsdl"
method="getProducts" ProductName="ColdFusion" returnVariable="products"></cfinvoke><cfdump var="#products#">
2002/06 Robi Sen department 13
PRO’s of CFC Web ServicePRO’s of CFC Web Service
Simple to deploySimple to consumeBased on industry standard/accepted AXIS
2002/06 Robi Sen department 13
CONS to CFC’s Web ServiceCONS to CFC’s Web Service
Inability to customize headersIssues with complex dataOnly supports SOAP encoding styleOnly Supports HTTPNo UDDI
2002/06 Robi Sen department 13
AlternativesAlternatives
CFHTTP!!CFOBJECT and MSXMLCFOBJECT and AXISCFX_API and AXISCFX,CFOBJECT, JSP SERVLET and other
third party tools!
2002/06 Robi Sen department 13
How SOA’s relate to Web How SOA’s relate to Web ServicesServices
service-oriented architectures are– loosely coupled pieces of application functionality– published– consumed– and combined with other applications over a
network. Web Services
– stack of emerging standards – define protocols – create a loosely coupled framework for
programmatic communication among disparate systems
2002/06 Robi Sen department 13
SOA’sSOA’s
SOA’s are not so much a radical and disruptive technology paradigm shift like procedural to OO but a natural evolution of best practices.
2002/06 Robi Sen department 13
SOASOA• Loosely Coupled. Senders and receivers (producers and consumers)
are abstractly decoupled from each other. Senders construct self-contained messages (including but not restricted to XML documents) and send them using a standards-based communication backbone without knowing the actual location of the receiver. The communication mechanism is responsible for the abstraction between the sender and the receiver.
• Coarse Grained. Traditional object-based languages like Java expose their interfaces on a fine-grained, method basis. These fine-grained interfaces need to be aggregated into larger, coarse-grained services that closely resemble real business processes. Service technologies are designed to support the ability to assemble services into larger, more business suitable processes.
• Asynchronous. Asynchronous communication is essential for distributed architectures. Senders and receivers cannot always depend on the availability of each other to do their work. Through a system of intermediaries, messages are exchanged in real-time with high performance. Yet, when receivers are unavailable, the
messages can be persisted for later
2002/06 Robi Sen department 13
SOASOA STANDARS BASED: The connections are based upon
vendor-independent standards. The development of generally open and accepted standards is a key strength of the coalitions that have been building web services infrastructure. Most previous efforts at distributed computing (e.g., CORBA, DCOM, RMI, and others) were very difficult to implement, because they were dependent upon a particular vendor’s product offering, highly specified, or programmatically complex—usually all of the above.
PROCESS CENTRIC: Systems are conceived from a process-centric perspective. By intent, services are designed with a task-orientation; they function as discrete steps in a larger workflow or business process. A well designed service describes its inputs and outputs in a way that other software can determine what it does, how to invoke its functionality, and what result to expect in return.
2002/06 Robi Sen department 13
Why SOA’sWhy SOA’sFrankly it’s the best application architecture
approach for large and distributed architectures.
More flexibility and more genericInteroperability is predefined and key which
leads to greater ROI, longer life cycles, greater usability
Makes more sense to “real people” Creates new opportunities for business,
revenue, creativity, and over all usefulness
2002/06 Robi Sen department 13
Distributed ProcessDistributed Process
2002/06 Robi Sen department 13
Break Down of ProcessBreak Down of Process
2002/06 Robi Sen department 13
SOA with CFSOA with CFDefine at a high level of a process and then
serviceCreate a open interface via CFC to other
components, templates, tagsYou can use getMetaData() to create
automated apps and easily discoverable services
2002/06 Robi Sen department 13
Change the way you think!Change the way you think!
SOA’s require you stop thinking about units of functionality, components, technology but force you to focus on what's important! Figuring out what you need to do and how to model it!
2002/06 Robi Sen department 13
Implementations TodayImplementations TodayRe-Use and Syndication. Software re-use has always been a key
part of component-based software models, but it rarely has been practical to implement. Web services may be different. Some early adopters envision syndicating existing software systems (e.g., an investment bank’s derivatives calculator or other complex algorithms) to partners and customers. Other re-use ideas include leveraging the standards-based interoperability to deliver data to a variety of formats and devices(e.g., web browsers, mobile devices, and interactive television).
Automation and Productivity. Disparate systems still result in a remarkable amount of manual integration processes. As a result, web services’ interoperability promise to yield tremendous opportunities for productivity improvements through automation of business processes and employee productivity. Example projects might include exposing order status tracking and past purchase history to customers. Automation initiatives could yield results similar to the so-called “ATM Effect,” which has helped significantly simplify the cost structure and increase the profitability of retail banking.
2002/06 Robi Sen department 13
More ImplementationsMore ImplementationsVisibility into Operations. Businesses consistently seek to
improve the accuracy of their inventory and revenue forecasts but are constrained by a lack of clear visibility into operating data. Web services based “digital dashboards” are one way adopters hope to address this challenge. Several specific categories of information that are hot-button issues include demand forecasting throughout the supply-chain, real-time cash flow and operating capital, and production and inventory availability.Bottom-line, better visibility will yield a dramatic impact on a company’s cost structure.
Exploring New Business Models. Most companies evaluating web services today are focused squarely on efficiencies and tend to put new web services-based revenue opportunities into a“sometime in the future” bucket. A few early adopters are exploring new subscription or pay-peruse business models, however. Further down the road, companies may spin off non-strategic (but potentially valuable) web service competencies, just as many tangible assets were “unlocked” at an increased value as stand-alone entities over the past ten years.
2002/06 Robi Sen department 13
The FutureThe Future
Support for new protocolsGreater interoperabilitySupport for complex data typesSupport for emerging standardsExposure of the engineOrchestration
2002/06 Robi Sen department 13
SummarySummarySuper easy to consume and deploySupports emerging standardsHas issues with complex data, different
encoding, as well as protocolsYou have lots of optionsWeb Services and SOA’s are moving
targets and paradigms and we will see change and growth in this space for several years
2002/06 Robi Sen department 13
ResourcesResources
W3c.orgwww.macromedia.comAlphaworks.ibm.comwww.xml.comwww.webservices.orgwww.xmethods.netUddi.org