Commit a8d7d1e0 authored by Shaun Ren's avatar Shaun Ren Committed by Alexandre Julliard

webservices: Write the correct headers when a request message is addressed.

parent 86895f07
......@@ -625,23 +625,25 @@ static HRESULT write_headers( struct msg *msg, WS_MESSAGE_INITIALIZATION init, W
if ((hr = write_action_header( writer, prefix_env, ns_env, prefix_addr, ns_addr, msg->action )) != S_OK)
return hr;
if (init == WS_REPLY_MESSAGE)
if (init == WS_REPLY_MESSAGE || init == WS_FAULT_MESSAGE)
{
if ((hr = write_relatesto_header( writer, prefix_env, ns_env, prefix_addr, ns_addr, &msg->id_req )) != S_OK)
return hr;
}
else if (msg->addr.length)
{
if ((hr = write_to_header( writer, prefix_env, ns_env, prefix_addr, ns_addr, &msg->addr )) != S_OK)
return hr;
}
else
{
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 (init == WS_REQUEST_MESSAGE)
{
if ((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;
}
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;
if (msg->addr.length &&
(hr = write_to_header(writer, prefix_env, ns_env, prefix_addr, ns_addr, &msg->addr)) != S_OK)
return hr;
}
for (i = 0; i < msg->header_count; i++)
......
......@@ -408,10 +408,26 @@ static void test_WsWriteEnvelopeStart(void)
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>";
static const char expected9[] =
"<s:Envelope xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" "
"xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header>"
"<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
"<a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>"
"</a:ReplyTo><a:To s:mustUnderstand=\"1\">http://localhost/</a:To></s:Header><s:Body/></s:Envelope>";
static const char expected10[] =
"<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>"
"<a:To s:mustUnderstand=\"1\">http://localhost/</a:To></s:Header><s:Body/></s:Envelope>";
HRESULT hr;
WS_MESSAGE *msg;
WS_XML_WRITER *writer;
WS_MESSAGE_STATE state;
WS_ENDPOINT_ADDRESS addr;
memset( &addr, 0, sizeof(addr) );
addr.url.chars = (WCHAR *) L"http://localhost/";
addr.url.length = 17;
hr = WsWriteEnvelopeStart( NULL, NULL, NULL, NULL, NULL );
ok( hr == E_INVALIDARG, "got %#lx\n", hr );
......@@ -509,6 +525,30 @@ static void test_WsWriteEnvelopeStart(void)
check_output_header( msg, expected8, -1, 0, 0, __LINE__ );
WsFreeMessage( msg );
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
hr = WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
hr = WsAddressMessage( msg, &addr, NULL );
hr = set_output( writer );
ok( hr == S_OK, "got %#lx\n", hr );
hr = WsWriteEnvelopeStart( msg, writer, NULL, NULL, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
check_output_header( msg, expected9, -1, strstr(expected9, "urn:uuid:") - expected9, 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 %#lx\n", hr );
hr = WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
hr = WsAddressMessage( msg, &addr, NULL );
hr = set_output( writer );
ok( hr == S_OK, "got %#lx\n", hr );
hr = WsWriteEnvelopeStart( msg, writer, NULL, NULL, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
check_output_header( msg, expected10, -1, strstr(expected10, "urn:uuid:") - expected10, 46, __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 %#lx\n", hr );
hr = WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
......
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