From: Owen Rudge Subject: [PATCH 3/7] wsdapi: Populate SOAP header structure. Message-Id: Date: Tue, 21 Nov 2017 22:42:46 +0000 Signed-off-by: Owen Rudge --- dlls/wsdapi/Makefile.in | 2 +- dlls/wsdapi/soap.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/dlls/wsdapi/Makefile.in b/dlls/wsdapi/Makefile.in index 155d004f4a..2e7c448125 100644 --- a/dlls/wsdapi/Makefile.in +++ b/dlls/wsdapi/Makefile.in @@ -1,6 +1,6 @@ MODULE = wsdapi.dll IMPORTLIB = wsdapi -IMPORTS = user32 ws2_32 +IMPORTS = rpcrt4 user32 ws2_32 C_SRCS = \ address.c \ diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c index 8a7a8f5226..f8957e1349 100644 --- a/dlls/wsdapi/soap.c +++ b/dlls/wsdapi/soap.c @@ -28,11 +28,74 @@ WINE_DEFAULT_DEBUG_CHANNEL(wsdapi); +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; +} + +void populate_soap_header(WSD_SOAP_HEADER *header, LPCWSTR to, LPCWSTR action, LPCWSTR messageId, WSD_APP_SEQUENCE *sequence, + const WSDXML_ELEMENT *anyHeaders) +{ + ZeroMemory(header, sizeof(WSD_SOAP_HEADER)); + + header->To = to; + header->Action = action; + header->MessageID = messageId; + header->AppSequence = sequence; + header->AnyHeaders = (WSDXML_ELEMENT *)anyHeaders; + + /* TODO: Implement RelatesTo, ReplyTo, From, FaultTo */ +} + HRESULT send_hello_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR pszId, ULONGLONG ullMetadataVersion, ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, LPCWSTR pszSessionId, const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList, const WSD_URI_LIST *pXAddrsList, const WSDXML_ELEMENT *pHeaderAny, const WSDXML_ELEMENT *pReferenceParameterAny, const WSDXML_ELEMENT *pEndpointReferenceAny, const WSDXML_ELEMENT *pAny) { + WSD_SOAP_HEADER soapHeader; + WSD_APP_SEQUENCE sequence; + WCHAR messageId[64]; + HRESULT ret = E_NOTIMPL; + FIXME("stub\n"); - return E_NOTIMPL; + + sequence.InstanceId = ullInstanceId; + sequence.MessageNumber = ullMessageNumber; + sequence.SequenceId = pszSessionId; + + if (!create_guid(messageId)) goto cleanup; + + populate_soap_header(&soapHeader, discoveryTo, actionHello, messageId, &sequence, pHeaderAny); + +cleanup: + return ret; }