wsdapi: Populate SOAP header structure.

Signed-off-by: Owen Rudge <orudge@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Owen Rudge 2018-03-19 21:46:18 +00:00 committed by Alexandre Julliard
parent 09612dd54d
commit 42d6d92d0d
1 changed files with 65 additions and 1 deletions

View File

@ -31,6 +31,54 @@ WINE_DEFAULT_DEBUG_CHANNEL(wsdapi);
#define APP_MAX_DELAY 500
static const WCHAR discoveryTo[] = {
'u','r','n',':',
's','c','h','e','m','a','s','-','x','m','l','s','o','a','p','-','o','r','g',':',
'w','s',':','2','0','0','5',':','0','4',':',
'd','i','s','c','o','v','e','r','y', 0 };
static const WCHAR actionHello[] = {
'h','t','t','p',':','/','/',
's','c','h','e','m','a','s','.','x','m','l','s','o','a','p','.','o','r','g','/',
'w','s','/','2','0','0','5','/','0','4','/',
'd','i','s','c','o','v','e','r','y','/',
'H','e','l','l','o', 0 };
static BOOL create_guid(LPWSTR buffer)
{
const WCHAR formatString[] = { 'u','r','n',':','u','u','i','d',':','%','s', 0 };
WCHAR* uuidString = NULL;
UUID uuid;
if (UuidCreate(&uuid) != RPC_S_OK)
return FALSE;
UuidToStringW(&uuid, (RPC_WSTR*)&uuidString);
if (uuidString == NULL)
return FALSE;
wsprintfW(buffer, formatString, uuidString);
RpcStringFreeW((RPC_WSTR*)&uuidString);
return TRUE;
}
static void populate_soap_header(WSD_SOAP_HEADER *header, LPCWSTR to, LPCWSTR action, LPCWSTR message_id,
WSD_APP_SEQUENCE *sequence, const WSDXML_ELEMENT *any_headers)
{
ZeroMemory(header, sizeof(WSD_SOAP_HEADER));
header->To = to;
header->Action = action;
header->MessageID = message_id;
header->AppSequence = sequence;
header->AnyHeaders = (WSDXML_ELEMENT *)any_headers;
/* TODO: Implement RelatesTo, ReplyTo, From, FaultTo */
}
static HRESULT write_and_send_message(IWSDiscoveryPublisherImpl *impl, WSD_SOAP_HEADER *header, WSDXML_ELEMENT *body_element,
struct list *discovered_namespaces, IWSDUdpAddress *remote_address, int max_initial_delay)
{
@ -72,8 +120,24 @@ HRESULT send_hello_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLON
const WSD_URI_LIST *xaddrs_list, const WSDXML_ELEMENT *hdr_any, const WSDXML_ELEMENT *ref_param_any,
const WSDXML_ELEMENT *endpoint_ref_any, const WSDXML_ELEMENT *any)
{
WSD_SOAP_HEADER soapHeader;
WSD_APP_SEQUENCE sequence;
WCHAR message_id[64];
HRESULT ret = E_OUTOFMEMORY;
sequence.InstanceId = instance_id;
sequence.MessageNumber = msg_num;
sequence.SequenceId = session_id;
if (!create_guid(message_id)) goto cleanup;
populate_soap_header(&soapHeader, discoveryTo, actionHello, message_id, &sequence, hdr_any);
/* TODO: Populate message body */
/* Write and send the message */
return write_and_send_message(impl, NULL, NULL, NULL, NULL, APP_MAX_DELAY);
ret = write_and_send_message(impl, &soapHeader, NULL, NULL, NULL, APP_MAX_DELAY);
cleanup:
return ret;
}