From 0f227b2244fa1b83d95f18ab4d6ee81da178c7b7 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 16 Aug 2016 12:30:36 +0200 Subject: [PATCH] webservices: Implement WS_ADDRESSING_VERSION_TRANSPORT. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/msg.c | 21 +++++++++++++++------ dlls/webservices/tests/msg.c | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c index 2bac6e036fb..9a196222513 100644 --- a/dlls/webservices/msg.c +++ b/dlls/webservices/msg.c @@ -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; /* */ + 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; /* */ + } for (i = 0; i < msg->header_count; i++) { diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c index a42d36972af..5a0e8b2a587 100644 --- a/dlls/webservices/tests/msg.c +++ b/dlls/webservices/tests/msg.c @@ -339,6 +339,8 @@ static void test_WsWriteEnvelopeStart(void) "urn:uuid:00000000-0000-0000-0000-000000000000" "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous" ""; + static const char expected3[] = + ""; 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 );