mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 22:13:38 +00:00
webservices: Properly initialize messages.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
be940a00d9
commit
ff5982fcf1
|
@ -1687,7 +1687,6 @@ static HRESULT send_message( struct channel *channel, WS_MESSAGE *msg, const WS_
|
|||
WS_WRITE_OPTION option, const void *body, ULONG size )
|
||||
{
|
||||
HRESULT hr;
|
||||
WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
|
||||
if ((hr = WsAddressMessage( msg, &channel->addr, NULL )) != S_OK) return hr;
|
||||
if ((hr = message_set_action( msg, desc->action )) != S_OK) return hr;
|
||||
if ((hr = init_writer( channel )) != S_OK) return hr;
|
||||
|
@ -1766,6 +1765,8 @@ HRESULT WINAPI WsSendMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_MESS
|
|||
return WS_E_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
WsInitializeMessage( msg, WS_BLANK_MESSAGE, NULL, NULL );
|
||||
|
||||
if (!ctx) async_init( &async, &ctx_local );
|
||||
hr = queue_send_message( channel, msg, desc, option, body, size, ctx ? ctx : &ctx_local );
|
||||
if (!ctx)
|
||||
|
@ -1810,6 +1811,7 @@ HRESULT WINAPI WsSendReplyMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS
|
|||
return WS_E_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
WsInitializeMessage( msg, WS_REPLY_MESSAGE, NULL, NULL );
|
||||
if ((hr = message_get_id( request, &id )) != S_OK) goto done;
|
||||
if ((hr = message_set_request_id( msg, &id )) != S_OK) goto done;
|
||||
|
||||
|
@ -2533,6 +2535,8 @@ HRESULT WINAPI WsRequestReply( WS_CHANNEL *handle, WS_MESSAGE *request, const WS
|
|||
return WS_E_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
WsInitializeMessage( request, WS_REQUEST_MESSAGE, NULL, NULL );
|
||||
|
||||
if (!ctx) async_init( &async, &ctx_local );
|
||||
hr = queue_request_reply( channel, request, request_desc, write_option, request_body, request_size, reply,
|
||||
reply_desc, read_option, heap, value, size, ctx ? ctx : &ctx_local );
|
||||
|
|
|
@ -611,9 +611,9 @@ static HRESULT write_relatesto_header( WS_XML_WRITER *writer, const WS_XML_STRIN
|
|||
return WsWriteEndElement( writer, NULL ); /* </a:RelatesTo> */
|
||||
}
|
||||
|
||||
static HRESULT write_headers( struct msg *msg, WS_XML_WRITER *writer, const WS_XML_STRING *prefix_env,
|
||||
const WS_XML_STRING *ns_env, const WS_XML_STRING *prefix_addr,
|
||||
const WS_XML_STRING *ns_addr )
|
||||
static HRESULT write_headers( struct msg *msg, WS_MESSAGE_INITIALIZATION init, WS_XML_WRITER *writer,
|
||||
const WS_XML_STRING *prefix_env, const WS_XML_STRING *ns_env,
|
||||
const WS_XML_STRING *prefix_addr, const WS_XML_STRING *ns_addr )
|
||||
{
|
||||
static const WS_XML_STRING header = {6, (BYTE *)"Header"};
|
||||
HRESULT hr;
|
||||
|
@ -625,7 +625,7 @@ static HRESULT write_headers( struct msg *msg, WS_XML_WRITER *writer, const WS_X
|
|||
if ((hr = write_action_header( writer, prefix_env, ns_env, prefix_addr, ns_addr, msg->action )) != S_OK)
|
||||
return hr;
|
||||
|
||||
if (msg->init == WS_REPLY_MESSAGE)
|
||||
if (init == WS_REPLY_MESSAGE)
|
||||
{
|
||||
if ((hr = write_relatesto_header( writer, prefix_env, ns_env, prefix_addr, ns_addr, &msg->id_req )) != S_OK)
|
||||
return hr;
|
||||
|
@ -637,8 +637,9 @@ static HRESULT write_headers( struct msg *msg, WS_XML_WRITER *writer, const WS_X
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((hr = write_msgid_header( writer, prefix_env, ns_env, prefix_addr, ns_addr, &msg->id )) != S_OK)
|
||||
return hr;
|
||||
if (init == WS_REQUEST_MESSAGE &&
|
||||
(hr = write_msgid_header( writer, prefix_env, ns_env, prefix_addr, ns_addr, &msg->id )) != S_OK) return hr;
|
||||
|
||||
if (msg->version_addr == WS_ADDRESSING_VERSION_0_9 &&
|
||||
(hr = write_replyto_header( writer, prefix_env, ns_env, prefix_addr, ns_addr )) != S_OK) return hr;
|
||||
}
|
||||
|
@ -685,7 +686,7 @@ static HRESULT write_headers_transport( struct msg *msg, WS_XML_WRITER *writer,
|
|||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT write_envelope_start( struct msg *msg, WS_XML_WRITER *writer )
|
||||
static HRESULT write_envelope_start( struct msg *msg, WS_MESSAGE_INITIALIZATION init, WS_XML_WRITER *writer )
|
||||
{
|
||||
static const WS_XML_STRING envelope = {8, (BYTE *)"Envelope"}, body = {4, (BYTE *)"Body"};
|
||||
static const WS_XML_STRING prefix_s = {1, (BYTE *)"s"}, prefix_a = {1, (BYTE *)"a"};
|
||||
|
@ -700,7 +701,7 @@ static HRESULT write_envelope_start( struct msg *msg, WS_XML_WRITER *writer )
|
|||
if (msg->version_addr == WS_ADDRESSING_VERSION_TRANSPORT)
|
||||
hr = write_headers_transport( msg, writer, prefix_env, ns_env );
|
||||
else
|
||||
hr = write_headers( msg, writer, prefix_env, ns_env, prefix_addr, ns_addr );
|
||||
hr = write_headers( msg, init, writer, prefix_env, ns_env, prefix_addr, ns_addr );
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
return WsWriteStartElement( writer, prefix_env, &body, ns_env, NULL ); /* <s:Body> */
|
||||
|
@ -713,13 +714,13 @@ static HRESULT write_envelope_end( WS_XML_WRITER *writer )
|
|||
return WsWriteEndElement( writer, NULL ); /* </s:Envelope> */
|
||||
}
|
||||
|
||||
static HRESULT write_envelope( struct msg *msg )
|
||||
static HRESULT write_envelope( struct msg *msg, WS_MESSAGE_INITIALIZATION init )
|
||||
{
|
||||
HRESULT hr;
|
||||
if (!msg->writer && (hr = WsCreateWriter( NULL, 0, &msg->writer, NULL )) != S_OK) return hr;
|
||||
if (!msg->buf && (hr = WsCreateXmlBuffer( msg->heap, NULL, 0, &msg->buf, NULL )) != S_OK) return hr;
|
||||
if ((hr = WsSetOutputToBuffer( msg->writer, msg->buf, NULL, 0, NULL )) != S_OK) return hr;
|
||||
if ((hr = write_envelope_start( msg, msg->writer )) != S_OK) return hr;
|
||||
if ((hr = write_envelope_start( msg, init, msg->writer )) != S_OK) return hr;
|
||||
return write_envelope_end( msg->writer );
|
||||
}
|
||||
|
||||
|
@ -751,8 +752,8 @@ HRESULT WINAPI WsWriteEnvelopeStart( WS_MESSAGE *handle, WS_XML_WRITER *writer,
|
|||
}
|
||||
|
||||
if (msg->state != WS_MESSAGE_STATE_INITIALIZED) hr = WS_E_INVALID_OPERATION;
|
||||
else if ((hr = write_envelope( msg )) == S_OK &&
|
||||
(hr = write_envelope_start( msg, writer )) == S_OK)
|
||||
else if ((hr = write_envelope( msg, msg->init )) == S_OK &&
|
||||
(hr = write_envelope_start( msg, msg->init, writer )) == S_OK)
|
||||
{
|
||||
msg->writer_body = writer;
|
||||
msg->state = WS_MESSAGE_STATE_WRITING;
|
||||
|
@ -1085,7 +1086,7 @@ HRESULT WINAPI WsInitializeMessage( WS_MESSAGE *handle, WS_MESSAGE_INITIALIZATIO
|
|||
}
|
||||
|
||||
if (msg->state >= WS_MESSAGE_STATE_INITIALIZED) hr = WS_E_INVALID_OPERATION;
|
||||
else if ((hr = write_envelope( msg )) == S_OK)
|
||||
else if ((hr = write_envelope( msg, init )) == S_OK)
|
||||
{
|
||||
msg->init = init;
|
||||
msg->state = WS_MESSAGE_STATE_INITIALIZED;
|
||||
|
@ -1235,7 +1236,7 @@ HRESULT WINAPI WsSetHeader( WS_MESSAGE *handle, WS_HEADER_TYPE type, WS_TYPE val
|
|||
else free_header( msg->header[i] );
|
||||
|
||||
msg->header[i] = header;
|
||||
hr = write_envelope( msg );
|
||||
hr = write_envelope( msg, msg->init );
|
||||
|
||||
done:
|
||||
LeaveCriticalSection( &msg->cs );
|
||||
|
@ -1353,7 +1354,7 @@ HRESULT WINAPI WsRemoveHeader( WS_MESSAGE *handle, WS_HEADER_TYPE type, WS_ERROR
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (removed) hr = write_envelope( msg );
|
||||
if (removed) hr = write_envelope( msg, msg->init );
|
||||
}
|
||||
|
||||
LeaveCriticalSection( &msg->cs );
|
||||
|
@ -1730,7 +1731,7 @@ HRESULT WINAPI WsAddCustomHeader( WS_MESSAGE *handle, const WS_ELEMENT_DESCRIPTI
|
|||
if ((hr = build_custom_header( msg, desc->elementLocalName, desc->elementNs, desc->type,
|
||||
desc->typeDescription, option, value, size, &header )) != S_OK) goto done;
|
||||
msg->header[msg->header_count++] = header;
|
||||
hr = write_envelope( msg );
|
||||
hr = write_envelope( msg, msg->init );
|
||||
|
||||
done:
|
||||
LeaveCriticalSection( &msg->cs );
|
||||
|
@ -1833,7 +1834,7 @@ HRESULT WINAPI WsRemoveCustomHeader( WS_MESSAGE *handle, const WS_XML_STRING *na
|
|||
i--;
|
||||
}
|
||||
}
|
||||
if (removed) hr = write_envelope( msg );
|
||||
if (removed) hr = write_envelope( msg, msg->init );
|
||||
}
|
||||
|
||||
LeaveCriticalSection( &msg->cs );
|
||||
|
|
|
@ -164,6 +164,11 @@ static void test_WsCreateMessageForChannel(void)
|
|||
hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
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_EMPTY, "got %u\n", state );
|
||||
|
||||
env_version = 0xdeadbeef;
|
||||
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION, &env_version,
|
||||
sizeof(env_version), NULL );
|
||||
|
@ -393,6 +398,16 @@ static void test_WsWriteEnvelopeStart(void)
|
|||
"xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
|
||||
"<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
|
||||
"</s:Header><s:Body/></s:Envelope>";
|
||||
static const char expected6[] =
|
||||
"<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header/><s:Body/></s:Envelope>";
|
||||
static const char expected7[] =
|
||||
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
|
||||
"xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header>"
|
||||
"<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
|
||||
"</s:Header><s:Body/></s:Envelope>";
|
||||
static const char expected8[] =
|
||||
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
|
||||
"xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header/><s:Body/></s:Envelope>";
|
||||
HRESULT hr;
|
||||
WS_MESSAGE *msg;
|
||||
WS_XML_WRITER *writer;
|
||||
|
@ -407,8 +422,7 @@ static void test_WsWriteEnvelopeStart(void)
|
|||
hr = WsWriteEnvelopeStart( NULL, writer, NULL, NULL, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg,
|
||||
NULL );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteEnvelopeStart( msg, writer, NULL, NULL, NULL );
|
||||
|
@ -429,8 +443,7 @@ static void test_WsWriteEnvelopeStart(void)
|
|||
ok( state == WS_MESSAGE_STATE_WRITING, "got %u\n", state );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_TRANSPORT, NULL, 0, &msg,
|
||||
NULL );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_TRANSPORT, 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 );
|
||||
|
@ -441,8 +454,7 @@ static void test_WsWriteEnvelopeStart(void)
|
|||
check_output_header( msg, expected3, -1, 0, 0, __LINE__ );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_NONE, WS_ADDRESSING_VERSION_TRANSPORT, NULL, 0, &msg,
|
||||
NULL );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_NONE, WS_ADDRESSING_VERSION_TRANSPORT, 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 );
|
||||
|
@ -453,8 +465,7 @@ static void test_WsWriteEnvelopeStart(void)
|
|||
check_output_header( msg, expected4, -1, 0, 0, __LINE__ );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2, WS_ADDRESSING_VERSION_1_0, NULL, 0, &msg,
|
||||
NULL );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2, WS_ADDRESSING_VERSION_1_0, 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 );
|
||||
|
@ -465,18 +476,48 @@ static void test_WsWriteEnvelopeStart(void)
|
|||
check_output_header( msg, expected5, -1, strstr(expected5, "urn:uuid:") - expected5, 46, __LINE__ );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2, WS_ADDRESSING_VERSION_1_0, NULL, 0, &msg,
|
||||
NULL );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2, WS_ADDRESSING_VERSION_TRANSPORT, 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 );
|
||||
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 );
|
||||
check_output_header( msg, expected6, -1, 0, 0, __LINE__ );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_1_0, 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 );
|
||||
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 );
|
||||
check_output_header( msg, expected7, -1, strstr(expected7, "urn:uuid:") - expected7, 46, __LINE__ );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_1_0, NULL, 0, &msg, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
hr = WsInitializeMessage( msg, WS_BLANK_MESSAGE, NULL, 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 );
|
||||
check_output_header( msg, expected8, -1, 0, 0, __LINE__ );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2, WS_ADDRESSING_VERSION_1_0, 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 );
|
||||
WsFreeMessage( msg );
|
||||
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_NONE, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg,
|
||||
NULL );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_NONE, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_NONE, WS_ADDRESSING_VERSION_1_0, NULL, 0, &msg,
|
||||
NULL );
|
||||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_NONE, WS_ADDRESSING_VERSION_1_0, NULL, 0, &msg, NULL );
|
||||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
WsFreeWriter( writer );
|
||||
}
|
||||
|
@ -1197,9 +1238,19 @@ static void test_WsResetMessage(void)
|
|||
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
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_EMPTY, "got %u\n", state );
|
||||
|
||||
hr = WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
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_INITIALIZED, "got %u\n", state );
|
||||
|
||||
hr = WsResetMessage( msg, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
|
|
Loading…
Reference in a new issue