webservices: Use the static dictionary only while writing the message header.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2018-06-20 15:04:47 +02:00 committed by Alexandre Julliard
parent 8355a96dd3
commit d120f7f841
3 changed files with 17 additions and 19 deletions

View File

@ -967,15 +967,6 @@ static HRESULT connect_channel( struct channel *channel )
} }
} }
static HRESULT write_message( WS_MESSAGE *handle, WS_XML_WRITER *writer, const WS_ELEMENT_DESCRIPTION *desc,
WS_WRITE_OPTION option, const void *body, ULONG size )
{
HRESULT hr;
if ((hr = WsWriteEnvelopeStart( handle, writer, NULL, NULL, NULL )) != S_OK) return hr;
if ((hr = WsWriteBody( handle, desc, option, body, size, NULL )) != S_OK) return hr;
return WsWriteEnvelopeEnd( handle, NULL );
}
static HRESULT send_message_http( HINTERNET request, BYTE *data, ULONG len ) static HRESULT send_message_http( HINTERNET request, BYTE *data, ULONG len )
{ {
if (!WinHttpSendRequest( request, NULL, 0, data, len, len, 0 )) if (!WinHttpSendRequest( request, NULL, 0, data, len, len, 0 ))
@ -1298,8 +1289,7 @@ static HRESULT init_writer( struct channel *channel )
bin.staticDictionary = (WS_XML_DICTIONARY *)&dict_builtin_static.dict; bin.staticDictionary = (WS_XML_DICTIONARY *)&dict_builtin_static.dict;
bin.dynamicStringCallback = dict_cb; bin.dynamicStringCallback = dict_cb;
bin.dynamicStringCallbackState = &channel->dict_send; bin.dynamicStringCallbackState = &channel->dict_send;
if ((hr = WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL )) != S_OK) return hr; return WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL );
return writer_enable_lookup( channel->writer );
case WS_ENCODING_XML_BINARY_1: case WS_ENCODING_XML_BINARY_1:
return WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL ); return WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL );
@ -1310,6 +1300,17 @@ static HRESULT init_writer( struct channel *channel )
} }
} }
static HRESULT write_message( struct channel *channel, WS_MESSAGE *msg, const WS_ELEMENT_DESCRIPTION *desc,
WS_WRITE_OPTION option, const void *body, ULONG size )
{
HRESULT hr;
if ((hr = writer_set_lookup( channel->writer, TRUE )) != S_OK) return hr;
if ((hr = WsWriteEnvelopeStart( msg, channel->writer, NULL, NULL, NULL )) != S_OK) return hr;
if ((hr = writer_set_lookup( channel->writer, FALSE )) != S_OK) return hr;
if ((hr = WsWriteBody( msg, desc, option, body, size, NULL )) != S_OK) return hr;
return WsWriteEnvelopeEnd( msg, NULL );
}
/************************************************************************** /**************************************************************************
* WsSendMessage [webservices.@] * WsSendMessage [webservices.@]
*/ */
@ -1339,8 +1340,7 @@ HRESULT WINAPI WsSendMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_MESS
if ((hr = message_set_action( msg, desc->action )) != S_OK) goto done; if ((hr = message_set_action( msg, desc->action )) != S_OK) goto done;
if ((hr = init_writer( channel )) != S_OK) goto done; if ((hr = init_writer( channel )) != S_OK) goto done;
if ((hr = write_message( msg, channel->writer, desc->bodyElementDescription, option, body, size )) != S_OK) if ((hr = write_message( channel, msg, desc->bodyElementDescription, option, body, size )) != S_OK) goto done;
goto done;
hr = send_message( channel, msg ); hr = send_message( channel, msg );
done: done:
@ -1380,13 +1380,11 @@ HRESULT WINAPI WsSendReplyMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS
if ((hr = message_set_request_id( msg, &req_id )) != S_OK) goto done; if ((hr = message_set_request_id( msg, &req_id )) != S_OK) goto done;
if ((hr = init_writer( channel )) != S_OK) goto done; if ((hr = init_writer( channel )) != S_OK) goto done;
if ((hr = write_message( msg, channel->writer, desc->bodyElementDescription, option, body, size )) != S_OK) if ((hr = write_message( channel, msg, desc->bodyElementDescription, option, body, size )) != S_OK) goto done;
goto done;
hr = send_message( channel, msg ); hr = send_message( channel, msg );
done: done:
LeaveCriticalSection( &channel->cs ); LeaveCriticalSection( &channel->cs );
FIXME( "returning %08x\n", hr );
return hr; return hr;
} }

View File

@ -50,7 +50,7 @@ const struct dictionary dict_builtin_static DECLSPEC_HIDDEN;
int find_string( const struct dictionary *, const unsigned char *, ULONG, ULONG * ) DECLSPEC_HIDDEN; int find_string( const struct dictionary *, const unsigned char *, ULONG, ULONG * ) DECLSPEC_HIDDEN;
HRESULT insert_string( struct dictionary *, unsigned char *, ULONG, int, ULONG * ) DECLSPEC_HIDDEN; HRESULT insert_string( struct dictionary *, unsigned char *, ULONG, int, ULONG * ) DECLSPEC_HIDDEN;
void clear_dict( struct dictionary * ) DECLSPEC_HIDDEN; void clear_dict( struct dictionary * ) DECLSPEC_HIDDEN;
HRESULT writer_enable_lookup( WS_XML_WRITER * ) DECLSPEC_HIDDEN; HRESULT writer_set_lookup( WS_XML_WRITER *, BOOL ) DECLSPEC_HIDDEN;
const char *debugstr_xmlstr( const WS_XML_STRING * ) DECLSPEC_HIDDEN; const char *debugstr_xmlstr( const WS_XML_STRING * ) DECLSPEC_HIDDEN;
WS_XML_STRING *alloc_xml_string( const unsigned char *, ULONG ) DECLSPEC_HIDDEN; WS_XML_STRING *alloc_xml_string( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;

View File

@ -4849,7 +4849,7 @@ done:
return hr; return hr;
} }
HRESULT writer_enable_lookup( WS_XML_WRITER *handle ) HRESULT writer_set_lookup( WS_XML_WRITER *handle, BOOL enable )
{ {
struct writer *writer = (struct writer *)handle; struct writer *writer = (struct writer *)handle;
@ -4861,7 +4861,7 @@ HRESULT writer_enable_lookup( WS_XML_WRITER *handle )
return E_INVALIDARG; return E_INVALIDARG;
} }
writer->dict_do_lookup = TRUE; writer->dict_do_lookup = enable;
LeaveCriticalSection( &writer->cs ); LeaveCriticalSection( &writer->cs );
return S_OK; return S_OK;