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

webservices: Detect when a message contains a fault in read_envelope_start.

parent 42980ed2
...@@ -42,6 +42,10 @@ static const struct prop_desc msg_props[] = ...@@ -42,6 +42,10 @@ static const struct prop_desc msg_props[] =
{ sizeof(WS_XML_READER *), TRUE }, /* WS_MESSAGE_PROPERTY_BODY_READER */ { sizeof(WS_XML_READER *), TRUE }, /* WS_MESSAGE_PROPERTY_BODY_READER */
{ sizeof(WS_XML_WRITER *), TRUE }, /* WS_MESSAGE_PROPERTY_BODY_WRITER */ { sizeof(WS_XML_WRITER *), TRUE }, /* WS_MESSAGE_PROPERTY_BODY_WRITER */
{ sizeof(BOOL), TRUE }, /* WS_MESSAGE_PROPERTY_IS_ADDRESSED */ { sizeof(BOOL), TRUE }, /* WS_MESSAGE_PROPERTY_IS_ADDRESSED */
{ sizeof(WS_HEAP_PROPERTIES), TRUE }, /* WS_MESSAGE_PROPERTY_HEAP_PROPERTIES */
{ sizeof(WS_XML_READER_PROPERTIES), TRUE }, /* WS_MESSAGE_PROPERTY_XML_READER_PROPERTIES */
{ sizeof(WS_XML_WRITER_PROPERTIES), TRUE }, /* WS_MESSAGE_PROPERTY_XML_WRITER_PROPERTIES */
{ sizeof(BOOL), FALSE }, /* WS_MESSAGE_PROPERTY_IS_FAULT */
}; };
struct header struct header
...@@ -122,6 +126,7 @@ static void free_header( struct header *header ) ...@@ -122,6 +126,7 @@ static void free_header( struct header *header )
static void reset_msg( struct msg *msg ) static void reset_msg( struct msg *msg )
{ {
BOOL isfault = FALSE;
ULONG i; ULONG i;
msg->state = WS_MESSAGE_STATE_EMPTY; msg->state = WS_MESSAGE_STATE_EMPTY;
...@@ -150,6 +155,8 @@ static void reset_msg( struct msg *msg ) ...@@ -150,6 +155,8 @@ static void reset_msg( struct msg *msg )
memset( &msg->ctx_send, 0, sizeof(msg->ctx_send) ); memset( &msg->ctx_send, 0, sizeof(msg->ctx_send) );
memset( &msg->ctx_receive, 0, sizeof(msg->ctx_receive) ); memset( &msg->ctx_receive, 0, sizeof(msg->ctx_receive) );
prop_set( msg->prop, msg->prop_count, WS_MESSAGE_PROPERTY_IS_FAULT, &isfault, sizeof(isfault) );
} }
static void free_msg( struct msg *msg ) static void free_msg( struct msg *msg )
...@@ -375,6 +382,13 @@ HRESULT WINAPI WsGetMessageProperty( WS_MESSAGE *handle, WS_MESSAGE_PROPERTY_ID ...@@ -375,6 +382,13 @@ HRESULT WINAPI WsGetMessageProperty( WS_MESSAGE *handle, WS_MESSAGE_PROPERTY_ID
else *(BOOL *)buf = msg->is_addressed; else *(BOOL *)buf = msg->is_addressed;
break; break;
case WS_MESSAGE_PROPERTY_HEAP_PROPERTIES:
case WS_MESSAGE_PROPERTY_XML_READER_PROPERTIES:
case WS_MESSAGE_PROPERTY_XML_WRITER_PROPERTIES:
FIXME( "property %u not supported\n", id );
hr = E_NOTIMPL;
break;
default: default:
hr = prop_get( msg->prop, msg->prop_count, id, buf, size ); hr = prop_get( msg->prop, msg->prop_count, id, buf, size );
} }
...@@ -877,6 +891,18 @@ static BOOL match_current_element( WS_XML_READER *reader, const WS_XML_STRING *l ...@@ -877,6 +891,18 @@ static BOOL match_current_element( WS_XML_READER *reader, const WS_XML_STRING *l
return WsXmlStringEquals( elem->localName, localname, NULL ) == S_OK; return WsXmlStringEquals( elem->localName, localname, NULL ) == S_OK;
} }
static BOOL match_current_element_with_ns( WS_XML_READER *reader, const WS_XML_STRING *localname, const WS_XML_STRING *ns )
{
const WS_XML_NODE *node;
const WS_XML_ELEMENT_NODE *elem;
if (WsGetReaderNode( reader, &node, NULL ) != S_OK) return FALSE;
if (node->nodeType != WS_XML_NODE_TYPE_ELEMENT) return FALSE;
elem = (const WS_XML_ELEMENT_NODE *)node;
return WsXmlStringEquals( elem->localName, localname, NULL ) == S_OK &&
WsXmlStringEquals( elem->ns, ns, NULL ) == S_OK;
}
static HRESULT read_message_id( WS_XML_READER *reader, GUID *ret ) static HRESULT read_message_id( WS_XML_READER *reader, GUID *ret )
{ {
const WS_XML_NODE *node; const WS_XML_NODE *node;
...@@ -914,6 +940,9 @@ static HRESULT read_envelope_start( struct msg *msg, WS_XML_READER *reader ) ...@@ -914,6 +940,9 @@ static HRESULT read_envelope_start( struct msg *msg, WS_XML_READER *reader )
{ {
static const WS_XML_STRING envelope = {8, (BYTE *)"Envelope"}, body = {4, (BYTE *)"Body"}; static const WS_XML_STRING envelope = {8, (BYTE *)"Envelope"}, body = {4, (BYTE *)"Body"};
static const WS_XML_STRING header = {6, (BYTE *)"Header"}, msgid = {9, (BYTE *)"MessageID"}; static const WS_XML_STRING header = {6, (BYTE *)"Header"}, msgid = {9, (BYTE *)"MessageID"};
static const WS_XML_STRING fault = {5, (BYTE *)"Fault"};
const WS_XML_STRING *ns_env = get_env_namespace( msg->version_env );
BOOL isfault;
HRESULT hr; HRESULT hr;
if ((hr = WsReadNode( reader, NULL )) != S_OK) return hr; if ((hr = WsReadNode( reader, NULL )) != S_OK) return hr;
...@@ -930,7 +959,10 @@ static HRESULT read_envelope_start( struct msg *msg, WS_XML_READER *reader ) ...@@ -930,7 +959,10 @@ static HRESULT read_envelope_start( struct msg *msg, WS_XML_READER *reader )
} }
} }
if (!match_current_element( reader, &body )) return WS_E_INVALID_FORMAT; if (!match_current_element( reader, &body )) return WS_E_INVALID_FORMAT;
return WsReadNode( reader, NULL ); if ((hr = WsReadNode( reader, NULL )) != S_OK) return hr;
isfault = match_current_element_with_ns( reader, &fault, ns_env );
return prop_set( msg->prop, msg->prop_count, WS_MESSAGE_PROPERTY_IS_FAULT, &isfault, sizeof(isfault) );
} }
/************************************************************************** /**************************************************************************
......
...@@ -1071,10 +1071,14 @@ static void test_WsReadEnvelopeStart(void) ...@@ -1071,10 +1071,14 @@ static void test_WsReadEnvelopeStart(void)
{ {
static const char xml[] = static const char xml[] =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body/></s:Envelope>"; "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body/></s:Envelope>";
WS_MESSAGE *msg, *msg2; static const char faultxml[] =
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
"<s:Fault/></s:Body></s:Envelope>";
WS_MESSAGE *msg, *msg2, *msg3;
WS_XML_READER *reader; WS_XML_READER *reader;
WS_MESSAGE_STATE state; WS_MESSAGE_STATE state;
const WS_XML_NODE *node; const WS_XML_NODE *node;
BOOL isfault;
HRESULT hr; HRESULT hr;
hr = WsReadEnvelopeStart( NULL, NULL, NULL, NULL, NULL ); hr = WsReadEnvelopeStart( NULL, NULL, NULL, NULL, NULL );
...@@ -1127,8 +1131,23 @@ static void test_WsReadEnvelopeStart(void) ...@@ -1127,8 +1131,23 @@ static void test_WsReadEnvelopeStart(void)
ok( hr == S_OK, "got %#lx\n", hr ); ok( hr == S_OK, "got %#lx\n", hr );
ok( node->nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType ); ok( node->nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType );
hr = WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1, WS_ADDRESSING_VERSION_0_9, NULL, 0, &msg3, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
hr = set_input( reader, faultxml, strlen(faultxml) );
ok( hr == S_OK, "got %#lx\n", hr );
hr = WsReadEnvelopeStart( msg3, reader, NULL, NULL, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
isfault = FALSE;
hr = WsGetMessageProperty( msg3, WS_MESSAGE_PROPERTY_IS_FAULT, &isfault, sizeof(isfault), NULL );
ok( hr == S_OK, "got %#lx\n", hr );
ok( isfault, "isfault == FALSE\n" );
WsFreeMessage( msg ); WsFreeMessage( msg );
WsFreeMessage( msg2 ); WsFreeMessage( msg2 );
WsFreeMessage( msg3 );
WsFreeReader( reader ); WsFreeReader( reader );
} }
......
...@@ -113,6 +113,11 @@ typedef struct _WS_HEAP_PROPERTY { ...@@ -113,6 +113,11 @@ typedef struct _WS_HEAP_PROPERTY {
ULONG valueSize; ULONG valueSize;
} WS_HEAP_PROPERTY; } WS_HEAP_PROPERTY;
typedef struct _WS_HEAP_PROPERTIES {
WS_HEAP_PROPERTY *properties;
ULONG propertyCount;
} WS_HEAP_PROPERTIES;
typedef ULONG WS_XML_BUFFER_PROPERTY_ID; typedef ULONG WS_XML_BUFFER_PROPERTY_ID;
typedef struct _WS_XML_BUFFER_PROPERTY { typedef struct _WS_XML_BUFFER_PROPERTY {
...@@ -145,6 +150,11 @@ typedef struct _WS_XML_READER_PROPERTY { ...@@ -145,6 +150,11 @@ typedef struct _WS_XML_READER_PROPERTY {
ULONG valueSize; ULONG valueSize;
} WS_XML_READER_PROPERTY; } WS_XML_READER_PROPERTY;
typedef struct _WS_XML_READER_PROPERTIES {
WS_XML_READER_PROPERTY *properties;
ULONG propertyCount;
} WS_XML_READER_PROPERTIES;
typedef enum { typedef enum {
WS_XML_WRITER_PROPERTY_MAX_DEPTH, WS_XML_WRITER_PROPERTY_MAX_DEPTH,
WS_XML_WRITER_PROPERTY_ALLOW_FRAGMENT, WS_XML_WRITER_PROPERTY_ALLOW_FRAGMENT,
...@@ -173,6 +183,11 @@ typedef struct _WS_XML_WRITER_PROPERTY { ...@@ -173,6 +183,11 @@ typedef struct _WS_XML_WRITER_PROPERTY {
ULONG valueSize; ULONG valueSize;
} WS_XML_WRITER_PROPERTY; } WS_XML_WRITER_PROPERTY;
typedef struct _WS_XML_WRITER_PROPERTIES {
WS_XML_WRITER_PROPERTY *properties;
ULONG propertyCount;
} WS_XML_WRITER_PROPERTIES;
typedef struct _WS_BYTES { typedef struct _WS_BYTES {
ULONG length; ULONG length;
BYTE *bytes; BYTE *bytes;
......
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