Presentation is loading. Please wait.

Presentation is loading. Please wait.

WebServices ● What are web services? ● They can be any web based services, but we are talking about WSDL here. ● Web Services Definition Language is XML.

Similar presentations


Presentation on theme: "WebServices ● What are web services? ● They can be any web based services, but we are talking about WSDL here. ● Web Services Definition Language is XML."— Presentation transcript:

1 WebServices ● What are web services? ● They can be any web based services, but we are talking about WSDL here. ● Web Services Definition Language is XML ● WSDL is mostly used by large corporations. ● WSDL 1.1 is the de-facto standard. ● WSDL 2.0 is the W3C recommendation.

2 Bindings ● WSDL provides abstract service definitions. ● Bindings map to concrete data encodings ● And to specific service URLs and protocols. ● The main targeted binding is SOAP ● In theory, you can use web forms, XMLRPC, and any other mechanism. ● Mapping is done by extensibility elements. ● Different libraries support different extensibility elements.

3 SOAP ● WSDL primarily uses SOAP bindings. ● Simple Object Access Protocol... a misnomer ● It's complex and bloated, so we need software support to make it manageable. ● The main frameworks are in Java and C#. ● Different implementations support different options.

4 GWS Motivation ● I had to integrate with corporate web services. ● Very little free software available other than in Java. ● Using Java from other languages is painful and slow. ● Needed a free Objective-C or C solution. ● GNUstep WebServices written for better performance. ● Targets the common WSDL setups, but is easily extensible.

5 GNUstep WebServices ● The GNUstep WebServices library is written in Objective-C ● It builds with GNUstep-make or Apple Xcode... portable. ● It currently implements WSDL 1.1 ● It targets the SOAP binding, but can be extended for others easily. ● It makes it simple to write clients without having to use Java or C#

6 WSDL support ● We parse WSDL documents to produce objects. ● The objects can be examined and/or modified. ● We can generate a WSDL document from our objects. ● We provide lightweight XML tree support. ● We can tell a GWSService object to perform a service.

7 XML-RCP support ● We provide an XML-RPC coder. ● We provide synchronous and asynchronous RPC operations. ● There is no WSDL extensibility binding for XML-RPC. ● If you don't NEED to use WSDL/SOAP you should just use the XML-RPC coder directly. ● XML-RPC is almost always a better solution.

8 SOAP support ● We provide a SOAP encoder. ● You can use it directly for SOAP requests. ● GWSService understands SOAP extensibility ● You can invoke a service which uses SOAP.

9 GWSDocument ● Initialise an instance from a URL to parse the WSDL document at that URL. ● Provides methods to examine the contents of the document and modify them. ● Provides a method to regenerate the WSDL document. ● Provides registration of handlers to deal with WSDL extensitibilty.

10 within the document ● The WSDL document is parsed into the following objects owned by the GWSDocument - ● GWSMessage: the 'message' element ● GWSPortType” the 'portType' element ● GWSBinding: the 'binding' element ● GWSPort: the 'port' element ● GWSService: the 'service' element

11 GWSMessage ● Represents a WSDL message... the abstract idea of passing data between two endpoints. ● Each message has a unique name. ● It may contain documentation. ● It will contain a list of named parts. ● Parts define the data to be sent in the message.

12 GWSPortType ● Represents a WSDL portType ● Each port type has a unique name. ● It may provide documentation. ● It contains a set of named operations. ● Each operation may consist of ● an input message ● an output message ● and perhaps a fault message

13 GWSBinding ● Represents a WSDL binding. ● Has a unique name. ● Contains documentation and extensibility elements. ● References a particular portType. ● Lists the operations of the portType. ● Instead of specifying the messages for each operation, this holds extensibility elements to control how the messages are encoded.

14 GWSPort ● Represents a WSDL port. ● Has a unique name ● Has a binding which tells you what you can do with this port. ● May have extensibility (eg the URL to wihc you would send a SOAP request).

15 GWSService ● Represents a WSDL service. ● Has a unique name. ● May have documentation. ● Lists ports used by the service. ● Also handles invoking service operations. ● This is the key object a client will need to use. ● Can be used without a GWSDocument.

16 GWSElement ● Represents an XML element. ● Lightweight object with small API. ● Used throughout the WebServices library. ● Allows us to maintain trees of elements. ● Intermediate stage when encoding SOAP. ● Only needed for more advanced use.

17 More classes ● That concludes the list of classes used to parse/represent a WSDL document. ● There are two more important groups of classes. ● GWSExtensibility and its subclasses provide handling of extensibility elements within a WSDL document. ● GWSCoder and its subclasses provide encoding/decoding of messages to/from different representations.

18 Extensibility ● You register handler objects for namespaces ● When a WSDL document is parsed, the handler for a namespace is passed the extensibility elements for that namespace. ● When a message is sent by a service, the handler is asked to set up the service based on the extensibility elements in it. ● Implementing an extensibility handler is complex, but the SOAP handler is available as an example.

19 Coders ● Coders are used to encode property lists to an NSData object or decode an NSData to a property list. ● GWSCoder is a semi-abstract class. ● Implements convenience methods for handling XML (encoding/decoding GWSElements etc). ● Supports delegation of encoding/decoding of specific items. You can use that to override normal behavior.

20 Property lists ● A WSDL message is handled as a property list (NSDictionary). ● GWSMethodKey: the method/message name ● GWSParametersKey: the named params (a dictionary). ● GWSOrderKey: The order of params (an array of names) ● GWSErrorKey: Failure results.

21 GWSXMLRPCCoder ● Subclass of GWSCoder ● Encodes a property list to an XMLRPC request or response. ● Decodes an XMLRPC document to a property list. ● Supports setting of timezone for encoding and decoding date/time stamps.

22 GWSSOAPCoder ● Subclass to implement SOAP encoding/decoding. ● GWSSOAPBodyEncodingStyleKey (rpc, document, wrapped) ● GWSSOAPUseKey (encoded, literal) ● GWSSOAPMessageHeaderkey: heder info ● GWSSOAPNamespaceURIKey ● GWSSOAPNamespaceNameKey ● GWSSOAPValueKey

23 Setting the SOAP keys ● Setting all the keys in the plist is tedious. ● If you have a WSDL document, it handles it. ● When you invoke the operation, the service object calls the extensibility handler to fill in most of these values. ● It even creates the coder if necessary.

24 Coder delegates ● Normally the delegate of a coder is a GWSService ● You can set your own delegate to intercept messages. ● The delegate can override encoding/decoding of any data item. ● So you can implement custom coding/encoding to deal with bugs or unusual features in a server you are talking to.

25 Service delegates ● You can set up a delegate for a service. ● -completedRPC: to handle completion. ● -webService:willSendRequest: to intercept and modify the entire request. ● -webService:willHandleResponse: to intercept and modify the response.

26 Changing the URL ● SOAP bindings contain the URL to be used for an operation. ● Often this URL is wrong. ● You can override it by setting a delegate for the service ● Implement -webService:willSendRequest: to call -setURL: immediately before the request is sent. ● You can also override the SOAPAction header in the same way.

27 Debugging ● Use the GWSDebug user default to turn on debug globally. ● Use the [GWSService-setDebug:] method to record the XML sent and received, and to control debugging in its coders. ● Use the [GWSCoder-setDebug:] method to turn on logging during encoding/decoding.

28 Optimising ● Coder delegate methods let you override encoding/decoding of individual items. ● Service delegate methods let you override the encoding/decoding of entire requests. ● Use the GWSElement -setLiteralValue: method. ● Use a standalone GWSService instance to avoid checking the WSDL.

29 Conclusion ● At last you can easily write web service clients in Objective- C ● Your code can run on Cocoa and with GNUstep on GNU/Linux, MS-Windows, BSD etc ● You can keep it simple by ignoring everything apart from GWSService.


Download ppt "WebServices ● What are web services? ● They can be any web based services, but we are talking about WSDL here. ● Web Services Definition Language is XML."

Similar presentations


Ads by Google