webservices: Implement WS_ADDRESSING_VERSION_TRANSPORT.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-08-16 12:30:36 +02:00 committed by Alexandre Julliard
parent ac42d70121
commit 0f227b2244
2 changed files with 32 additions and 6 deletions

View File

@ -349,6 +349,11 @@ static HRESULT get_addr_namespace( WS_ADDRESSING_VERSION ver, WS_XML_STRING *str
str->length = sizeof(ns_addr_1_0)/sizeof(ns_addr_1_0[0]) - 1;
return S_OK;
case WS_ADDRESSING_VERSION_TRANSPORT:
str->bytes = NULL;
str->length = 0;
return S_OK;
default:
ERR( "unhandled addressing version %u\n", ver );
return E_NOTIMPL;
@ -409,14 +414,18 @@ static HRESULT write_envelope_start( struct msg *msg, WS_XML_WRITER *writer )
if ((hr = get_addr_namespace( msg->version_addr, &ns_addr )) != S_OK) return hr;
if ((hr = WsWriteStartElement( writer, &prefix_s, &envelope, &ns_env, NULL )) != S_OK) return hr;
if ((hr = WsWriteXmlnsAttribute( writer, &prefix_a, &ns_addr, FALSE, NULL )) != S_OK) return hr;
if (msg->version_addr < WS_ADDRESSING_VERSION_TRANSPORT &&
(hr = WsWriteXmlnsAttribute( writer, &prefix_a, &ns_addr, FALSE, NULL )) != S_OK) return hr;
if ((hr = WsWriteStartElement( writer, &prefix_s, &header, &ns_env, NULL )) != S_OK) return hr;
if ((hr = WsWriteStartElement( writer, &prefix_a, &msgid, &ns_addr, NULL )) != S_OK) return hr;
urn.text.textType = WS_XML_TEXT_TYPE_UNIQUE_ID;
memcpy( &urn.value, &msg->id, sizeof(msg->id) );
if ((hr = WsWriteText( writer, &urn.text, NULL )) != S_OK) return hr;
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </a:MessageID> */
if (msg->version_addr < WS_ADDRESSING_VERSION_TRANSPORT)
{
if ((hr = WsWriteStartElement( writer, &prefix_a, &msgid, &ns_addr, NULL )) != S_OK) return hr;
urn.text.textType = WS_XML_TEXT_TYPE_UNIQUE_ID;
memcpy( &urn.value, &msg->id, sizeof(msg->id) );
if ((hr = WsWriteText( writer, &urn.text, NULL )) != S_OK) return hr;
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </a:MessageID> */
}
for (i = 0; i < msg->header_count; i++)
{

View File

@ -339,6 +339,8 @@ static void test_WsWriteEnvelopeStart(void)
"<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></s:Header><s:Body/></s:Envelope>";
static const char expected3[] =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header/><s:Body/></s:Envelope>";
HRESULT hr;
WS_MESSAGE *msg;
WS_XML_WRITER *writer;
@ -375,6 +377,21 @@ static void test_WsWriteEnvelopeStart(void)
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_STATE, &state, sizeof(state), NULL );
ok( hr == S_OK, "got %08x\n", hr );
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 );
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, expected3, -1, 0, 0, __LINE__ );
WsFreeMessage( msg );
WsFreeWriter( writer );