diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c index 50821d9bf87..99f3837104b 100644 --- a/dlls/webservices/msg.c +++ b/dlls/webservices/msg.c @@ -433,3 +433,23 @@ HRESULT WINAPI WsWriteEnvelopeStart( WS_MESSAGE *handle, WS_XML_WRITER *writer, msg->state = WS_MESSAGE_STATE_WRITING; return S_OK; } + +/************************************************************************** + * WsWriteEnvelopeEnd [webservices.@] + */ +HRESULT WINAPI WsWriteEnvelopeEnd( WS_MESSAGE *handle, WS_ERROR *error ) +{ + struct msg *msg = (struct msg *)handle; + HRESULT hr; + + TRACE( "%p %p\n", handle, error ); + if (error) FIXME( "ignoring error parameter\n" ); + + if (!handle) return E_INVALIDARG; + if (msg->state != WS_MESSAGE_STATE_WRITING) return WS_E_INVALID_OPERATION; + + if ((hr = write_envelope_end( msg, msg->writer_body )) != S_OK) return hr; + + msg->state = WS_MESSAGE_STATE_DONE; + return S_OK; +} diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c index ec737c1f6e5..05d3169aa20 100644 --- a/dlls/webservices/tests/msg.c +++ b/dlls/webservices/tests/msg.c @@ -380,6 +380,57 @@ static void test_WsWriteEnvelopeStart(void) WsFreeWriter( writer ); } +static void test_WsWriteEnvelopeEnd(void) +{ + static const char expected[] = + "" + "urn:uuid:00000000-0000-0000-0000-000000000000" + ""; + HRESULT hr; + WS_MESSAGE *msg; + WS_XML_WRITER *writer; + WS_MESSAGE_STATE state; + + hr = WsWriteEnvelopeEnd( NULL, 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 = WsWriteEnvelopeEnd( msg, 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 ); + + hr = WsWriteEnvelopeEnd( msg, NULL ); + ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr ); + + hr = WsCreateWriter( NULL, 0, &writer, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = set_output( writer ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteEnvelopeStart( msg, writer, NULL, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteEnvelopeEnd( msg, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output( writer, expected, -1, strstr(expected, "urn:uuid:") - expected, 46, __LINE__ ); + check_output_header( msg, expected, -1, strstr(expected, "urn:uuid:") - expected, 46, __LINE__ ); + + 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_DONE, "got %u\n", state ); + + WsFreeMessage( msg ); + WsFreeWriter( writer ); +} + START_TEST(msg) { test_WsCreateMessage(); @@ -387,4 +438,5 @@ START_TEST(msg) test_WsInitializeMessage(); test_WsAddressMessage(); test_WsWriteEnvelopeStart(); + test_WsWriteEnvelopeEnd(); } diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec index 6a29af0f18f..bdb50a7f75a 100644 --- a/dlls/webservices/webservices.spec +++ b/dlls/webservices/webservices.spec @@ -175,7 +175,7 @@ @ stdcall WsWriteEndCData(ptr ptr) @ stdcall WsWriteEndElement(ptr ptr) @ stdcall WsWriteEndStartElement(ptr ptr) -@ stub WsWriteEnvelopeEnd +@ stdcall WsWriteEnvelopeEnd(ptr ptr) @ stdcall WsWriteEnvelopeStart(ptr ptr ptr ptr ptr) @ stub WsWriteMessageEnd @ stub WsWriteMessageStart