// Get feeds from a given Url through WWSAPI
EXPORT WCHAR* GetFeeds(WCHAR* szUrl, int cbResults) {
WCHAR* temp = NULL;
WS_HEAP* heap = NULL;
WCHAR retval[MAX_SIZE]; // 128Kb (It should be enough to avoid WS_E_QUOTA_EXCEEDED error)
WS_ERROR* error = NULL;
ULONG propertiesCount = 0;
WS_SERVICE_PROXY* proxy = NULL;
WS_CHANNEL_PROPERTY channelProps[2];
WS_STRING serviceUrl = WS_STRING_VALUE(L"http://localhost/DemoSvc/RSSFeedService.asmx");
WS_ENDPOINT_ADDRESS endpoint = { serviceUrl};
WS_ENVELOPE_VERSION soapVersion = WS_ENVELOPE_VERSION_SOAP_1_1; // Our Webservice is WsiProfiles.BasicProfile1_1 compliant
WS_ADDRESSING_VERSION addressingVersion = WS_ADDRESSING_VERSION_TRANSPORT;
// Set channel's properties
channelProps[propertiesCount].id = WS_CHANNEL_PROPERTY_ENVELOPE_VERSION;
channelProps[propertiesCount].value = &soapVersion;
channelProps[propertiesCount].valueSize = sizeof(soapVersion);
propertiesCount++;
// Set addressing's properties
channelProps[propertiesCount].id = WS_CHANNEL_PROPERTY_ADDRESSING_VERSION;
channelProps[propertiesCount].value = &addressingVersion;
channelProps[propertiesCount].valueSize = sizeof(addressingVersion);
propertiesCount++;
// Can we create an WsError and WsHeap objects?
if (SUCCEEDED(WsCreateError(NULL, NULL, &error)) && SUCCEEDED(WsCreateHeap(MAX_SIZE, TRIM_SIZE, NULL, NULL, &heap, error))) {
// Can we create a proxy based on the service?
if (SUCCEEDED(WsCreateServiceProxy(WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL, NULL,
channelProps, propertiesCount, &proxy, error))) {
// Can we open the proxy object?
if (SUCCEEDED(WsOpenServiceProxy(proxy, &endpoint, NULL, error))) {
// If we're able to invoke the service then copy the results to another variable because if
// we don't we lose the response after freeing the heap
if (SUCCEEDED(RSSFeedServiceSoap12_RetrieveFeeds(proxy, szUrl, cbResults, &temp, heap, NULL, NULL, NULL, error)))
wcscpy_s(retval, temp);
}
}
}
// Deallocate and free resources
if (error != NULL)
WsFreeError(error);
if (proxy != NULL) {
WsCloseServiceProxy(proxy, NULL, error);
WsFreeServiceProxy(proxy);
}
if (heap != NULL)
WsFreeHeap(heap);
return retval;
}