webservices: Implement WsRemoveHeader.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b89f7d9443
commit
b2829c4b66
|
@ -671,3 +671,35 @@ HRESULT WINAPI WsSetHeader( WS_MESSAGE *handle, WS_HEADER_TYPE type, WS_TYPE val
|
|||
msg->header[i] = header;
|
||||
return write_envelope( msg );
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* WsRemoveHeader [webservices.@]
|
||||
*/
|
||||
HRESULT WINAPI WsRemoveHeader( WS_MESSAGE *handle, WS_HEADER_TYPE type, WS_ERROR *error )
|
||||
{
|
||||
struct msg *msg = (struct msg *)handle;
|
||||
BOOL removed = FALSE;
|
||||
ULONG i;
|
||||
|
||||
TRACE( "%p %u %p\n", handle, type, error );
|
||||
if (error) FIXME( "ignoring error parameter\n" );
|
||||
|
||||
if (!handle) return E_INVALIDARG;
|
||||
if (msg->state < WS_MESSAGE_STATE_INITIALIZED) return WS_E_INVALID_OPERATION;
|
||||
if (type < WS_ACTION_HEADER || type > WS_FAULT_TO_HEADER) return E_INVALIDARG;
|
||||
|
||||
for (i = 0; i < msg->header_count; i++)
|
||||
{
|
||||
if (msg->header[i]->type == type)
|
||||
{
|
||||
heap_free( msg->header[i] );
|
||||
memmove( &msg->header[i], &msg->header[i + 1], (msg->header_count - i) * sizeof(struct header *) );
|
||||
msg->header_count--;
|
||||
removed = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed) return write_envelope( msg );
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -591,6 +591,67 @@ static void test_WsSetHeader(void)
|
|||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
static void test_WsRemoveHeader(void)
|
||||
{
|
||||
static const char expected[] =
|
||||
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
|
||||
"xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
|
||||
"<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
|
||||
"<a:Action s:mustUnderstand=\"1\">action</a:Action></s:Header>"
|
||||
"<s:Body/></s:Envelope>";
|
||||
static const char expected2[] =
|
||||
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
|
||||
"xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
|
||||
"<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
|
||||
"</s:Header><s:Body/></s:Envelope>";
|
||||
static const WS_XML_STRING action = {6, (BYTE *)"action"};
|
||||
HRESULT hr;
|
||||
WS_MESSAGE *msg;
|
||||
|
||||
hr = WsSetHeader( NULL, 0, 0, 0, NULL, 0, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
hr = WsCreateMessage( WS_ADDRESSING_VERSION_1_0, WS_ENVELOPE_VERSION_SOAP_1_2, NULL, 0, &msg,
|
||||
NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsRemoveHeader( NULL, 0, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
hr = WsRemoveHeader( msg, 0, NULL );
|
||||
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
|
||||
|
||||
hr = WsRemoveHeader( msg, WS_ACTION_HEADER, NULL );
|
||||
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
|
||||
|
||||
hr = WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output_header( msg, expected2, -1, strstr(expected2, "urn:uuid:") - expected2, 46, __LINE__ );
|
||||
|
||||
hr = WsRemoveHeader( msg, 0, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
hr = WsRemoveHeader( msg, WS_ACTION_HEADER, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output_header( msg, expected2, -1, strstr(expected2, "urn:uuid:") - expected2, 46, __LINE__ );
|
||||
|
||||
hr = WsSetHeader( msg, WS_ACTION_HEADER, WS_XML_STRING_TYPE, WS_WRITE_REQUIRED_VALUE, &action,
|
||||
sizeof(action), NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output_header( msg, expected, -1, strstr(expected, "urn:uuid:") - expected, 46, __LINE__ );
|
||||
|
||||
hr = WsRemoveHeader( msg, WS_ACTION_HEADER, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output_header( msg, expected2, -1, strstr(expected2, "urn:uuid:") - expected2, 46, __LINE__ );
|
||||
|
||||
/* again */
|
||||
hr = WsRemoveHeader( msg, WS_ACTION_HEADER, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output_header( msg, expected2, -1, strstr(expected2, "urn:uuid:") - expected2, 46, __LINE__ );
|
||||
|
||||
WsFreeMessage( msg );
|
||||
}
|
||||
|
||||
START_TEST(msg)
|
||||
{
|
||||
test_WsCreateMessage();
|
||||
|
@ -601,4 +662,5 @@ START_TEST(msg)
|
|||
test_WsWriteEnvelopeEnd();
|
||||
test_WsWriteBody();
|
||||
test_WsSetHeader();
|
||||
test_WsRemoveHeader();
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
@ stub WsReceiveMessage
|
||||
@ stub WsRegisterOperationForCancel
|
||||
@ stub WsRemoveCustomHeader
|
||||
@ stub WsRemoveHeader
|
||||
@ stdcall WsRemoveHeader(ptr long ptr)
|
||||
@ stub WsRemoveMappedHeader
|
||||
@ stub WsRemoveNode
|
||||
@ stub WsRequestReply
|
||||
|
|
|
@ -1420,6 +1420,7 @@ HRESULT WINAPI WsReadValue(WS_XML_READER*, WS_VALUE_TYPE, void*, ULONG, WS_ERROR
|
|||
HRESULT WINAPI WsReceiveMessage(WS_CHANNEL*, WS_MESSAGE*, const WS_MESSAGE_DESCRIPTION**, ULONG,
|
||||
WS_RECEIVE_OPTION, WS_READ_OPTION, WS_HEAP*, void*, ULONG, ULONG*,
|
||||
const WS_ASYNC_CONTEXT*, WS_ERROR*);
|
||||
HRESULT WINAPI WsRemoveHeader(WS_MESSAGE*, WS_HEADER_TYPE, WS_ERROR*);
|
||||
HRESULT WINAPI WsRemoveNode(const WS_XML_NODE_POSITION*, WS_ERROR*);
|
||||
HRESULT WINAPI WsResetChannel(WS_CHANNEL*, WS_ERROR*);
|
||||
HRESULT WINAPI WsResetError(WS_ERROR*);
|
||||
|
|
Loading…
Reference in New Issue