webservices: Implement WsResetServiceProxy.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2017-04-05 11:40:24 +02:00 committed by Alexandre Julliard
parent e1e36be4b8
commit 3c78421499
4 changed files with 86 additions and 1 deletions

View File

@ -70,9 +70,17 @@ static struct proxy *alloc_proxy(void)
return ret;
}
static void reset_proxy( struct proxy *proxy )
{
WsResetChannel( proxy->channel, NULL );
proxy->state = WS_SERVICE_PROXY_STATE_CREATED;
}
static void free_proxy( struct proxy *proxy )
{
reset_proxy( proxy );
WsFreeChannel( proxy->channel );
proxy->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &proxy->cs );
heap_free( proxy );
@ -191,6 +199,38 @@ HRESULT WINAPI WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE channel_type,
return hr;
}
/**************************************************************************
* WsResetServiceProxy [webservices.@]
*/
HRESULT WINAPI WsResetServiceProxy( WS_SERVICE_PROXY *handle, WS_ERROR *error )
{
struct proxy *proxy = (struct proxy *)handle;
TRACE( "%p %p\n", handle, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!proxy) return E_INVALIDARG;
EnterCriticalSection( &proxy->cs );
if (proxy->magic != PROXY_MAGIC)
{
LeaveCriticalSection( &proxy->cs );
return E_INVALIDARG;
}
if (proxy->state != WS_SERVICE_PROXY_STATE_CREATED && proxy->state != WS_SERVICE_PROXY_STATE_CLOSED)
{
LeaveCriticalSection( &proxy->cs );
return WS_E_INVALID_OPERATION;
}
reset_proxy( proxy );
LeaveCriticalSection( &proxy->cs );
return S_OK;
}
/**************************************************************************
* WsFreeServiceProxy [webservices.@]
*/

View File

@ -185,6 +185,49 @@ static void test_WsOpenServiceProxy(void)
WsFreeServiceProxy( proxy );
}
static void test_WsResetServiceProxy(void)
{
WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t','/'};
HRESULT hr;
WS_SERVICE_PROXY *proxy;
WS_ENDPOINT_ADDRESS addr;
WS_SERVICE_PROXY_STATE state;
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
0, NULL, 0, &proxy, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsResetServiceProxy( proxy, NULL );
ok( hr == S_OK, "got %08x\n", hr );
state = 0xdeadbeef;
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
memset( &addr, 0, sizeof(addr) );
addr.url.length = sizeof(url)/sizeof(url[0]);
addr.url.chars = url;
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsResetServiceProxy( proxy, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = WsCloseServiceProxy( proxy , NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsResetServiceProxy( proxy, NULL );
ok( hr == S_OK, "got %08x\n", hr );
state = 0xdeadbeef;
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
WsFreeServiceProxy( proxy );
}
static HRESULT create_channel( int port, WS_CHANNEL **ret )
{
static const WCHAR fmt[] =
@ -680,6 +723,7 @@ START_TEST(proxy)
test_WsCreateServiceProxy();
test_WsCreateServiceProxyFromTemplate();
test_WsOpenServiceProxy();
test_WsResetServiceProxy();
info.port = 7533;
info.event = CreateEventW( NULL, 0, 0, NULL );

View File

@ -140,7 +140,7 @@
@ stdcall WsResetMessage(ptr ptr)
@ stub WsResetMetadata
@ stub WsResetServiceHost
@ stub WsResetServiceProxy
@ stdcall WsResetServiceProxy(ptr ptr)
@ stub WsRevokeSecurityContext
@ stub WsSendFaultMessageForError
@ stdcall WsSendMessage(ptr ptr ptr long ptr long ptr ptr)

View File

@ -1631,6 +1631,7 @@ HRESULT WINAPI WsResetError(WS_ERROR*);
HRESULT WINAPI WsResetHeap(WS_HEAP*, WS_ERROR*);
HRESULT WINAPI WsResetListener(WS_LISTENER*, WS_ERROR*);
HRESULT WINAPI WsResetMessage(WS_MESSAGE*, WS_ERROR*);
HRESULT WINAPI WsResetServiceProxy(WS_SERVICE_PROXY*, WS_ERROR*);
HRESULT WINAPI WsRequestReply(WS_CHANNEL*, WS_MESSAGE*, const WS_MESSAGE_DESCRIPTION*, WS_WRITE_OPTION,
const void*, ULONG, WS_MESSAGE*, const WS_MESSAGE_DESCRIPTION*,
WS_READ_OPTION, WS_HEAP*, void*, ULONG, const WS_ASYNC_CONTEXT*, WS_ERROR*);