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
--------------------------------------------------------------------------------
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
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.
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
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
--------------------------------------------------------------------------------
37
const char *server = "https://uddi.xmethods.net/publish";
39
const char *userid = "..."; // user ID to access UDDI server
40
const char *passwd = "..."; // password to access UDDI server
42
int main(int argc, char **argv)
44
// Create a gSOAP context
45
struct soap *soap = soap_new();
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))
50
soap_print_fault(soap, stderr);
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);
58
// Check if authorized
61
soap_print_fault(soap, stderr);
65
// Authorization info provided by server for this session
66
char *authInfo = authToken->authInfo;
68
// Step 2: Create a tModel for the WSDL to be published
70
tModel.soap_default(soap);
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";
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";
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);
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";
106
// Omit identifier bag
107
tModel.identifierBag = NULL;
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";
117
tModel.authorizedName = "...";
118
tModel.operator_ = "...";
119
tModel.tModelKey = "...";
122
uddi2__save_USCOREtModel save_tModel(soap, tModel);
123
uddi2__tModelDetail *tModelDetail = save_tModel.send(server, authInfo);
125
// Step 3: Create a new service to be published
126
uddi2__businessService service;
127
service.soap_default(soap);
129
// Service name is the tModel name (XMethods)
130
service.name.push_back(tModel.name);
132
// Add two description elements to the service
133
service.description.push_back(description + 4);
134
service.description.push_back(description + 5);
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 = "...";
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);
155
service.categoryBag = NULL;
156
service.serviceKey = "...";
157
service.businessKey = "...";
160
uddi2__save_USCOREservice save_service(soap, service);
161
uddi2__serviceDetail *serviceDetail = save_service.send(server, authInfo);
163
// Step 4: Discard authorization token
164
uddi2__discard_USCOREauthToken discard_authToken(soap, authInfo);
165
uddi2__dispositionReport *dispositionReport = discard_authToken.send(server);
167
// Remove deserialized objects
170
// Remove temporary data
173
// Detach and free context