[07/10] webservices: Implement WsAddressMessage.
Hans Leidekker
hans at codeweavers.com
Thu Jul 7 02:31:57 CDT 2016
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/webservices/msg.c | 32 ++++++++++++++++++++
dlls/webservices/tests/msg.c | 63 +++++++++++++++++++++++++++++++++++++++
dlls/webservices/webservices.spec | 2 +-
3 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c
index b3444e0..360e0bd 100644
--- a/dlls/webservices/msg.c
+++ b/dlls/webservices/msg.c
@@ -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;
+}
diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c
index e7b91d0..3e321d7 100644
--- a/dlls/webservices/tests/msg.c
+++ b/dlls/webservices/tests/msg.c
@@ -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();
}
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index 6a3fbd4..a702fc0 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -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)
--
2.1.4
More information about the wine-patches
mailing list