~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/gsoap-linux-2.7/uddi2/.svn/text-base/example3.cpp.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 
3
 
example3.cpp
4
 
 
5
 
Example UDDI V2 Client
6
 
 
7
 
--------------------------------------------------------------------------------
8
 
gSOAP XML Web services tools
9
 
Copyright (C) 2004-2005, Robert van Engelen, Genivia Inc. All Rights Reserved.
10
 
This software is released under one of the following two licenses:
11
 
GPL or Genivia's license for commercial use.
12
 
--------------------------------------------------------------------------------
13
 
GPL license.
14
 
 
15
 
This program is free software; you can redistribute it and/or modify it under
16
 
the terms of the GNU General Public License as published by the Free Software
17
 
Foundation; either version 2 of the License, or (at your option) any later
18
 
version.
19
 
 
20
 
This program is distributed in the hope that it will be useful, but WITHOUT ANY
21
 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
22
 
PARTICULAR PURPOSE. See the GNU General Public License for more details.
23
 
 
24
 
You should have received a copy of the GNU General Public License along with
25
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
26
 
Place, Suite 330, Boston, MA 02111-1307 USA
27
 
 
28
 
Author contact information:
29
 
engelen@genivia.com / engelen@acm.org
30
 
--------------------------------------------------------------------------------
31
 
A commercial use license is available from Genivia, Inc., contact@genivia.com
32
 
--------------------------------------------------------------------------------
33
 
*/
34
 
 
35
 
#include "pubH.h"
36
 
 
37
 
const char *server = "https://uddi.xmethods.net/publish";
38
 
 
39
 
const char *userid = "..."; // user ID to access UDDI server
40
 
const char *passwd = "..."; // password to access UDDI server
41
 
 
42
 
int main(int argc, char **argv)
43
 
44
 
  // Create a gSOAP context
45
 
  struct soap *soap = soap_new();
46
 
 
47
 
  // Setup SSL context (optional) to verify server's credentials
48
 
  if (soap_ssl_client_context(soap, SOAP_SSL_DEFAULT, NULL, NULL, "cacerts.pem", NULL, NULL))
49
 
  { 
50
 
    soap_print_fault(soap, stderr);
51
 
    exit(1);
52
 
  }
53
 
 
54
 
  // Step 1: Get an authorization token from the UDDI server
55
 
  uddi2__get_USCOREauthToken get_authToken(soap, userid, passwd);
56
 
  uddi2__authToken *authToken = get_authToken.send(server);
57
 
 
58
 
  // Check if authorized
59
 
  if (!authToken)
60
 
  {
61
 
    soap_print_fault(soap, stderr);
62
 
    exit(1);
63
 
  }
64
 
 
65
 
  // Authorization info provided by server for this session
66
 
  char *authInfo = authToken->authInfo;
67
 
 
68
 
  // Step 2: Create a tModel for the WSDL to be published
69
 
  uddi2__tModel tModel;
70
 
  tModel.soap_default(soap);
71
 
 
72
 
  // Create the tModel and service name
73
 
  tModel.name = soap_new_uddi2__name(soap, -1);
74
 
  tModel.name->__item = "...";
75
 
  tModel.name->xml__lang_ = "en";
76
 
 
77
 
  // Create XMethods description elements (see http://www.xmethods.net/ve2/UDDI.po)
78
 
  uddi2__description *description = soap_new_uddi2__description(soap, 6);
79
 
  description[0].__item = "SHORT DESCRIPTION: ...";
80
 
  description[0].xml__lang_ = "en";
81
 
  description[1].__item = "SHORT DESCRIPTION: ...";
82
 
  description[1].xml__lang_ = "en";
83
 
  description[2].__item = "USAGE NOTES: ...";
84
 
  description[2].xml__lang_ = "en";
85
 
  description[3].__item = "HOMEPAGE URL: ...";
86
 
  description[3].xml__lang_ = "en";
87
 
  description[4].__item = "CONTACT EMAIL: ...";
88
 
  description[4].xml__lang_ = "en";
89
 
  description[5].__item = "IMPLEMENTATION: ...";
90
 
  description[5].xml__lang_ = "en";
91
 
 
92
 
  // Add the four description elements to the tModel
93
 
  tModel.description.push_back(description + 0);
94
 
  tModel.description.push_back(description + 1);
95
 
  tModel.description.push_back(description + 2);
96
 
  tModel.description.push_back(description + 4);
97
 
 
98
 
  // Add an overviewDoc element with description and overviewURL
99
 
  tModel.overviewDoc = soap_new_uddi2__overviewDoc(soap, -1);
100
 
  tModel.overviewDoc->soap_default(soap);
101
 
  tModel.overviewDoc->description.push_back(soap_new_uddi2__description(soap, -1));
102
 
  tModel.overviewDoc->description[0]->__item = "WSDL source document";
103
 
  tModel.overviewDoc->description[0]->xml__lang_ = "en";
104
 
  tModel.overviewDoc->overviewURL = "http://.../my.wsdl#bindingName";
105
 
 
106
 
  // Omit identifier bag
107
 
  tModel.identifierBag = NULL;
108
 
 
109
 
  // Add a category with a WSDL-specific keyedReference
110
 
  tModel.categoryBag = soap_new_uddi2__categoryBag(soap, -1);
111
 
  tModel.categoryBag->soap_default(soap);
112
 
  tModel.categoryBag->keyedReference.push_back(soap_new_uddi2__keyedReference(soap, -1));
113
 
  tModel.categoryBag->keyedReference[0]->tModelKey = "...";
114
 
  tModel.categoryBag->keyedReference[0]->keyName = "uddi-org:types";
115
 
  tModel.categoryBag->keyedReference[0]->keyValue = "wsdlSpec";
116
 
 
117
 
  tModel.authorizedName = "...";
118
 
  tModel.operator_ = "...";
119
 
  tModel.tModelKey = "...";
120
 
 
121
 
  // Save the tModel
122
 
  uddi2__save_USCOREtModel save_tModel(soap, tModel);
123
 
  uddi2__tModelDetail *tModelDetail = save_tModel.send(server, authInfo);
124
 
 
125
 
  // Step 3: Create a new service to be published
126
 
  uddi2__businessService service;
127
 
  service.soap_default(soap);
128
 
 
129
 
  // Service name is the tModel name (XMethods)
130
 
  service.name.push_back(tModel.name);
131
 
 
132
 
  // Add two description elements to the service
133
 
  service.description.push_back(description + 4);
134
 
  service.description.push_back(description + 5);
135
 
 
136
 
  // Create binding template
137
 
  uddi2__bindingTemplate bindingTemplate;
138
 
  bindingTemplate.soap_default(soap);
139
 
  bindingTemplate.tModelInstanceDetails = soap_new_uddi2__tModelInstanceDetails(soap, -1);
140
 
  bindingTemplate.tModelInstanceDetails->tModelInstanceInfo.push_back(soap_new_uddi2__tModelInstanceInfo(soap, -1));
141
 
  bindingTemplate.tModelInstanceDetails->tModelInstanceInfo[0]->instanceDetails = NULL;
142
 
  bindingTemplate.tModelInstanceDetails->tModelInstanceInfo[0]->tModelKey = tModel.tModelKey;
143
 
  bindingTemplate.accessPoint = soap_new_uddi2__accessPoint(soap, -1);
144
 
  bindingTemplate.accessPoint->__item = "...";
145
 
  bindingTemplate.accessPoint->URLType = uddi2__URLType__http;
146
 
  bindingTemplate.hostingRedirector = NULL;
147
 
  bindingTemplate.serviceKey = "...";
148
 
  bindingTemplate.bindingKey = "...";
149
 
 
150
 
  // Add binding Template to service
151
 
  service.bindingTemplates = soap_new_uddi2__bindingTemplates(soap, -1);
152
 
  service.bindingTemplates->soap_default(soap);
153
 
  service.bindingTemplates->bindingTemplate.push_back(&bindingTemplate);
154
 
 
155
 
  service.categoryBag = NULL;
156
 
  service.serviceKey = "...";
157
 
  service.businessKey = "...";
158
 
 
159
 
  // Save the service
160
 
  uddi2__save_USCOREservice save_service(soap, service);
161
 
  uddi2__serviceDetail *serviceDetail = save_service.send(server, authInfo);
162
 
 
163
 
  // Step 4: Discard authorization token
164
 
  uddi2__discard_USCOREauthToken discard_authToken(soap, authInfo);
165
 
  uddi2__dispositionReport *dispositionReport = discard_authToken.send(server);
166
 
 
167
 
  // Remove deserialized objects
168
 
  soap_destroy(soap);
169
 
 
170
 
  // Remove temporary data
171
 
  soap_end(soap);
172
 
 
173
 
  // Detach and free context
174
 
  soap_done(soap);
175
 
  free(soap);
176
 
 
177
 
  return 0;
178
 
}