Commit efcf63cc authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Don't write an empty header element for messages that have an action.

parent c7b606ea
...@@ -71,6 +71,7 @@ struct msg ...@@ -71,6 +71,7 @@ struct msg
WS_ADDRESSING_VERSION version_addr; WS_ADDRESSING_VERSION version_addr;
BOOL is_addressed; BOOL is_addressed;
WS_STRING addr; WS_STRING addr;
WS_STRING action;
WS_HEAP *heap; WS_HEAP *heap;
WS_XML_BUFFER *buf; WS_XML_BUFFER *buf;
WS_XML_WRITER *writer; WS_XML_WRITER *writer;
...@@ -118,6 +119,7 @@ static void free_msg( struct msg *msg ) ...@@ -118,6 +119,7 @@ static void free_msg( struct msg *msg )
WsFreeWriter( msg->writer ); WsFreeWriter( msg->writer );
WsFreeHeap( msg->heap ); WsFreeHeap( msg->heap );
heap_free( msg->addr.chars ); heap_free( msg->addr.chars );
heap_free( msg->action.chars );
for (i = 0; i < msg->header_count; i++) free_header( msg->header[i] ); for (i = 0; i < msg->header_count; i++) free_header( msg->header[i] );
heap_free( msg->header ); heap_free( msg->header );
heap_free( msg ); heap_free( msg );
...@@ -404,33 +406,37 @@ static const WS_XML_STRING *get_header_name( WS_HEADER_TYPE type ) ...@@ -404,33 +406,37 @@ static const WS_XML_STRING *get_header_name( WS_HEADER_TYPE type )
} }
} }
static HRESULT write_envelope_start( struct msg *msg, WS_XML_WRITER *writer ) static HRESULT write_headers( struct msg *msg, const WS_XML_STRING *ns_env, const WS_XML_STRING *ns_addr,
WS_XML_WRITER *writer )
{ {
static const char anonymous[] = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"; static const char anonymous[] = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
static const WS_XML_STRING prefix_s = {1, (BYTE *)"s"}, prefix_a = {1, (BYTE *)"a"}; static const WS_XML_STRING prefix_s = {1, (BYTE *)"s"}, prefix_a = {1, (BYTE *)"a"};
static const WS_XML_STRING envelope = {8, (BYTE *)"Envelope"}, header = {6, (BYTE *)"Header"};
static const WS_XML_STRING msgid = {9, (BYTE *)"MessageID"}, replyto = {7, (BYTE *)"ReplyTo"}; static const WS_XML_STRING msgid = {9, (BYTE *)"MessageID"}, replyto = {7, (BYTE *)"ReplyTo"};
static const WS_XML_STRING address = {7, (BYTE *)"Address"}, body = {4, (BYTE *)"Body"}; static const WS_XML_STRING address = {7, (BYTE *)"Address"}, header = {6, (BYTE *)"Header"};
WS_XML_STRING ns_env, ns_addr;
WS_XML_UTF8_TEXT urn, addr; WS_XML_UTF8_TEXT urn, addr;
HRESULT hr; HRESULT hr;
ULONG i; ULONG i;
if ((hr = get_env_namespace( msg->version_env, &ns_env )) != S_OK) return hr; if ((hr = WsWriteXmlnsAttribute( writer, &prefix_a, ns_addr, FALSE, NULL )) != S_OK) return hr;
if ((hr = get_addr_namespace( msg->version_addr, &ns_addr )) != S_OK) return hr; if ((hr = WsWriteStartElement( writer, &prefix_s, &header, ns_env, NULL )) != S_OK) return hr;
if ((hr = WsWriteStartElement( writer, &prefix_s, &envelope, &ns_env, NULL )) != S_OK) return hr; if ((hr = WsWriteStartElement( writer, &prefix_a, &msgid, ns_addr, NULL )) != S_OK) return hr;
if (msg->version_addr < WS_ADDRESSING_VERSION_TRANSPORT && urn.text.textType = WS_XML_TEXT_TYPE_UNIQUE_ID;
(hr = WsWriteXmlnsAttribute( writer, &prefix_a, &ns_addr, FALSE, NULL )) != S_OK) return hr; memcpy( &urn.value, &msg->id, sizeof(msg->id) );
if ((hr = WsWriteStartElement( writer, &prefix_s, &header, &ns_env, NULL )) != S_OK) return hr; 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 (msg->version_addr == WS_ADDRESSING_VERSION_0_9)
{ {
if ((hr = WsWriteStartElement( writer, &prefix_a, &msgid, &ns_addr, NULL )) != S_OK) return hr; if ((hr = WsWriteStartElement( writer, &prefix_a, &replyto, ns_addr, NULL )) != S_OK) return hr;
urn.text.textType = WS_XML_TEXT_TYPE_UNIQUE_ID; if ((hr = WsWriteStartElement( writer, &prefix_a, &address, ns_addr, NULL )) != S_OK) return hr;
memcpy( &urn.value, &msg->id, sizeof(msg->id) );
if ((hr = WsWriteText( writer, &urn.text, NULL )) != S_OK) return hr; addr.text.textType = WS_XML_TEXT_TYPE_UTF8;
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </a:MessageID> */ addr.value.bytes = (BYTE *)anonymous;
addr.value.length = sizeof(anonymous) - 1;
if ((hr = WsWriteText( writer, &addr.text, NULL )) != S_OK) return hr;
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </a:Address> */
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </a:ReplyTo> */
} }
for (i = 0; i < msg->header_count; i++) for (i = 0; i < msg->header_count; i++)
...@@ -439,21 +445,46 @@ static HRESULT write_envelope_start( struct msg *msg, WS_XML_WRITER *writer ) ...@@ -439,21 +445,46 @@ static HRESULT write_envelope_start( struct msg *msg, WS_XML_WRITER *writer )
if ((hr = WsWriteXmlBuffer( writer, msg->header[i]->u.buf, NULL )) != S_OK) return hr; if ((hr = WsWriteXmlBuffer( writer, msg->header[i]->u.buf, NULL )) != S_OK) return hr;
} }
if (msg->version_addr == WS_ADDRESSING_VERSION_0_9) return WsWriteEndElement( writer, NULL ); /* </s:Header> */
{ }
if ((hr = WsWriteStartElement( writer, &prefix_a, &replyto, &ns_addr, NULL )) != S_OK) return hr;
if ((hr = WsWriteStartElement( writer, &prefix_a, &address, &ns_addr, NULL )) != S_OK) return hr;
addr.text.textType = WS_XML_TEXT_TYPE_UTF8; static HRESULT write_headers_transport( struct msg *msg, const WS_XML_STRING *ns_env, WS_XML_WRITER *writer )
addr.value.bytes = (BYTE *)anonymous; {
addr.value.length = sizeof(anonymous) - 1; static const WS_XML_STRING prefix = {1, (BYTE *)"s"}, header = {6, (BYTE *)"Header"};
if ((hr = WsWriteText( writer, &addr.text, NULL )) != S_OK) return hr; HRESULT hr;
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </a:Address> */ ULONG i;
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </a:ReplyTo> */
if ((msg->header_count || !msg->action.length) &&
(hr = WsWriteStartElement( writer, &prefix, &header, ns_env, NULL )) != S_OK) return hr;
for (i = 0; i < msg->header_count; i++)
{
if (msg->header[i]->mapped) continue;
if ((hr = WsWriteXmlBuffer( writer, msg->header[i]->u.buf, NULL )) != S_OK) return hr;
} }
if ((hr = WsWriteEndElement( writer, NULL )) != S_OK) return hr; /* </s:Header> */ if (msg->header_count || !msg->action.length) hr = WsWriteEndElement( writer, NULL ); /* </s:Header> */
return WsWriteStartElement( writer, &prefix_s, &body, &ns_env, NULL ); /* <s:Body> */ return hr;
}
static HRESULT write_envelope_start( struct msg *msg, WS_XML_WRITER *writer )
{
static const WS_XML_STRING envelope = {8, (BYTE *)"Envelope"}, body = {4, (BYTE *)"Body"};
static const WS_XML_STRING prefix = {1, (BYTE *)"s"};
WS_XML_STRING ns_env, ns_addr;
HRESULT hr;
if ((hr = get_env_namespace( msg->version_env, &ns_env )) != S_OK) return hr;
if ((hr = get_addr_namespace( msg->version_addr, &ns_addr )) != S_OK) return hr;
if ((hr = WsWriteStartElement( writer, &prefix, &envelope, &ns_env, NULL )) != S_OK) return hr;
if (msg->version_addr == WS_ADDRESSING_VERSION_TRANSPORT)
hr = write_headers_transport( msg, &ns_env, writer );
else
hr = write_headers( msg, &ns_env, &ns_addr, writer );
if (hr != S_OK) return hr;
return WsWriteStartElement( writer, &prefix, &body, &ns_env, NULL ); /* <s:Body> */
} }
static HRESULT write_envelope_end( WS_XML_WRITER *writer ) static HRESULT write_envelope_end( WS_XML_WRITER *writer )
......
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