Commit e36a185f authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement WsAddressMessage.

parent d91a7d2e
......@@ -49,6 +49,7 @@ struct msg
WS_ENVELOPE_VERSION version_env;
WS_ADDRESSING_VERSION version_addr;
BOOL is_addressed;
WS_STRING addr;
ULONG prop_count;
struct prop prop[sizeof(msg_props)/sizeof(msg_props[0])];
};
......@@ -68,6 +69,8 @@ static struct msg *alloc_msg(void)
static void free_msg( struct msg *msg )
{
if (!msg) return;
heap_free( msg->addr.chars );
heap_free( msg );
}
......@@ -246,3 +249,32 @@ HRESULT WINAPI WsSetMessageProperty( WS_MESSAGE *handle, WS_MESSAGE_PROPERTY_ID
}
return prop_set( msg->prop, msg->prop_count, id, value, size );
}
/**************************************************************************
* WsAddressMessage [webservices.@]
*/
HRESULT WINAPI WsAddressMessage( WS_MESSAGE *handle, const WS_ENDPOINT_ADDRESS *addr, WS_ERROR *error )
{
struct msg *msg = (struct msg *)handle;
TRACE( "%p %p %p\n", handle, addr, error );
if (error) FIXME( "ignoring error parameter\n" );
if (addr && (addr->headers || addr->extensions || addr->identity))
{
FIXME( "headers, extensions or identity not supported\n" );
return E_NOTIMPL;
}
if (!handle) return E_INVALIDARG;
if (msg->state < WS_MESSAGE_STATE_INITIALIZED || msg->is_addressed) return WS_E_INVALID_OPERATION;
if (addr && addr->url.length)
{
if (!(msg->addr.chars = heap_alloc( addr->url.length * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
memcpy( msg->addr.chars, addr->url.chars, addr->url.length * sizeof(WCHAR) );
msg->addr.length = addr->url.length;
}
msg->is_addressed = TRUE;
return S_OK;
}
......@@ -209,9 +209,72 @@ static void test_WsInitializeMessage(void)
WsFreeMessage( msg );
}
static void test_WsAddressMessage(void)
{
static WCHAR localhost[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t','/',0};
HRESULT hr;
WS_MESSAGE *msg;
WS_ENDPOINT_ADDRESS endpoint;
BOOL addressed;
hr = WsAddressMessage( NULL, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsCreateMessage( WS_ADDRESSING_VERSION_0_9, WS_ENVELOPE_VERSION_SOAP_1_1, NULL,
0, &msg, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_IS_ADDRESSED, &addressed, sizeof(addressed),
NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = WsAddressMessage( msg, NULL, 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 );
addressed = -1;
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_IS_ADDRESSED, &addressed, sizeof(addressed),
NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( !addressed, "unexpected value %d\n", addressed );
hr = WsAddressMessage( msg, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
addressed = -1;
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_IS_ADDRESSED, &addressed, sizeof(addressed),
NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( addressed == TRUE, "unexpected value %d\n", addressed );
WsFreeMessage( msg );
hr = WsCreateMessage( WS_ADDRESSING_VERSION_0_9, WS_ENVELOPE_VERSION_SOAP_1_1, 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 );
memset( &endpoint, 0, sizeof(endpoint) );
endpoint.url.chars = localhost;
endpoint.url.length = sizeof(localhost)/sizeof(localhost[0]);
hr = WsAddressMessage( msg, &endpoint, NULL );
ok( hr == S_OK, "got %08x\n", hr );
addressed = -1;
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_IS_ADDRESSED, &addressed, sizeof(addressed),
NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( addressed == TRUE, "unexpected value %d\n", addressed );
WsFreeMessage( msg );
}
START_TEST(msg)
{
test_WsCreateMessage();
test_WsCreateMessageForChannel();
test_WsInitializeMessage();
test_WsAddressMessage();
}
......@@ -8,7 +8,7 @@
@ stub WsAddCustomHeader
@ stub WsAddErrorString
@ stub WsAddMappedHeader
@ stub WsAddressMessage
@ stdcall WsAddressMessage(ptr ptr ptr)
@ stdcall WsAlloc(ptr long ptr ptr)
@ stub WsAsyncExecute
@ stdcall WsCall(ptr ptr ptr ptr ptr long ptr ptr)
......
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