Hans Leidekker : webservices: Implement WsReadBody.
Alexandre Julliard
julliard at winehq.org
Wed Aug 31 11:02:42 CDT 2016
Module: wine
Branch: master
Commit: 23a64ca074021bfda46f6287aaa529d6e8f66774
URL: http://source.winehq.org/git/wine.git/?a=commit;h=23a64ca074021bfda46f6287aaa529d6e8f66774
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Aug 31 14:35:34 2016 +0200
webservices: Implement WsReadBody.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/webservices/msg.c | 17 ++++++++
dlls/webservices/tests/msg.c | 90 +++++++++++++++++++++++++++++++++++++++
dlls/webservices/webservices.spec | 2 +-
include/webservices.h | 2 +
4 files changed, 110 insertions(+), 1 deletion(-)
diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c
index 27dbddd..4a47fd3 100644
--- a/dlls/webservices/msg.c
+++ b/dlls/webservices/msg.c
@@ -616,6 +616,23 @@ HRESULT WINAPI WsReadEnvelopeEnd( WS_MESSAGE *handle, WS_ERROR *error )
}
/**************************************************************************
+ * WsReadBody [webservices.@]
+ */
+HRESULT WINAPI WsReadBody( WS_MESSAGE *handle, const WS_ELEMENT_DESCRIPTION *desc, WS_READ_OPTION option,
+ WS_HEAP *heap, void *value, ULONG size, WS_ERROR *error )
+{
+ struct msg *msg = (struct msg *)handle;
+
+ TRACE( "%p %p %08x %p %p %u %p\n", handle, desc, option, heap, value, size, error );
+ if (error) FIXME( "ignoring error parameter\n" );
+
+ if (!handle || !desc) return E_INVALIDARG;
+ if (msg->state != WS_MESSAGE_STATE_READING) return WS_E_INVALID_OPERATION;
+
+ return WsReadElement( msg->reader_body, desc, option, heap, value, size, NULL );
+}
+
+/**************************************************************************
* WsInitializeMessage [webservices.@]
*/
HRESULT WINAPI WsInitializeMessage( WS_MESSAGE *handle, WS_MESSAGE_INITIALIZATION init,
diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c
index 99db9e6..0a8456a 100644
--- a/dlls/webservices/tests/msg.c
+++ b/dlls/webservices/tests/msg.c
@@ -962,6 +962,95 @@ static void test_WsReadEnvelopeEnd(void)
WsFreeReader( reader );
}
+static void test_WsReadBody(void)
+{
+ static const char xml[] =
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
+ "<u xmlns=\"ns\"><val>1</val></u></s:Body></s:Envelope>";
+ WS_HEAP *heap;
+ WS_MESSAGE *msg, *msg2;
+ WS_XML_READER *reader;
+ WS_MESSAGE_STATE state;
+ WS_XML_STRING localname = {1, (BYTE *)"t"}, localname2 = {1, (BYTE *)"u"};
+ WS_XML_STRING val = {3, (BYTE *)"val"}, ns = {2, (BYTE *)"ns"};
+ WS_ELEMENT_DESCRIPTION desc;
+ WS_STRUCT_DESCRIPTION s;
+ WS_FIELD_DESCRIPTION f, *fields[1];
+ struct test
+ {
+ UINT32 val;
+ } test;
+ HRESULT hr;
+
+ hr = WsCreateHeap( 1 << 16, 0, NULL, 0, &heap, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsReadBody( NULL, NULL, 0, NULL, NULL, 0, NULL );
+ ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
+ hr = WsCreateMessage( WS_ADDRESSING_VERSION_0_9, WS_ENVELOPE_VERSION_SOAP_1_1, NULL, 0, &msg, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsCreateReader( NULL, 0, &reader, 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 = WsCreateMessage( WS_ADDRESSING_VERSION_0_9, WS_ENVELOPE_VERSION_SOAP_1_1, NULL, 0, &msg2, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsReadBody( msg2, NULL, 0, NULL, NULL, 0, NULL );
+ ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
+ hr = set_input( reader, xml, strlen(xml) );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsReadEnvelopeStart( msg2, reader, NULL, NULL, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsReadBody( msg2, NULL, WS_READ_REQUIRED_VALUE, heap, &test, sizeof(test), NULL );
+ ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
+ memset( &f, 0, sizeof(f) );
+ f.mapping = WS_ELEMENT_FIELD_MAPPING;
+ f.localName = &val;
+ f.ns = &ns;
+ f.type = WS_UINT32_TYPE;
+ fields[0] = &f;
+
+ memset( &s, 0, sizeof(s) );
+ s.size = sizeof(struct test);
+ s.alignment = TYPE_ALIGNMENT(struct test);
+ s.fields = fields;
+ s.fieldCount = 1;
+ s.typeLocalName = &localname;
+ s.typeNs = &ns;
+
+ desc.elementLocalName = &localname2;
+ desc.elementNs = &ns;
+ desc.type = WS_STRUCT_TYPE;
+ desc.typeDescription = &s;
+
+ memset( &test, 0, sizeof(test) );
+ hr = WsReadBody( msg2, &desc, WS_READ_REQUIRED_VALUE, heap, &test, sizeof(test), NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( test.val == 1, "got %u\n", test.val );
+
+ state = 0xdeadbeef;
+ hr = WsGetMessageProperty( msg2, WS_MESSAGE_PROPERTY_STATE, &state, sizeof(state), NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( state == WS_MESSAGE_STATE_READING, "got %u\n", state );
+
+ hr = WsReadEnvelopeEnd( msg2, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ WsFreeMessage( msg );
+ WsFreeMessage( msg2 );
+ WsFreeReader( reader );
+ WsFreeHeap( heap );
+}
+
START_TEST(msg)
{
test_WsCreateMessage();
@@ -979,4 +1068,5 @@ START_TEST(msg)
test_WsRemoveCustomHeader();
test_WsReadEnvelopeStart();
test_WsReadEnvelopeEnd();
+ test_WsReadBody();
}
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index a0f88ac..cda787d 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -103,7 +103,7 @@
@ stub WsPushBytes
@ stub WsReadArray
@ stub WsReadAttribute
-@ stub WsReadBody
+@ stdcall WsReadBody(ptr ptr long ptr ptr long ptr)
@ stub WsReadBytes
@ stub WsReadChars
@ stub WsReadCharsUtf8
diff --git a/include/webservices.h b/include/webservices.h
index dbaa5d1..5decf68 100644
--- a/include/webservices.h
+++ b/include/webservices.h
@@ -1440,6 +1440,8 @@ HRESULT WINAPI WsOpenServiceProxy(WS_SERVICE_PROXY*, const WS_ENDPOINT_ADDRESS*,
WS_ERROR*);
HRESULT WINAPI WsReadAttribute(WS_XML_READER*, const WS_ATTRIBUTE_DESCRIPTION*, WS_READ_OPTION,
WS_HEAP*, void*, ULONG, WS_ERROR*);
+HRESULT WINAPI WsReadBody(WS_MESSAGE*, const WS_ELEMENT_DESCRIPTION*, WS_READ_OPTION, WS_HEAP*, void*,
+ ULONG, WS_ERROR*);
HRESULT WINAPI WsReadElement(WS_XML_READER*, const WS_ELEMENT_DESCRIPTION*, WS_READ_OPTION,
WS_HEAP*, void*, ULONG, WS_ERROR*);
HRESULT WINAPI WsReadEndAttribute(WS_XML_READER*, WS_ERROR*);
More information about the wine-cvs
mailing list