The method invocation functions are used to create an invocation reference, set the parameters for the call, add any settings, such as action headers or debug parameters, and invoke the operation (which serializes the output, makes the call, gets the response, and deserializes the reply). Additional functions allow you to schedule the invocation on your run loop (recommended), set a callback to deal with the response, and add a custom serializer or deserializer.
WSMethodInvocationAddDeserializationOverride
WSMethodInvocationAddSerializationOverride
WSMethodInvocationCopyParameters
WSMethodInvocationCopyProperty
WSMethodInvocationCopySerialization
WSMethodInvocationCreate
WSMethodInvocationCreateFromSerialization
WSMethodInvocationGetTypeID
WSMethodInvocationInvoke
WSMethodInvocationScheduleWithRunLoop
WSMethodInvocationSetCallBack
WSMethodInvocationSetParameters
WSMethodInvocationSetProperty
WSMethodInvocationUnscheduleFromRunLoop
WSMethodResultIsFault
The protocol handler functions assist in the serialization and deserialization of service requests and responses. In other words, they translate between XML messages and dictionaries. These functions can be used to support either server-side or client-side web services applications. On the client side, they are not generally needed, as serialization and deserialization are handled by the method invocation, but they can be useful when this work needs to be done separately from the method invocation itself.
WSProtocolHandlerCopyFaultDocument
WSProtocolHandlerCopyProperty
WSProtocolHandlerCopyReplyDictionary
WSProtocolHandlerCopyReplyDocument
WSProtocolHandlerCopyRequestDictionary
WSProtocolHandlerCopyRequestDocument
WSProtocolHandlerCreate
WSProtocolHandlerGetTypeID
WSProtocolHandlerSetDeserializationOverride
WSProtocolHandlerSetProperty
WSProtocolHandlerSetSerializationOverride
Web Services types functions translate between WSTypes and CFTypes. Because CFTypes are determined at runtime, it isn't always possible to produce a static mapping between Core Foundation types and the corresponding serialized XML types used to interact with remote servers. What this means is that when converting between serialized XML data and deserialized CFTypes, you need to do a conversion from WSTypes to CFTypes, and vice versa.
Gets the CFType associated with a given WSType
WSGetCFTypeIDFromWSTypeID( WSTypeID typeID);
The WSTypeID
for which you need a CFTypeID
.
Returns a CFTypeID
, or 0 if not found
Returns the CFTypeID
that is associated with a given WSTypeID
. CFTypeIDs
are only valid during a particular instance of a process and should not be used as static values.
WSTypes.h
Returns the WSTypeID
associated with a given CFTypeRef
.
WSGetWSTypeIDFromCFType( CFTypeRef ref);
A CFTypeRef
object. An actual instance of a CFType must be passed.
the WSTypeID
used in serializing the object. If no WSTypeID
matches, eWSUnknownType
is returned.
Returns the WSTypeID
associated with CFTypeRef
. Because there is not a one to one mapping between CFTypeID
and WSTypesID
an actual instance of a CFType must be passed.
WSTypes.h
Specifies a callback to be made when parsing the XML in a method response.
WSMethodInvocationAddDeserializationOverride( WSMethodInvocationRef invocation, CFStringRef typeNamespace, CFStringRef typeName, WSMethodInvocationDeserializationProcPtr deserializationProc, WSClientContext *context);
The method invocation reference.
The fully resolved namespace for a specific type. For example, this field could be: CFSTR("http://www.Myserver.com/myNameSpace")
. If NULL
, the default namespace will be used.
The non-qualified type name. Note that this is the XML /name/ to be deserialized, not the name of the type. For example, if the XML is <Sharename xsi:type="xsd:string">Album-9</Sharename>
, the typeName
is Sharename
, not string
. This parameter must not be NULL
.
A ProcPtr
to the callback to be called to perform the deserialization.
A pointer to a WSClientContext
. The structure will be copied.
Specifies a callback to be made when parsing an XML method response. Used to deserialize types the default deserializer does not handle. The callback should return a CFTypeRef
containing the deserialized object value. If the callback returns NULL
, the default deserializer is used.
WSMethodInvocation.h
Specifies a callback to be made when creating the XML for an method invocation.
WSMethodInvocationAddSerializationOverride( WSMethodInvocationRef invocation, CFTypeID objType, WSMethodInvocationSerializationProcPtr serializationProc, WSClientContext *context);
The invocation currently being serialized
The CFTypeID
of the object to serialize
The ProcPtr
to the callback
A pointer to a WSClientContext
. The structure will be copied.
Specifies a callback which will be called to produce the XML that represents the serialization of a given type ref. See WSTypes.h
for a list of CFTypes
for which there are default serializers. If your callback returns NULL
, the default serializer will be used.
WSMethodInvocation.h
Creates a copy of the parameters dictionary and sets the order in an array.
WSMethodInvocationCopyParameters( WSMethodInvocationRef invocation, CFArrayRef *parameterOrder); /* can be NULL */
the invocation
a pointer to a CFArray
which will will receive the names, in their specified order, of the input parameter values. This parameter may be NULL
.
a CFDictionaryRef
Copies the parameters from the invocation. The resulting dictionary contains the parameter dictionary. The parameterOrder
output parameter, if not NULL
, will contain the order used to serialize the parameters.
WSMethodInvocation.h
Creates a copy of a named property of the invocation reference.
WSMethodInvocationCopyProperty( WSMethodInvocationRef invocation, CFStringRef propertyName);
The method invocation.
The name of the property to retrieve.
the CFTypeRef
value of the property, or NULL
if the property was not specified.
Returns a property from an invocation. If the result is NULL
, the property doesn't exist. Being a copy call, you must release the result.
WSMethodInvocation.h
Creates an XML serialization of a method invocation.
WSMethodInvocationCopySerialization( WSMethodInvocationRef invocation);
The invocation to serialize.
A CFDataRef
of the serialized XML method invocation.
Creates a serialized version of the method invocation which can be used at a later time.
WSMethodInvocation.h
Creates a reference to a method invocation, containing the URL of the service, the operation name, and the protocol.
WSMethodInvocationCreate( CFURLRef url, CFStringRef methodName, CFStringRef protocol);
The endpoint of the service.
The name of the operation to be called.
A string defined above that determines the type of invocation object to create. There are string constants for XML-RPC, SOAP 1.1, or SOAP 1.2. Other protocols are not recognized.
A WSMethodInvocationRef
object that can be passed to WSMethodInvocationInvoke
or scheduled with a run loop.
Creates a web services method invocation object. This is the fundamental object used when passing method parameters or settings, callbacks, or custom serializers or deserializers. This object may be executed synchronously using WSMethodInvocationInvoke
or scheduled on a run loop for asynchronous execution using WSMethodInvocationScheduleWithRunLoop
.
WSMethodInvocation.h
Creates a method invocation object from an XML serialization.
WSMethodInvocationCreateFromSerialization( CFDataRef contract);
The result of a previously serialized WSMethodInvocationRef
.
A WSMethodInvocationRef
object that can be passed to WSMethodInvocationInvoke
or scheduled with a run loop.
Creates a web services method invocation object from a previously serialized contract. You can use this with a serialization returned from WSMethodInvocationCopySerialization
.
WSMethodInvocation.h
Returns the type ID of the current method invocation.
WSMethodInvocationGetTypeID( void);
A CFTypeID.
Returns the ID of the current method invocation. You should call this immediately after creating the invocation reference.
WSMethodInvocation.h
Invokes an web services operation synchronously.
WSMethodInvocationInvoke( WSMethodInvocationRef invocation);
The method invocation reference.
a CFDictionaryRef
containing the result of the execution or a fault, and optional debug information.
Executes the invocation synchronously. If the call was successful, the result contains the result of the invocation. If the invocation failed for any reason, including out of memory or invalid parameter errors, then the result contains a fault structure. You must release the result when you are done with it. To execute the invocation asynchronously (recommended), use WSMethodInvocationScheduleWithRunLoop.
WSMethodInvocation.h
Schedule a method invocation for asynchronous execution on a run loop.
WSMethodInvocationScheduleWithRunLoop( WSMethodInvocationRef invocation, CFRunLoopRef runLoop, CFStringRef runLoopMode);
The method invocation reference.
The run loop upon which to schedule the invocation.
The run loop mode.
Schedules the invocation to execute on the run loop. You must also set a callback to handle the response, using WSMethodInvocationSetCallBack
. This is the recommended way to invoke web services, due to the unpredictable network delays inherent in such operations.
WSMethodInvocation.h
Set a callback to handle the response to an asynchronous method invocation.
WSMethodInvocationSetCallBack( WSMethodInvocationRef invocation, WSMethodInvocationCallBackProcPtr clientCB, WSClientContext *context);
The method invocation reference.
A ProcPtr
to be called when the invocation completes.
A pointer to a WSClientContext
. The structure will be copied.
Sets the callback to handle the response for an asynchronous method invocation. The callback is passed a reference to the method invocation just completed, a pointer to private data, and a dictionary that contains the return values for the operation or a fault structure. Test for a fault using WSMethodResultIsFault
. The callback parses the method response dictionary, which contains the deserialized return data, and may contain the raw XML of the return message as well. The callback is responsible for releasing the result ref.
Call with a clientCB
and context of NULL
to clear the invocation callback.
WSMethodInvocation.h
Set the parameter names, types, and order for a method invocation.
WSMethodInvocationSetParameters( WSMethodInvocationRef invocation, CFDictionaryRef parameters, CFArrayRef parameterOrder); /* can be NULL */
The invocation reference.
A CFDictionaryRef
of CFString
keys and CFTypeRef
values.
A CFArrayRef
of CFString
parameter names in order for XML-RPC.
Sets the parameters for a method invocation. The parameters dictionary should contain the names and types of the parameters. The parameter order array should contain the names of the parameters in the order they should be passed. The parameterOrder
may be NULL
, in which case the order of the parameters is undefined. If the parameters dictionary contains more or fewer parameters than are specified by the order, the behavior is undefined.
WSMethodInvocation.h
Sets a named property of the method invocation.
WSMethodInvocationSetProperty( WSMethodInvocationRef invocation, CFStringRef propertyName, CFTypeRef propertyValue);
The method invocation reference.
A CFStringRef
name of the property to set.
A CFTypeRef
containing the new property value.
Adds properties to a method invocation. These properties can be user-defined or one of the declared properties, which may alter the behavior of the invocation. Declared properties start with the string "kWS," for example kWSHTTPFollowsRedirects
. Use these properties to add SOAP action headers or to set debug properties, such as including the raw XML in the method response dictionary. Properties are serialized along with the contract, so you should avoid using raw pointers in a CFNumber
, for example.
WSMethodInvocation.h
Unschedules a method invocation from a run loop.
WSMethodInvocationUnscheduleFromRunLoop( WSMethodInvocationRef invocation, CFRunLoopRef runLoop, CFStringRef runLoopMode);
The method invocation reeference.
The run loop from which to unschedule the invocation.
The run loop mode.
Unschedules the invocation from a given run loop and mode. If the invocation has not yet completed, its callback will not be called.
WSMethodInvocation.h
Tests a method result dictionary for a fault condition.
WSMethodResultIsFault (CFDictionaryRef methodResult);
A method result dictionary.
A boolean TRUE if the result contains a fault condition.
If the result is a fault, look in the kWSFaultCode
, kWSFaultString
, and kWSFaultExtra
fields of the dictionary. If not a fault, kWSMethodInvocationResult
will contain the result of the execution. If debugging information was requested, it will be available in the dictionary as well.
WSMethodInvocation.h
Creates a Fault XML response for a given WSProtocolHandler and fault details dictionary.
WSProtocolHandlerCopyFaultDocument( WSProtocolHandlerRef ref, CFDictionaryRef methodContext, CFDictionaryRef faultDict);
A WSProtocolHandlerRef
, as created by WSProtocolHandlerCreate
.
The CFDictionary containing the context for this method call, as returned by WSProtocolHandlerParseRequest
.
A CFDictionary
containing the fault information. See WSMethodInvocation.h
for valid keys.
A CFDataRef
containing the XML fault.
This function creates a Fault XML response for a given WSProtocolHandlerRef
and fault details dictionary. The fault dictionary contains one or more of kWSFaultString
, kWSFaultCode
or kWSFaultExtra
, as per WSMethodInvocation.h.
WSProtocolHandler.h
Returns a copy of a property from a protocol handler reference.
WSProtocolHandlerCopyProperty( WSProtocolHandlerRef ref, CFStringRef propertyName);
A WSProtocolHandlerRef
, as created by WSProtocolHandlerCreate
.
The name of the property to copy.
The CFTypeRef
value of the property, or NULL
if the specified property does not exist.
Returns a property from a protocol handler. If the result is NULL
, the property doesn't exist. Since this is a Copy call, you must release the result.
WSProtocolHandler.h
Parses an incoming XML document as if it were the reply of a method.
WSProtocolHandlerCopyReplyDictionary( WSProtocolHandlerRef ref, CFStringRef methodName, CFDataRef data);
A WSProtocolHandlerRef
, as created by WSProtocolHandlerCreate
.
The method name to treat the XML file as a result of.
A CFDataRef
of the XML document to parse
A CFDictionary
, as returned by WSMethodInvocationInvoke
.
Parse an incoming XML document as if it were the reply of a method. The results are the same as the WSMethodInvocationInvoke
response; the reply could be a fault. If there was a parse error, NULL
is returned. Protocol specific additions, such as kWSSOAPMessageHeaders
, may also be present in the dictionary. The caller must release the resulting dictionary.
WSProtocolHandler.h
Creates a Reply XML document for a given WS ProtocolHandler and context dictionary.
WSProtocolHandlerCopyReplyDocument( WSProtocolHandlerRef ref, CFDictionaryRef methodContext, CFTypeRef resultValue);
The WSProtocolHandler to respond.
The CFDictionary
containing the context for this method call, as returned by WSProtocolHandlerParseRequest
.
A CFTypeRef
representing the data to be serialized.
A CFDataRef
containing the XML response.
This function creates a Reply XML document for a given WSProtocolHandler
and context dictionary. Protocol specific addtions (for example, kWSSOAPMessageHeaders
) may also be present in the dictionary.
WSProtocolHandler.h
Parses an incoming XML document for the method name and parameters.
WSProtocolHandlerCopyRequestDictionary( WSProtocolHandlerRef ref, CFDataRef data);
The protocol handler to use.
The XML document to parse.
A CFDictionary
.
This function parses an incoming XML document for the method name and parameters. The results are in a dictionory as kWSMethodName
(a CFString
), kWSMethodParameters
(a CFDictionary
), and kWSMethodParameterOrder
(a CFArray
). If a parse error occurred, NULL
is returned. Protocol specific additions (for example, kWSSOAPMessageHeaders
) may also be present in the dictionary. The dictionary returned also represents the context with which XML reply documents are created (see WSProtocolHandlerCreateReply
). The caller must release the resulting dictionary. Note that the returned dictionary should be used as an input parameter for other WSProtocol
functions that require a context dictionary parameter.
WSProtocolHandler.h
Creates an XML request for a given WSProtocolHandler
and parameter list.
WSProtocolHandlerCopyRequestDocument( WSProtocolHandlerRef ref, CFStringRef methodName, CFDictionaryRef methodParams, CFArrayRef methodParamOrder, CFDictionaryRef methodExtras);
The WSProtocolHandlerRef
.
A CFString
of the method name to call.
A CFDictionary
containing the parameters to send.
A CFArray
, which, if not NULL
, specifies the order of the parameters in the CFDictionary
.
A CFDictionary
, which, if not NULL
, contains additional information for the protocol (for example, kWSSoapMessageHeaders
).
A CFDataRef
.
This function creates an XML request for a given WSProtocolHandler
and parameter list. This is the request sent to a server.
WSProtocolHandler.h
Creates a WSProtocolHandlerRef
for use in translating an XML document.
WSProtocolHandlerCreate( CFAllocatorRef allocator, CFStringRef protocol);
A CFAllocatorRef
used to allocate the protocol handler.
A constant string, defined in WSMethodInvocation.h
, that determines the type of implementation to create (XML-RPC vs. SOAP).
A WSProtocolHandlerRef
; NULL
if a parse error occurred.
This function creates a WSProtocolHandlerRef
for use in translating an XML document. A protocol handler translates dictionaries into web services requests. It is created with a string specifying the protocol (XML-RPC or SOAP) and can be modified by setting various properties. It should be noted that the parser can be re-used for multiple parses.
WSProtocolHandler.h
Returns a CFTypeID
for the current WSProtocolHandlerRef
.
WSProtocolHandlerGetTypeID( void);
A CFTypeID
.
Returns the CFTypeID
of the opaque WSProtocolHandlerRef
most recently created by WSProtocolHandlerCreate
. CFTypeIDs
are only valid during a particular instance of a process and should not be used as static values.
WSProtocolHandler.h
Specifies a callback to be made when parsing an XML method response.
WSProtocolHandlerSetDeserializationOverride( WSProtocolHandlerRef protocol, CFStringRef typeNamespace, CFStringRef typeName, WSProtocolHandlerDeserializationProcPtr deserializationProc, WSClientContext *context);
The ProtocolHandlerRef
.
The fully resolved namespace for a specific type. If NULL
, the default namespace will be used. For example, this field could be: CFSTR("http://www.w3.org/2001/XMLSchema-instance")
.
The non-qualified type name. This parameter must not be NULL
.
A ProcPtr
to be called to perform the deserialization.
A pointer to a WSClientContext
. The structure will be copied.
This function specifies a callback to be made when parsing an XML method response. The callback is passed a reference to the protocol element currently being executed, the root of the response parse tree, the current node being deserialized, and a pointer to private data. The return result should be a valid CFTypeRef
object, which will be released by the caller. If the callback returns NULL
, the default deserializer will be used.
WSProtocolHandler.h
Sets a property in a specified protocol handler.
WSProtocolHandlerSetProperty( WSProtocolHandlerRef ref, CFStringRef propertyName, CFTypeRef propertyValue);
The protocol handler.
The name of the property to set.
The value of the property to set.
This function sets the value of a named property in a method implementation.
WSProtocolHandler.h
Specifies a callback which will be called to produce the XML that represents the serialization of a given type ref.
WSProtocolHandlerSetSerializationOverride( WSProtocolHandlerRef protocol, CFTypeID objType, WSProtocolHandlerSerializationProcPtr serializationProc, WSClientContext *context);
The protocol which is to be executed.
The CFTypeID
of the object to be serialized.
The serialization callback that will do the work.
A pointer to a WSClientContext
. The structure will be copied.
This function specifies a callback which will be called to produce the XML that represents the serialization of a given type ref. This callback is called whenever a type has the given CFTypeID
. The callback should return an XML snippet that will be understood by the server as a correct serialization for a given type. If the callback returns NULL, the default serializer is used. For SOAP serializations, the parameter key (element name) is not part of the callback; it will be substituded for all occurances of "%@" in the returned string. If your callback returns NULL
, the default serializer will be used.
WSProtocolHandler.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)