diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c
index 4a47fd358e3..01b66257dd5 100644
--- a/dlls/webservices/msg.c
+++ b/dlls/webservices/msg.c
@@ -1022,9 +1022,7 @@ HRESULT WINAPI WsAddCustomHeader( WS_MESSAGE *handle, const WS_ELEMENT_DESCRIPTI
{
struct msg *msg = (struct msg *)handle;
struct header *header;
- BOOL found = FALSE;
HRESULT hr;
- ULONG i;
TRACE( "%p %p %08x %p %u %08x %p\n", handle, desc, option, value, size, attrs, error );
if (error) FIXME( "ignoring error parameter\n" );
@@ -1032,30 +1030,11 @@ HRESULT WINAPI WsAddCustomHeader( WS_MESSAGE *handle, const WS_ELEMENT_DESCRIPTI
if (!handle || !desc) return E_INVALIDARG;
if (msg->state < WS_MESSAGE_STATE_INITIALIZED) return WS_E_INVALID_OPERATION;
- for (i = 0; i < msg->header_count; i++)
- {
- if (msg->header[i]->type || msg->header[i]->mapped) continue;
- if (WsXmlStringEquals( desc->elementLocalName, &msg->header[i]->name, NULL ) &&
- WsXmlStringEquals( desc->elementNs, &msg->header[i]->ns, NULL ) == S_OK)
- {
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- {
- if ((hr = grow_header_array( msg, msg->header_count + 1 )) != S_OK) return hr;
- i = msg->header_count;
- }
-
+ if ((hr = grow_header_array( msg, msg->header_count + 1 )) != S_OK) return hr;
if ((hr = build_custom_header( msg->heap, desc->elementLocalName, desc->elementNs, desc->type,
desc->typeDescription, option, value, size, &header )) != S_OK) return hr;
- if (!found) msg->header_count++;
- else free_header( msg->header[i] );
-
- msg->header[i] = header;
+ msg->header[msg->header_count++] = header;
return write_envelope( msg );
}
diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c
index 0a8456add7c..b78c52ea1ba 100644
--- a/dlls/webservices/tests/msg.c
+++ b/dlls/webservices/tests/msg.c
@@ -749,8 +749,22 @@ static void test_WsAddCustomHeader(void)
"xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">"
"urn:uuid:00000000-0000-0000-0000-000000000000"
"";
+ static const char expected3[] =
+ ""
+ "urn:uuid:00000000-0000-0000-0000-000000000000"
+ ""
+ "";
+ static const char expected4[] =
+ ""
+ "urn:uuid:00000000-0000-0000-0000-000000000000"
+ ""
+ "value2";
static WS_XML_STRING header = {6, (BYTE *)"header"}, ns = {2, (BYTE *)"ns"};
+ static WS_XML_STRING header2 = {7, (BYTE *)"header2"};
static WCHAR valueW[] = {'v','a','l','u','e',0};
+ static WCHAR value2W[] = {'v','a','l','u','e','2',0};
HRESULT hr;
WS_MESSAGE *msg;
WS_ELEMENT_DESCRIPTION desc;
@@ -797,6 +811,16 @@ static void test_WsAddCustomHeader(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output_header( msg, expected, -1, strstr(expected, "urn:uuid:") - expected, 46, __LINE__ );
+ test.value = value2W;
+ hr = WsAddCustomHeader( msg, &desc, WS_WRITE_REQUIRED_VALUE, &test, sizeof(test), 0, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ check_output_header( msg, expected3, -1, strstr(expected3, "urn:uuid:") - expected3, 46, __LINE__ );
+
+ desc.elementLocalName = &header2;
+ hr = WsAddCustomHeader( msg, &desc, WS_WRITE_REQUIRED_VALUE, &test, sizeof(test), 0, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ check_output_header( msg, expected4, -1, strstr(expected4, "urn:uuid:") - expected4, 46, __LINE__ );
+
hr = WsAddCustomHeader( msg, &desc, WS_WRITE_REQUIRED_VALUE, NULL, 0, 0, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );