Owen Rudge : wsdapi: Create Body and Hello elements in Hello message.
Alexandre Julliard
julliard at winehq.org
Thu Apr 19 16:54:19 CDT 2018
Module: wine
Branch: master
Commit: 86515b390eace818af0897dce0fd943639c66801
URL: https://source.winehq.org/git/wine.git/?a=commit;h=86515b390eace818af0897dce0fd943639c66801
Author: Owen Rudge <orudge at codeweavers.com>
Date: Tue Apr 17 23:04:49 2018 +0100
wsdapi: Create Body and Hello elements in Hello message.
Signed-off-by: Owen Rudge <orudge at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 96efefd..a2a4223 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;
+
+ /* <soap:Body>, <wsd:Hello> */
+ 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 20d3442..06bde89 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, "<wsd:MetadataVersion>1</wsd:MetadataVersion>") != NULL);
any_header_seen = (strstr(msg, "<wine:Beer>PublishTest</wine:Beer>") != NULL);
wine_ns_seen = (strstr(msg, "xmlns:wine=\"http://wine.test/\"") != NULL);
+ body_hello_seen = (strstr(msg, "<soap:Body><wsd:Hello") != NULL);
messageOK = hello_message_seen && endpoint_reference_seen && app_sequence_seen && metadata_version_seen &&
- any_header_seen && wine_ns_seen;
+ any_header_seen && wine_ns_seen && body_hello_seen;
if (messageOK) break;
}
@@ -649,6 +650,7 @@ static void Publish_tests(void)
todo_wine ok(messageOK == TRUE, "Hello message metadata not received\n");
ok(any_header_seen == TRUE, "Custom header not received\n");
ok(wine_ns_seen == TRUE, "Wine namespace not received\n");
+ ok(body_hello_seen == TRUE, "Body and Hello elements not received\n");
after_publish_test:
More information about the wine-cvs
mailing list