wsdl2h -c MetaEdit.wsdl soapcpp2 -C MetaEdit.h
![]() | soapC.c |
![]() | soapClient.c |
![]() | soapH.h |
![]() | soapStub.h |
![]() | MetaEditAPISoapBinding.nsmap |
01 #include "stdlib.h"
02 #include "string.h"
03 #include "soapH.h"
04 #include "MetaEditAPISoapBinding.nsmap"
05
06 int main()
07 {
08 struct soap meServer;
09
10 struct ns2__METype graphType;
11 struct ns1__allGoodInstancesResponse allGoodInstancesResponse;
12 struct MEOopArray *resultPtr;
13 struct ns2__MEOop graph;
14 struct ns2__METype objectType;
15 struct ns2__MEAny *props[1];
16 struct MEAnyArray propArray;
17 struct ns2__MEAny *values[1];
18 struct MEAnyArray valueArray;
19 struct ns2__MEAny area, np;
20 struct ns1__instPropsResponse instPropsResponse;
21 struct ns2__MEAny newObjectAny;
22 struct ns2__MEOop newObject;
23 struct ns1__addToGraphResponse addToGraphResponse;
24 struct ns1__diagramsResponse diagramsResponse;
25 struct ns2__MEOop diagram;
26 struct ns2__MEAny place;
27 struct ns1__addNewObjectRepForResponse addNewObjectRepForResponse;
28 struct ns2__MEAny nullAny;
29 struct ns2__MEAny textAny;
30 struct ns1__animateResponse animateResponse;
31 char *token, *next_token;
32
33 soap_init1(&meServer, SOAP_IO_KEEPALIVE);
34
35 graphType.name = "WatchFamily";
36 if(soap_call_ns1__allGoodInstances(&meServer, NULL, NULL, &graphType,
37 &allGoodInstancesResponse) != SOAP_OK) {
38 soap_print_fault(&meServer, stderr);
39 exit(1);
40 }
41 resultPtr = allGoodInstancesResponse.result;
42 if (!resultPtr->__size) exit(2); /* No WatchFamily graphs found */
43 graph = **resultPtr->__ptr;
44 objectType.name = "Note [Watch]";
45 nullAny.meType = "MENull";
46 nullAny.meValue = "";
47 props[0] = &nullAny;
48 propArray.__ptr = &props[0];
49 propArray.__size = 1;
50 textAny.meType = "Text";
51 textAny.meValue = "'A new note created by the API'";
52 values[0] = &textAny;
53 valueArray.__ptr = &values[0];
54 valueArray.__size = 1;
55 np = area = nullAny;
56 if(soap_call_ns1__instProps(&meServer, NULL, NULL, &objectType, &propArray,
57 &valueArray, &np, &area, &instPropsResponse) != SOAP_OK) {
58 soap_print_fault(&meServer, stderr);
59 exit(1);
60 }
61 newObjectAny = *instPropsResponse.result;
62 if (strcmp(newObjectAny.meType, "MEOop")) exit(3); /* Object not created */
63 token = strtok_s(newObjectAny.meValue, "_", &next_token);
64 newObject.areaID = atoi(token);
65 token = strtok_s(NULL, "", &next_token);
66 newObject.objectID = atoi(token);
67 if(soap_call_ns1__addToGraph(&meServer, NULL, NULL, &newObject, &graph,
68 &addToGraphResponse) != SOAP_OK) {
69 soap_print_fault(&meServer, stderr);
70 exit(1);
71 }
72 if(soap_call_ns1__diagrams(&meServer, NULL, NULL, &graph, &diagramsResponse)
73 != SOAP_OK) {
74 soap_print_fault(&meServer, stderr);
75 exit(1);
76 }
77 resultPtr = diagramsResponse.result;
78 if (!resultPtr->__size) exit(4); /* No existing diagrams found */
79 diagram = **resultPtr->__ptr;
80 place.meType = "Point";
81 place.meValue = "400,360";
82 if(soap_call_ns1__addNewObjectRepFor(&meServer, NULL, NULL, &diagram, &newObject,
83 0, &place, &addNewObjectRepForResponse) != SOAP_OK ) {
84 soap_print_fault(&meServer, stderr);
85 exit(1);
86 }
87 if (soap_call_ns1__animate(&meServer, NULL, NULL, &graph, &newObject,
88 &animateResponse) != SOAP_OK) {
89 soap_print_fault(&meServer, stderr);
90 exit(1);
91 }
92
93 soap_end(&meServer);
94 soap_done(&meServer);
95 return 0;
96 }Listing 4. Sample C application using the API.