Commit 6f3afc1a authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement WsResetMessage.

parent 4f1c7dc1
......@@ -123,15 +123,44 @@ static void free_header( struct header *header )
heap_free( header );
}
static void free_msg( struct msg *msg )
static void reset_msg( struct msg *msg )
{
ULONG i;
WsFreeWriter( msg->writer );
WsFreeHeap( msg->heap );
msg->state = WS_MESSAGE_STATE_EMPTY;
msg->init = 0;
UuidCreate( &msg->id );
msg->is_addressed = FALSE;
heap_free( msg->addr.chars );
msg->addr.chars = NULL;
msg->addr.length = 0;
heap_free( msg->action.chars );
for (i = 0; i < msg->header_count; i++) free_header( msg->header[i] );
msg->action.chars = NULL;
msg->action.length = 0;
WsResetHeap( msg->heap, NULL );
msg->buf = NULL; /* allocated on msg->heap */
msg->writer_body = NULL; /* owned by caller */
msg->reader_body = NULL; /* owned by caller */
for (i = 0; i < msg->header_count; i++)
{
free_header( msg->header[i] );
msg->header[i] = NULL;
}
msg->header_count = 0;
memset( &msg->ctx_send, 0, sizeof(msg->ctx_send) );
memset( &msg->ctx_receive, 0, sizeof(msg->ctx_receive) );
}
static void free_msg( struct msg *msg )
{
reset_msg( msg );
WsFreeWriter( msg->writer );
WsFreeHeap( msg->heap );
heap_free( msg->header );
msg->cs.DebugInfo->Spare[0] = 0;
......@@ -246,6 +275,32 @@ void WINAPI WsFreeMessage( WS_MESSAGE *handle )
}
/**************************************************************************
* WsResetMessage [webservices.@]
*/
HRESULT WINAPI WsResetMessage( WS_MESSAGE *handle, WS_ERROR *error )
{
struct msg *msg = (struct msg *)handle;
TRACE( "%p %p\n", handle, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!msg) return E_INVALIDARG;
EnterCriticalSection( &msg->cs );
if (msg->magic != MSG_MAGIC)
{
LeaveCriticalSection( &msg->cs );
return E_INVALIDARG;
}
reset_msg( msg );
LeaveCriticalSection( &msg->cs );
return S_OK;
}
/**************************************************************************
* WsGetMessageProperty [webservices.@]
*/
HRESULT WINAPI WsGetMessageProperty( WS_MESSAGE *handle, WS_MESSAGE_PROPERTY_ID id, void *buf,
......
......@@ -1105,6 +1105,43 @@ static void test_WsReadBody(void)
WsFreeHeap( heap );
}
static void test_WsResetMessage(void)
{
WS_MESSAGE *msg;
WS_MESSAGE_STATE state;
WS_ENVELOPE_VERSION env_version;
WS_ADDRESSING_VERSION addr_version;
HRESULT hr;
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsResetMessage( msg, NULL );
ok( hr == S_OK, "got %08x\n", hr );
state = 0xdeadbeef;
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_STATE, &state, sizeof(state), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( state == WS_MESSAGE_STATE_EMPTY, "got %u\n", state );
env_version = 0xdeadbeef;
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION, &env_version,
sizeof(env_version), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( env_version == WS_ENVELOPE_VERSION_SOAP_1_1, "got %u\n", env_version );
addr_version = 0xdeadbeef;
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION, &addr_version,
sizeof(addr_version), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( addr_version == WS_ADDRESSING_VERSION_0_9, "got %u\n", addr_version );
WsFreeMessage( msg );
}
START_TEST(msg)
{
test_WsCreateMessage();
......@@ -1123,4 +1160,5 @@ START_TEST(msg)
test_WsReadEnvelopeStart();
test_WsReadEnvelopeEnd();
test_WsReadBody();
test_WsResetMessage();
}
......@@ -137,7 +137,7 @@
@ stdcall WsResetError(ptr)
@ stdcall WsResetHeap(ptr ptr)
@ stub WsResetListener
@ stub WsResetMessage
@ stdcall WsResetMessage(ptr ptr)
@ stub WsResetMetadata
@ stub WsResetServiceHost
@ stub WsResetServiceProxy
......
......@@ -1488,6 +1488,7 @@ HRESULT WINAPI WsRemoveHeader(WS_MESSAGE*, WS_HEADER_TYPE, WS_ERROR*);
HRESULT WINAPI WsRemoveMappedHeader(WS_MESSAGE*, const WS_XML_STRING*, WS_ERROR*);
HRESULT WINAPI WsRemoveNode(const WS_XML_NODE_POSITION*, WS_ERROR*);
HRESULT WINAPI WsResetChannel(WS_CHANNEL*, WS_ERROR*);
HRESULT WINAPI WsResetMessage(WS_MESSAGE*, WS_ERROR*);
HRESULT WINAPI WsResetError(WS_ERROR*);
HRESULT WINAPI WsResetHeap(WS_HEAP*, WS_ERROR*);
HRESULT WINAPI WsResetMessage(WS_MESSAGE*, WS_ERROR*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment