annotate GEMBASSY-1.0.3/gsoap/custom/README.txt @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2 OVERVIEW
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 This directory contains custom serializers for common data types.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
5
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
6 CONTENTS
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
7
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
8 Custom serializers replace the soapcpp2-generated serialization routines.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
9 See the notes in the source files on specific usage.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
10
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
11 The following serializers are available:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
12
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
13 long_double.* Serializes long double (extended double) type
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
14 struct_tm.* Serializes <time.h> struct tm
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
15 struct_timeval.* Serializes struct timeval (precision in usec)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
16 duration.* Serializes LONG64 values as xsd:duration
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
17
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
18 USAGE
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
19
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
20 To use a custom serializer add an import statement to your gSOAP header file:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
21
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
22 #import "struct_tm.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
23
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
24 This replaces time_t for xsd__dateTime by struct tm. You can use xsd__dateTime
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
25 as XML elements and attributes:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
26
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
27 struct ns__example
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
28 { @xsd__dateTime start; // attribute
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
29 xsd__dateTime end; // element
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30 };
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32 Then compile with soapcpp2 and cc and link struct_tm.c
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 HOW TO MODIFY TYPEMAP.DAT TO AUTOMATE THE MAPPING TO A CUSTOM TYPE WITH WSDL2H
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36 The mapping is specified in typemap.dat as follows:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38 xsd__dateTime = #import "custom/struct_tm.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40 which maps xsd:dateTime to struct tm when wsdl2h is applied to a WSDL.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42 xsd__decimal = #import "custom/long_double.h" | long double
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44 this maps xsd:decimal to long double (the column after | specifies usage).
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46 IMPLEMENTING YOUR OWN CUSTOM SERIALIZERS
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48 To build your own custom serializers: a custom serializer is typically declared
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49 in the imported file as follows
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51 extern typedef Type X;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53 To implement custom serializers you should implement the following routines:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55 void soap_default_X(struct soap*, X*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 sets default values for X
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57 void soap_serialize_X(struct soap*, const X*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 analyzes X for id-ref serialization (maybe empty)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59 int soap_out_X(struct soap*, const char *tag, int id, const X*, const char *type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 emits X in XML as <tag xsi:type=type> (type is optional)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61 X *soap_in_X(struct soap*, const char *tag, X*, const char *type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62 parses X from XML as <tag xsi:type=type>
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64 To support XML attribute serialization, you should also define:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 int soap_s2X(struct soap*, const char *value, X*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67 converts string to X and returns SOAP_OK
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68 const char *soap_X2s(struct soap*, X);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 converts X to string (or NULL when error)