From 1a7df56e562bf14e99cfb853e3a0a5ab17446240 Mon Sep 17 00:00:00 2001 From: Owen Rudge Date: Tue, 17 Apr 2018 23:04:40 +0100 Subject: [PATCH] wsdapi: Register default namespaces when creating publisher. Signed-off-by: Owen Rudge Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/wsdapi/discovery.c | 20 +++++++++++++++++--- dlls/wsdapi/soap.c | 13 +++++++++++++ dlls/wsdapi/wsdapi_internal.h | 2 ++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/dlls/wsdapi/discovery.c b/dlls/wsdapi/discovery.c index 5136a243d9e..fc8acfb91c9 100644 --- a/dlls/wsdapi/discovery.c +++ b/dlls/wsdapi/discovery.c @@ -25,6 +25,7 @@ #include "wsdapi_internal.h" #include "wine/debug.h" +#include "wine/heap.h" #include "guiddef.h" WINE_DEFAULT_DEBUG_CHANNEL(wsdapi); @@ -332,6 +333,7 @@ static const IWSDiscoveryPublisherVtbl publisher_vtbl = HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext *pContext, IWSDiscoveryPublisher **ppPublisher) { IWSDiscoveryPublisherImpl *obj; + HRESULT ret; TRACE("(%p, %p)\n", pContext, ppPublisher); @@ -356,11 +358,13 @@ HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext *pContext, IWSDiscover if (pContext == NULL) { - if (FAILED(WSDXMLCreateContext(&obj->xmlContext))) + ret = WSDXMLCreateContext(&obj->xmlContext); + + if (FAILED(ret)) { WARN("Unable to create XML context\n"); - HeapFree (GetProcessHeap(), 0, obj); - return E_OUTOFMEMORY; + heap_free(obj); + return ret; } } else @@ -369,6 +373,16 @@ HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext *pContext, IWSDiscover IWSDXMLContext_AddRef(pContext); } + ret = register_namespaces(obj->xmlContext); + + if (FAILED(ret)) + { + WARN("Unable to register default namespaces\n"); + heap_free(obj); + + return ret; + } + list_init(&obj->notificationSinks); *ppPublisher = &obj->IWSDiscoveryPublisher_iface; diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c index ad83a885b05..96efefdbba7 100644 --- a/dlls/wsdapi/soap.c +++ b/dlls/wsdapi/soap.c @@ -286,6 +286,19 @@ static HRESULT add_child_element(IWSDXMLContext *xml_context, WSDXML_ELEMENT *pa return ret; } +HRESULT register_namespaces(IWSDXMLContext *xml_context) +{ + HRESULT ret; + + ret = IWSDXMLContext_AddNamespace(xml_context, addressingNsUri, addressingPrefix, NULL); + if (FAILED(ret)) return ret; + + ret = IWSDXMLContext_AddNamespace(xml_context, discoveryNsUri, discoveryPrefix, NULL); + if (FAILED(ret)) return ret; + + return IWSDXMLContext_AddNamespace(xml_context, envelopeNsUri, envelopePrefix, NULL); +} + static BOOL create_guid(LPWSTR buffer) { const WCHAR formatString[] = { 'u','r','n',':','u','u','i','d',':','%','s', 0 }; diff --git a/dlls/wsdapi/wsdapi_internal.h b/dlls/wsdapi/wsdapi_internal.h index dd7931c67e3..57bf58c3385 100644 --- a/dlls/wsdapi/wsdapi_internal.h +++ b/dlls/wsdapi/wsdapi_internal.h @@ -62,6 +62,8 @@ 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); +HRESULT register_namespaces(IWSDXMLContext *xml_context); + /* xml.c */ LPWSTR duplicate_string(void *parentMemoryBlock, LPCWSTR value);