From 86515b390eace818af0897dce0fd943639c66801 Mon Sep 17 00:00:00 2001 From: Owen Rudge Date: Tue, 17 Apr 2018 23:04:49 +0100 Subject: [PATCH] wsdapi: Create Body and Hello elements in Hello message. Signed-off-by: Owen Rudge Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/wsdapi/soap.c | 39 ++++++++++++++++++++++++++++++++++----- dlls/wsdapi/tests/discovery.c | 6 ++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c index 96efefdbba7..a2a4223bef9 100644 --- a/dlls/wsdapi/soap.c +++ b/dlls/wsdapi/soap.c @@ -73,6 +73,8 @@ static const WCHAR instanceIdString[] = { 'I','n','s','t','a','n','c','e','I','d static const WCHAR messageNumberString[] = { 'M','e','s','s','a','g','e','N','u','m','b','e','r', 0 }; static const WCHAR sequenceIdString[] = { 'S','e','q','u','e','n','c','e','I','d', 0 }; static const WCHAR emptyString[] = { 0 }; +static const WCHAR bodyString[] = { 'B','o','d','y', 0 }; +static const WCHAR helloString[] = { 'H','e','l','l','o', 0 }; struct discovered_namespace { @@ -732,6 +734,10 @@ static HRESULT create_soap_envelope(IWSDXMLContext *xml_context, WSD_SOAP_HEADER ret = write_xml_element(header_element, writer); if (FAILED(ret)) goto cleanup; + /* Write the body */ + ret = write_xml_element(body_element, writer); + if (FAILED(ret)) goto cleanup; + ret = WsWriteEndElement(writer, NULL); if (FAILED(ret)) goto cleanup; @@ -774,7 +780,7 @@ static HRESULT write_and_send_message(IWSDiscoveryPublisherImpl *impl, WSD_SOAP_ char *full_xml; HRESULT ret; - ret = create_soap_envelope(impl->xmlContext, header, NULL, &heap, &xml, &xml_length, discovered_namespaces); + ret = create_soap_envelope(impl->xmlContext, header, body_element, &heap, &xml, &xml_length, discovered_namespaces); if (ret != S_OK) return ret; /* Prefix the XML header */ @@ -812,7 +818,9 @@ 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) { + WSDXML_ELEMENT *body_element = NULL, *hello_element; struct list *discoveredNamespaces = NULL; + WSDXML_NAME *body_name = NULL; WSD_SOAP_HEADER soapHeader; WSD_APP_SEQUENCE sequence; WCHAR message_id[64]; @@ -822,21 +830,42 @@ HRESULT send_hello_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLON sequence.MessageNumber = msg_num; sequence.SequenceId = session_id; - if (!create_guid(message_id)) goto cleanup; + if (!create_guid(message_id)) goto failed; discoveredNamespaces = WSDAllocateLinkedMemory(NULL, sizeof(struct list)); - if (!discoveredNamespaces) goto cleanup; + if (!discoveredNamespaces) goto failed; list_init(discoveredNamespaces); populate_soap_header(&soapHeader, discoveryTo, actionHello, message_id, &sequence, hdr_any); - /* TODO: Populate message body */ + ret = IWSDXMLContext_AddNameToNamespace(impl->xmlContext, envelopeNsUri, bodyString, &body_name); + if (FAILED(ret)) goto cleanup; + + /* , */ + ret = WSDXMLBuildAnyForSingleElement(body_name, NULL, &body_element); + if (FAILED(ret)) goto cleanup; + + ret = add_child_element(impl->xmlContext, body_element, discoveryNsUri, helloString, NULL, &hello_element); + if (FAILED(ret)) goto cleanup; + + /* Write any body elements */ + if (any != NULL) + { + ret = duplicate_element(hello_element, any, discoveredNamespaces); + if (FAILED(ret)) goto cleanup; + } /* Write and send the message */ - ret = write_and_send_message(impl, &soapHeader, NULL, discoveredNamespaces, NULL, APP_MAX_DELAY); + ret = write_and_send_message(impl, &soapHeader, body_element, discoveredNamespaces, NULL, APP_MAX_DELAY); + goto cleanup; + +failed: + ret = E_OUTOFMEMORY; cleanup: + WSDFreeLinkedMemory(body_name); + WSDFreeLinkedMemory(body_element); WSDFreeLinkedMemory(discoveredNamespaces); return ret; diff --git a/dlls/wsdapi/tests/discovery.c b/dlls/wsdapi/tests/discovery.c index 20d344299f7..06bde897218 100644 --- a/dlls/wsdapi/tests/discovery.c +++ b/dlls/wsdapi/tests/discovery.c @@ -507,7 +507,7 @@ static void Publish_tests(void) messageStorage *msgStorage; WSADATA wsaData; BOOL messageOK, hello_message_seen = FALSE, endpoint_reference_seen = FALSE, app_sequence_seen = FALSE; - BOOL metadata_version_seen = FALSE, any_header_seen = FALSE, wine_ns_seen = FALSE; + BOOL metadata_version_seen = FALSE, any_header_seen = FALSE, wine_ns_seen = FALSE, body_hello_seen = FALSE; int ret, i; HRESULT rc; ULONG ref; @@ -629,8 +629,9 @@ static void Publish_tests(void) metadata_version_seen = (strstr(msg, "1") != NULL); any_header_seen = (strstr(msg, "PublishTest") != NULL); wine_ns_seen = (strstr(msg, "xmlns:wine=\"http://wine.test/\"") != NULL); + body_hello_seen = (strstr(msg, "