Web Service Protocols —Web service specifications

Preview:

DESCRIPTION

课程名:以服务为中心的软件开发设计与实现. Web Service Protocols —Web service specifications. Outline. Overview of Web Services XML and XML Schema The Communication Protocol (SOAP) Web Services Description (WSDL) Web Services Publication and Discovery (UDDI) Summary. Overview of Web Services. Web Services. - PowerPoint PPT Presentation

Citation preview

1

Web Service Protocols—Web service specifications

课程名:以服务为中心的软件开发设计与实现

2

Outline• Overview of Web Services• XML and XML Schema • The Communication Protocol (SOAP)• Web Services Description (WSDL)• Web Services Publication and Discovery (UDDI)• Summary

3

Overview of Web Services

4

Web Services

• Web Services: Web services are a recent set of technology specifications that leverage existing proven open standards such as XML, URL, and HTTP to provide a new system-to-system communication standard.

• Working Definition: Network-resident software Services accessible via standardized protocols

– Simple Object Access Protocol (SOAP): very flexible remote procedure call

• Lots of interest in trade press, academic community, standards bodies, . . .

• Applications in e-commerce, telecom, science, GRID, government, education, . . .

5

Categories of Web Services• Business-Oriented Web Services

– ERP,CRM,– Application system integration

• Consumer-Oriented Web Services– B2C website, across multi B2C systems

• Device-Oriented Web Services– Support the services across different kinds of services. E.g

weather report, email service• System-Oriented Web Services

– Authentication– Monitoring– QoS

6

• As a distributed computing architecture, Web Services are the most important implementation for SOA.

• SOA Model is Web Services Concept Architecture.

SOA Model

7

Concept in SOA Model

• Role– Services Provider– Services Requestor– Services Registry

• Operation– Publish– Find– Bind

• Key Component– Services– Services Description

8

Core Standards in SOA Model

• Some Standards– Web Services Description Language (WSDL)– Universal Description, Discovery and Integration (UDDI)– Simple Object Access Protocol (SOAP)– Web Service Flow Language (BPEL)– ……

9

The Level Model of SOA Development

Existing Application Resources

Components

Services

Business Process

Services ProviderServices C

onsumer

Qos Security M

anagement

Integration Architecture

10

The Processes of Web ServicesSimplify and/or automate web Services • Discovery

– What properties should be described?– How to efficiently query against them?

• Composition– Specifying goals of a composition– Specifying constraints on a composition– Building a composition – Analysis of compositions

• Invocation– Keeping enactments separated– Providing transactional guarantees

• Monitoring– How to track enactments– Recovering from failed enactments

11

Web Services Standard Stack

Transport layer: HTTP, SMTP, FTP, etc.

XML messaging layer: SOAP , WS-Addressing, WS-Notification, WS-Eventing, WS-Enumeration, WS-MessageDelivery, WS-Reliability,WS Reliable Messaging, WS-Resources WS-Transfer

Services Description Layer: WSDL, WSCL, WSCI,WS-MetadataExchange, WS-Policy

Web Services composition:WSFL,BPEL4WS WS-CDL WS-CAF

Publishing anddiscovery:UDDI,WSIL, WS-Discovery

Web Services Transaction:WS-Coordination WS-Transaction WS-AtomicTransaction WS-BusinessActivityWeb Services Management:WSDM, WS-Manageability SPML, WS-Provisioning

Web Services Security:XML-Encryption XML-Signature WS-Security WS-SecureConversation WS-SecurityPolicy WS-Trust

12

Data

Type

Interface

Behavior

Message

BPEL

Web Service Standards

Implementation Platforms

WSDL

SOAP

XML Schema

XML Sun

J2EE

Web Service Core Standards

Micr

osof

t .Ne

t

IBM

Web

Sphe

re

13

XML and XML Schema

14

The structure of XML• Tag: label for a section of data• Element and Subelement: section of data beginning with

<tagname> and ending with matching </tagname>Elements must be properly nested

– Proper nesting• <account> … <balance> …. </balance> </account>

– Improper nesting• <account> … <balance> …. </account> </balance>

– Formally: every start tag must have a unique matching end tag, that is in the context of the same parent element.

15

– Every document must have a single top-level element

<bank> <customer>

<name> Hayes </name> <street> Main </street> <city> Harrison </city> <account>

<account-number> A-102 </account-number> <branch-name>Perryridge </branch-name> <balance> 400 </balance>

</account> <account> … </account>

</customer>. .

</bank>

The structure of XML

Top level element

16

The structure of XML

• Attribute– Elements can have attributes <account acct-type = “checking” >

<account-number> A-102 </account-number> <branch-name> Perryridge </branch-name> <balance> 400 </balance>

</account>– Attributes are specified by name=value pairs inside the

starting tag of an element– An element may have several attributes, but each attribute

name can only occur once• <account acct-type = “checking” monthly-fee=“5”>

17

The structure of XML• Differences between element and attribute

<customer name=Hayes street=Main city=Harrison> <account>

<account-number> A-102 </account-number> <branch-name> Perryridge </branch-name> <balance> 400 </balance>

</account> <account> … </account>

</customer>Attribute can only occur once

Attributes cannot be nested

Attributes have no order

18

The structure of XML

• Well-Formed XML Documents– There is only one outermost element in the document

(called the root element)– Each element contains an opening and a

corresponding closing tag– Tags can not overlap, as in

<author><name>LeeHong</author></name>– Attributes within an element have unique names– Element and tag names must be permissible

19

The structure of XML

• The Tree Model of XML Documents– There is exactly one root– There are no cycles– Each node, other than the root, has exactly

one parent– Each node has a label. Element or attribute– The order of elements is important

20

21

XML Example<?xml version="1.0" encoding="UTF-16"?>

<!DOCTYPE email SYSTEM "email.dtd"><email>

<head><from name="Michael Maher” address="michaelmaher@cs.gu.edu.au"/><to name="Grigoris Antoniou“ address="grigoris@cs.unibremen.de"/><subject>Where is your draft?</subject>

</head><body>

Grigoris, where is the draft of the paperyou promised me last week?

</body></email>

22

Namespace

• XML data has to be exchanged between organizations

• Same tag name may have different meanings in different organizations, causing confusion on exchanged documents

• Specifying a unique string as an element name avoids confusion

• Better solution: use unique-name:element-name• Avoid using long unique names all over document by

using XML Namespaces

23

Namespace

<Schema name="mySchema"         xmlns="urn:schemas-microsoft-com:xml-data"        xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:myNS=http://www.xml_step_by_step.edu\ns.xml

>

Three namespaces:schema namespacedatatype namespacemyNS namespace

24

Sample Code—Read XMLimport java.net.URL;

import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.io.SAXReader;

public class Foo {

public Document parse(URL url) throws DocumentException {

SAXReader reader = new SAXReader(); Document document = reader.read(url); return document; }}

public void bar(Document document) throws DocumentException {

Element root = document.getRootElement(); // iterate through child elements of root for ( Iterator i = root.elementIterator(); i.hasNext(); ) { Element element = (Element) i.next(); // do something } // iterate through child elements with element name "foo" for ( Iterator i = root.elementIterator( "foo" ); i.hasNext(); )

{ Element foo = (Element) i.next(); // do something } // iterate through attributes of root for ( Iterator i = root.attributeIterator(); i.hasNext(); ) { Attribute attribute = (Attribute) i.next(); // do something } }

25

Sample Code—Write XMLimport org.dom4j.Document;import org.dom4j.DocumentHelper;import org.dom4j.Element;

public class Foo { public void createDocument() { Document document = DocumentHelper.createDocument(); Element root = document.addElement( "root" ); Element author1 = root.addElement( "author" ) .addAttribute( "name", "James" ) .addAttribute( "location", "UK" ) .addText( "James Strachan" ); Element author2 = root.addElement( "author" ) .addAttribute( "name", "Bob" ) .addAttribute( "location", "US" ) .addText( "Bob McWhirter" );

FileWriter out = new FileWriter( "foo.xml" );document.write( out );

}}

26

XML Schema

• Database schemas constrain what information can be stored, and the data types of stored values

• schemas are very important for XML data exchange– Otherwise, a site cannot automatically interpret data received

from another site

• Two mechanisms for specifying XML schema– Document Type Definition (DTD)– XML Schema

Like DDL for

database?

27

DDL Example/*Column Information For - psn.publisher*/Field Type Collation Null Key Default Extra Privileges

Comment------ ---------------- --------------- ------ ------ ------- ------ ------------------------------- -------id int(11) unsigned (NULL) NO PRI 0

select,insert,update,references name varchar(255) utf8_general_ci NO

select,insert,update,references

/*DDL Information For - psn.publisher*/Table Create Table --------- --------------------------------------------------------------------------------publisher CREATE TABLE `publisher` ( `id` int(11) unsigned NOT NULL default '0', `name` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Publisher information from DBLP'

28

XML Schema

• XML Schema Supports– Typing of values

• E.g. integer, string, etc• Also, constraints on min/max values

– User defined types– Is itself specified in XML syntax, unlike DTDs

• More standard representation, but verbose– Is integrated with namespaces (reuse and refine)– Many more features

• List types, uniqueness and foreign key constraints, inheritance ..

29

<xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema><xsd:element name=“bank” type=“BankType”/><xsd:element name=“account”>

<xsd:complexType> <xsd:sequence> <xsd:element name=“account-number” type=“xsd:string”/> <xsd:element name=“branch-name” type=“xsd:string”/> <xsd:element name=“balance” type=“xsd:decimal”/> </xsd:squence></xsd:complexType>

</xsd:element>….. definitions of customer and depositor ….<xsd:complexType name=“BankType”>

<xsd:squence><xsd:element ref=“account” minOccurs=“0” maxOccurs=“unbounded”/><xsd:element ref=“customer” minOccurs=“0” maxOccurs=“unbounded”/><xsd:element ref=“depositor” minOccurs=“0” maxOccurs=“unbounded”/>

</xsd:sequence></xsd:complexType></xsd:schema>

30

XML Schema

• Element Types <element name=". . ."/> with possible attributes:

– ‘ type’ attribute define the element type of this element: type=". . ." (more on types later)– cardinality constraints:

• minOccurs="x", where x may be any natural number (including zero)

• maxOccurs="x", where x may be any natural number (including zero) or unbounded

31

XML Schema

<element name="email"/><element name="head" minOccurs="1" maxOccurs="1"/><element name="to" minOccurs="1"/>

32

XML Schema• Attribute Types

<attribute name=". . ."/> with possible attributes– type=". . ."– use="x", corresponds to #OPTIONAL and

#IMPLIED in DTDs– use="x" value=". . .", where x may be default or fixed

33

XML Schema

<attribute name="id" type="ID" use="required"/>

<attribute name="speaks" type="LanguageType" use="default“ value="en"/>

34

XML Schema

• Data Types– Numerical data types, including integer, Short,

Byte, Long, Float,Decimal– String data types, including string, ID, IDREF,

CDATA, Language– Date and time data types

• user-defined data types– simple data types and complex data types

35

XML Schema

• Complex data type and extension data type– defined from already existing data types by defining some

attributes (if any) and using sequence, all and choice.

<complexType name="lecturerType"><sequence>

<element name="firstname" type="string"minOccurs="0" maxOccurs="unbounded"/>

<element name="lastname" type="string"/></sequence><attribute name="title" type="string" use="optional"/></complexType>

36

XML Schema

• <element name=“lecture” type=“lectureType”>

<lecture title=“associate professor”><firstname>gang</firstname><lastname>Huang</lastname>

</lecture>

37

XML Schema

Data Type Extension: existing data types can be extended by new elements or attributes

<complexType name="extendedLecturerType"><extension base="lecturerType"><sequence>

<element name="email" type="string"minOccurs="0" maxOccurs="1"/>

</sequence><attribute name="rank" type="string" use="required"/></extension></complexType>

38

XML Schema• Restriction data type and simple data type

be defined by restricting existing data types<complexType name="restrictedLecturerType"><restriction base="lecturerType"><sequence>

<element name="firstname" type="string"minOccurs="1" maxOccurs="2"/>

</sequence><attribute name="title" type="string" use="required"/></restriction></complexType>

39

XML schema• Simple data types can also be defined by

restricting existing data types.<simpleType name="dayOfMonth">

<restriction base="integer"><minInclusive value="1"/><maxInclusive value="31"/>

</restriction></simpleType>

40

The Communication Protocol(SOAP)

41

Why Simple Object Access Protocol

• SOAP is an XML messaging protocol that is independent of any specific transport protocol.

• Light weight replacement for complicated distributed object technology

• Originally for BizTalk (Microsoft/UserLand/DevelopMentor )• Now a W3C standard

• Based on XML

42

SOAP Message Structure• Envelope contains

– Header– Body

• Header is optional– Out-of-band information

such as…• Authentication information• Message routes• Logging• Transaction flow

• Body contains XML body of RPC call

SOAP Envelope

SOAP HeaderHeader Block

Header Block. . .

SOAP BodyBody Block

Body Block. . .

43

SOAP Example

<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-ncoding"> <soap:Body> <m:GetPrice xmlns:m="http://www.w3schools.com/prices"> <m:Item>Apples</m:Item> </m:GetPrice> </soap:Body></soap:Envelope>

44

SOAP Example

<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body> <m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices"> <m:Price>1.90</m:Price> </m:GetPriceResponse> </soap:Body></soap:Envelope>

45

Web Services Description Language(WSDL)

46

Web Services Description Language (WSDL)

• WSDL is an XML-based interface definition language that separates function from implementation, and enables design by contract as recommended by SOA.

• WSDL defines– What does Services do – interface– Access specification – how– Location of the Services – where

47

WSDL Specification

types

message message message

operation

porttype

operation operation

binding

serviceport

48

Ingredients of WSDL

OperationPort Type

MessageBinding

Port Services

Supports

Input & Output

Provides

How to encode

Formats & Protocols

How to invoke

Implements

Interface

Accessspecification

Endpoints

49

Main Structure of WSDL

<definitions namespace = “http://… ”><types> XML schema types </type><message> definition of a message </message><portType> a set of operations </portType><binding> communication protocols </binding><Services> a list of binding and ports </Services>

</definitions>

50

Types• <types> define data types used in defining messages• XML Schema, DTD, and etc.• XML Schema must be supported by any vendor of WSDL

conformant products

<types> <schema targetNamespace=“http://example.com/stockquote.xsd”

xmlns=“http://www.w3.org/2000/10/XMLSchema”> <element name=“TradePriceRequest”>

<complexType> <all>

<element name=“tickerSymbol” type=“string“

minOccur = “1” maxOccur=“10”/>

<element name = “payment”><complexType>

<choice><element

name = “account” type=“string” /><element

name = “creditcard” type=“string” /></choice>

</complexType></element>

</all> </complexType>

</element> </schema>

</types>

51

WSDL Messages• A <message> element defines the data elements of an

operation• Each message can be the input or output of an operation, and

may consist of one or more parts• A part resembles a parameter of a function

<message name=“GetLastTradePriceInput”> <part name=“body” element="TradePriceRequest"/>

</message>

<message name=“GetLastTradePriceOutput”> <part name=“body” element=“TradePrice” />

</message>

52

WSDL PortTypes• The <portType> element is the most important WSDL

element: it defines – a web Service– the operations that can be performed, and– the messages that are involved

• The <port> defines the connection point to a web Services, an instance of <portType> – It can be compared to a function library (or a module, or a

class) in a traditional programming language– Each operation can be compared to a function in a

traditional programming language

53

<portType name=“StockQuotePortType”> <operation name=“GetLastTradePrice”> <input message=“tns:GetLastTradePriceInput” /> <output message=“tns:GetLastTradePriceOutput” /> </operation> </portType>

54

Operation Types• The request-response type is the most common operation type,

but WSDL defines four types:– One-way: The operation can receive a message but will not

return a response – Request-response: The operation can receive a request and

will return a response– Solicit-response: The operation can send a request and will

wait for a response– Notification: The operation can send a message but will not

wait for a response

• WSDL 1.2 adds: request – multiple response

55

Operation TypesOne-way:• <message name="newTermValues">

<part name="term" type="xs:string"/><part name="value" type="xs:string"/>

</message>• <portType name="glossaryTerms">

<operation name="setTerm"><input name="newTerm" message="newTermValues"/>

</operation></portType >

Request-response:<message name="getTermRequest">

<part name="term" type="xs:string"/></message><message name="getTermResponse">

<part name="value" type="xs:string"/></message>

<portType name="glossaryTerms"><operation name="getTerm">

<input message="getTermRequest"/><output message="getTermResponse"/>

</operation></portType>

56

• Binding defines how message are transmitted, and the location of the Services

• <binding> element has two attributes:– type: the port type– name: name of the binding

• <soap:binding> has two attributes:– style: either “document” or “rpc”– transport: protocol to use, e.g., “http”

Binding

57

Binding (2) – Alternatives to SOAP over http

• XML documents over HTTP– Less need to do this with commonplace SOAP

toolkits– But these are still web services

• XML RPC– Simpler than SOAP and longer history– Limitations on objects that can be exposed– With current SOAP toolkit support, little reason to

use

58

Binding<binding name="StockQuoteSoapBinding“

type="tns:StockQuotePortType"> <soap:binding style=“document”

transport=“http://schemas.xmlsoap.org/soap/http” /> <operation name="GetLastTradePrice">

<soap:operationsoapAction=“http://example.com/

GetLastTradePrice” /> <input>

<soap:body use=“literal” /> </input> <output>

<soap:body use=“literal” /> </output>

</operation> </binding>

59

<Services name=“StockQuoteServices”> <documentation>

My first Services</documentation> <port name=“StockQuotePort”

binding=“tns:StockQuoteBinding”> <soap:address

location=“http://example.com/stockquote” />

</port> </Services>

Services

60

Summary of WSDL• Types• Message • Operation• PortType • Binding • Port • Service

61

Web Services Publication and Discovery

62

Why Do We Need a Web Services Registry

• Web services are valuable because of standardized payloads and transport definitions– The value is creating a web service that is used by

many clients• Can’t happen unless the services are

advertised to multiple consumers

63

UDDI• UDDI servers act as a directory of available services

and service providers. SOAP can be used to query UDDI to find the locations of WSDL definitions of services, or the search can be performed through a user interface at design or development time.

• Data structure specification describes what kind of data is stored in UDDI.

• The programmer’s API specification contains how a UDDI registry can be accessed.

• The replication specification contains descriptions of how registries replicate information among themselves.

64

UDDI• Three basic functions

– publish: how to register a web service– Search: how to find a specific web service– binding: How to connect to a web service

65

Core UDDI Entities

businessService

businessService

Interface tModelbindingTemplate

bindingTemplate

businessEntity

bindingTemplateInterface tModel

66

Summary

67

Summary • As a distributed computing architecture,Web Services are the most

important implementation for SOA;• Web Services: Flexible machine-machine interaction;• XML is a powerful language to describe data. It’s construct rules is

defined by XML Schema.• SOAP is a light weight replacement for complicated distributed object

technology which we use to wrap Web Services message;• The function and interface of Web Services is open by WSDL and the

interaction between Web Services is presented by BPEL; • Universal Description, Discovery, and Integration (UDDI) is a

technical specification for describing, discovering, and integrating web Services.

68

Reference•A list of web service specifications. http://en.wikipedia.org/wiki/List_of_Web_service_specifications.•SOA & Webservices.http://www-900.ibm.com/developerWorks/cn/ webservices•WebServices. http://www.w3.org/2002/ws/•Ueli Wahli ,Thomas Kjaer…“WebSphere Version 6 Web Services Handbook Development&Deployment”,http://www.redbooks.ibm.com/redbooks/pdfs/sg246461.pdf,2005•Stan Kleijnen,Srikanth Raju.An Open Web Services Archiecture.NewYork: ACM Press,2003•XML.http://www.w3.org/TR/xml/•XML Schema. http://www.w3.org/TR/xmlschema11-1/•WSDL. http://www.w3.org/TR/wsdl•Tony Andrews, Francisco Curbera. Business Process Execution Language for Web Services Version 1.1.http://download.boulder.ibm.com/ ibmdl/pub/software/dw/specs/ws-bpel/ws-bpel.pdf•The Stencil Group.” The Evolution of UDDI ,UDDI.org White Paper” http://www.uddi.org/pubs/the_evolution_of_uddi_20020719.pdf

69

Thanks!

HP: http://keg.cs.tsinghua.edu.cn/persons/tj/Arnet: http://jietang.arnetminer.org/

70

Appendix

71

UDDI Entities• businessEntity – provider of service• businessService – collection of related services• bindingTemplate - information necessary to use • tModel - “reusable concept” such as

– Interface– Protocol used by web services– Category

• publisherAssertion - relationship that business entity has with another businessEntity

• Subscription – request to be informed of particular changes

72

businessEntity Structure

73

businessEntity Identifying Elements• Uniquely identified by businessKey attribute• discoveryURLs

– <discoveryURL useType=”businessEntity”>http://www.example.com?businessKey=uddi:example.com:registry:sales:53</discoveryURL> • Returns XML document of type businessEntity

– <discoveryURL useType=”homepage”>    http://www.acmewidgets.com</discoveryURL>

• name – Multiple names to do languages or abbreviations– <businessEntity . . . >–   ........–   <name xml:lang="ja">日本生花店 </name>–   <name xml:lang="ja">ニッポンセイカテン </name>–   <name xml:lang="en">NIPPON FLOWERS </name>–   <name xml:lang="en">NF</name>–   .....– </businessEntity>

• description– Multiple descriptions potentially in multiple languages with xml:lang

74

businessEntity contacts

<

75

businessEntity Identifiers and Categories

• Optional IdentifierBag– <identifierBag>

    <keyedReference      tModelKey=”uddi:uddi.org:ubr:identifier:dnb.com:d-u-n-s”      keyName=”SAP AG”

•         keyValue=”31-626-8655” />– </identifierBag>

• Optional CategoryBag– <categoryBag>

   <keyedReference    tModelKey=”uddi:uddi.org:ubr:categorization:iso3166”    keyName=”California, USA”

–     keyValue=”US-CA” />– </categoryBag>

76

businessService

77

bindingTemplates

78

tModelInstance Details

79

overviewDoc

80

tModels• The “technical fingerprint”

– tModel defines unique identifiers for interfaces and interface specifications

– Once tModel is published service advertises compliance with the spec represented by including the correct tModelKey

• Value sets– Categorization hierarchies– E.g. categoryBag and identifierBag have references to tModels with the

system of values• Find qualifiers

– find_business uddi:uddi.org:findqualifier:sortbydateasc

81

tModel Structure

82

tModel Structure• Exactly one non-empty name• Zero or more descriptions• Zero or more overviewDocs

– useType=text– useType=wsdlInterface

• identifierBag– Contains tModelKey which uniquely identifies tModel (inconsistent?)– Other logical identifiers

• categoryBag– list of categories that describe specific aspects of the tModel

83

UDDI Standard APIs

84

UDDI APIs• Inquiry• Publication• Subscription• Security• Custody Transfer• Replication

85

Inquiry API Patterns• Browse

– find_xx• Drill-down

– Use browse then drill-down– get_xx

• Invocation– Use browse and drilldown and get bindingTemplate– Invoke from bindingTemplate

86

Inquiry API Functions

• find_binding• find_business• find_relatedBusinesses• find_service• find_tModel

• get_bindingDetail• get_businessDetail• get_operationalInfo• get_serviceDetail• get_tModelDetail

87

Public Registries

• IBM Public registry Registration: https://uddi.ibm.com/ubr/registry.htmlinquiryURL= https://uddi.ibm.com/ubr/inquiryapi publishURL= https://uddi.ibm.com/ubr/publishapi

• Test registry Registration: https://uddi.ibm.com/testregistry/registry.html inquiryURL= https://uddi.ibm.com/testregistry/inquiryapi publishURL= https://uddi.ibm.com/testregistry/publishapi

88

Public Registries • HP Registration: http://uddi.hp.com inquiryURL = http://uddi.hp.com/ubr/inquire publishURL = https://uddi.hp.com/ubr/publish

• Microsoft Registration: http://uddi.rte.microsoft.com

inquiryURL=http://uddi.rte.microsoft.com/inquire publishURL=https://uddi.rte.microsoft.com/publish

• SAP Registration: http://udditest.sap.com

inquiryURL=http://uddi.sap.com/UDDI/api/inquiry/ publishURL=https://uddi.sap.com/UDDI/api/publish/

89

Searching for Web Services

90

Publishing a Web Service

91

Connecting to UDDI with .NETpublic UddiConnection InitializeConnection() {

string szInquiry = "http://test.uddi.microsoft.com/inquire"; string szPublish = "https://test.uddi.microsoft.com/publish"; string szExtension = "http://test.uddi.microsoft.com/extension.asmx"; string szUsername = null; string szPassword = null; UddiConnection oConnection = null; try {

oConnect = new UddiConnection(szInquiry, szPublish, szExtension, szUsername, szPassword); System.Net.IWebProxy oProxy =

System.Net.WebProxy("http://someproxy:80",true); oConnect.AutoGetAuthToken = true;

oConnect.HttpClient.Proxy = oProxy; GetAuthToken oGetToken = new GetAuthToken(szUsername, szPassword);

oConnect.AuthInfo = oGetToken.Send(oConnect); } catch(InvalidUrlPassedException oUddiEx) {

// Insert exception-handling code. return null;

} catch(UddiException oUddiEx) {

// Insert exception-handling code. return null;

}return oConnect;

}

92

Finding Businesses with .NETusing Microsoft.Uddi;

try {

// Create a connection to the UDDI node that is to be accessed.UddiConnection myConn = new UddiConnection("http://test.uddi.microsoft.com/inquire");

// Create an object to find a business.FindBusiness fb = new FindBusiness("Fabrikam");

// Send the prepared FindBusiness request over the connection.BusinessList bizList = fb.Send(myConn);

// Report the summary result.Console.WriteLine("Found " + bizList.BusinessInfos.Count + " businesses");}catch (Microsoft.Uddi.UddiException e){ Console.WriteLine("UDDI error: " + e.Message); }catch (Exception gen){ Console.WriteLine("General exception: {0}", gen.Message);

}

93

Publishing with .NET • UddiConnection myConn = new

UddiConnection(InquireTextbox.Text,PublishTextBox.Text);• myConn.AuthenticationMode = AuthenticationMode.UddiAuthentication;• myConn.Username = UserTextbox.Text;• myConn.Password = PasswordTextbox.Text;

• // Create a named business entity.• BusinessEntity myBiz = new BusinessEntity(BusinessNameTextbox.Text);

• // Use business entity to create an object to save a business.• SaveBusiness sb = new SaveBusiness(myBiz);

• // Send the prepared save business request.• BusinessDetail savedBiz = sb.Send(myConn);

• ReturnBiz.Text= savedBiz.BusinessEntities[0].Names[0].Text;• ReturnKey.Text= savedBiz.BusinessEntities[0].BusinessKey;

94

Finding Services with .NET

try { UddiConnection conn = new

UddiConnection("http://localhost/uddi/inquire.asmx");

FindService fs = new FindService(“holdem odds”);

ServiceList servList = fs.Send(conn); // Display the service name and unique identifying key.

foreach (ServiceInfo servInfo in servList.ServiceInfos) { MessageBox.Show("Service: " + servInfo.Names[0].Text + " " + servInfo.ServiceKey);

} } catch (Microsoft.Uddi.UddiException ex) {

MessageBox.Show("UDDI Exception: " + ex.Message); } catch (Exception gen) {

MessageBox.Show("General Exception: " + gen.Message); }

95

Mapping WSDL to UDDI• UDDI technote (V2.0 in August 2003) regarding

– How to take about WSDL objects and store them in UDDI equivalents

– Enables queries on WSDL constituents (portTypes, operations, ports)

96

Overview