Hans Leidekker : webservices: Implement WsReadEnvelopeStart.

Alexandre Julliard julliard at winehq.org
Wed Aug 31 11:02:42 CDT 2016


Module: wine
Branch: master
Commit: a8c343552b0eda441a5941d4f525531d024f9418
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a8c343552b0eda441a5941d4f525531d024f9418

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Aug 31 14:35:32 2016 +0200

webservices: Implement WsReadEnvelopeStart.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/webservices/msg.c            | 52 +++++++++++++++++++++++++++++++++++
 dlls/webservices/tests/msg.c      | 58 +++++++++++++++++++++++++++++++++++++++
 dlls/webservices/webservices.spec |  2 +-
 include/webservices.h             |  2 ++
 4 files changed, 113 insertions(+), 1 deletion(-)

diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c
index a27ddbd..2004c70 100644
--- a/dlls/webservices/msg.c
+++ b/dlls/webservices/msg.c
@@ -75,6 +75,7 @@ struct msg
     WS_XML_BUFFER            *buf;
     WS_XML_WRITER            *writer;
     WS_XML_WRITER            *writer_body;
+    WS_XML_READER            *reader_body;
     ULONG                     header_count;
     ULONG                     header_size;
     struct header           **header;
@@ -536,6 +537,57 @@ HRESULT WINAPI WsWriteBody( WS_MESSAGE *handle, const WS_ELEMENT_DESCRIPTION *de
     return hr;
 }
 
+static BOOL match_current_element( WS_XML_READER *reader, const WS_XML_STRING *localname )
+{
+    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;
+}
+
+static HRESULT read_envelope_start( WS_XML_READER *reader )
+{
+    static const WS_XML_STRING envelope = {8, (BYTE *)"Envelope"}, body = {4, (BYTE *)"Body"};
+    HRESULT hr;
+
+    if ((hr = WsReadNode( reader, NULL )) != S_OK) return hr;
+    if (!match_current_element( reader, &envelope )) return WS_E_INVALID_FORMAT;
+    /* FIXME: read headers */
+    if ((hr = WsReadNode( reader, NULL )) != S_OK) return hr;
+    if (!match_current_element( reader, &body )) return WS_E_INVALID_FORMAT;
+    return WsReadNode( reader, NULL );
+}
+
+/**************************************************************************
+ *          WsReadEnvelopeStart		[webservices.@]
+ */
+HRESULT WINAPI WsReadEnvelopeStart( WS_MESSAGE *handle, WS_XML_READER *reader, WS_MESSAGE_DONE_CALLBACK cb,
+                                    void *state, WS_ERROR *error )
+{
+    struct msg *msg = (struct msg *)handle;
+    HRESULT hr;
+
+    TRACE( "%p %p %p %p %p\n", handle, reader, cb, state, error );
+    if (error) FIXME( "ignoring error parameter\n" );
+    if (cb)
+    {
+        FIXME( "callback not supported\n" );
+        return E_NOTIMPL;
+    }
+
+    if (!handle || !reader) return E_INVALIDARG;
+    if (msg->state != WS_MESSAGE_STATE_EMPTY) return WS_E_INVALID_OPERATION;
+
+    if ((hr = read_envelope_start( reader )) != S_OK) return hr;
+
+    msg->reader_body = reader;
+    msg->state       = WS_MESSAGE_STATE_READING;
+    return S_OK;
+}
+
 /**************************************************************************
  *          WsInitializeMessage		[webservices.@]
  */
diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c
index af7f609..a31ed94 100644
--- a/dlls/webservices/tests/msg.c
+++ b/dlls/webservices/tests/msg.c
@@ -859,6 +859,63 @@ static void test_WsRemoveCustomHeader(void)
     WsFreeMessage( msg );
 }
 
+static HRESULT set_input( WS_XML_READER *reader, const char *data, ULONG size )
+{
+    WS_XML_READER_TEXT_ENCODING text = {{WS_XML_READER_ENCODING_TYPE_TEXT}, WS_CHARSET_AUTO};
+    WS_XML_READER_BUFFER_INPUT buf;
+
+    buf.input.inputType = WS_XML_READER_INPUT_TYPE_BUFFER;
+    buf.encodedData     = (void *)data;
+    buf.encodedDataSize = size;
+    return WsSetInput( reader, &text.encoding, &buf.input, NULL, 0, NULL );
+}
+
+static void test_WsReadEnvelopeStart(void)
+{
+    static const char xml[] =
+        "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body/></s:Envelope>";
+    WS_MESSAGE *msg, *msg2;
+    WS_XML_READER *reader;
+    WS_MESSAGE_STATE state;
+    HRESULT hr;
+
+    hr = WsReadEnvelopeStart( NULL, NULL, NULL, NULL, 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 = WsReadEnvelopeStart( msg, NULL, NULL, NULL, NULL );
+    ok( hr == E_INVALIDARG, "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 = WsReadEnvelopeStart( msg, reader, NULL, NULL, NULL );
+    ok( hr == WS_E_INVALID_OPERATION, "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 = 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 );
+
+    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 );
+
+    WsFreeMessage( msg );
+    WsFreeMessage( msg2 );
+    WsFreeReader( reader );
+}
+
 START_TEST(msg)
 {
     test_WsCreateMessage();
@@ -874,4 +931,5 @@ START_TEST(msg)
     test_WsRemoveMappedHeader();
     test_WsAddCustomHeader();
     test_WsRemoveCustomHeader();
+    test_WsReadEnvelopeStart();
 }
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index fb9a1bc..6354243 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -112,7 +112,7 @@
 @ stdcall WsReadEndElement(ptr ptr)
 @ stub WsReadEndpointAddressExtension
 @ stub WsReadEnvelopeEnd
-@ stub WsReadEnvelopeStart
+@ stdcall WsReadEnvelopeStart(ptr ptr ptr ptr ptr)
 @ stub WsReadMessageEnd
 @ stub WsReadMessageStart
 @ stub WsReadMetadata
diff --git a/include/webservices.h b/include/webservices.h
index 8e1270f..3a06ab5 100644
--- a/include/webservices.h
+++ b/include/webservices.h
@@ -1444,6 +1444,8 @@ HRESULT WINAPI WsReadElement(WS_XML_READER*, const WS_ELEMENT_DESCRIPTION*, WS_R
                              WS_HEAP*, void*, ULONG, WS_ERROR*);
 HRESULT WINAPI WsReadEndAttribute(WS_XML_READER*, WS_ERROR*);
 HRESULT WINAPI WsReadEndElement(WS_XML_READER*, WS_ERROR*);
+HRESULT WINAPI WsReadEnvelopeStart(WS_MESSAGE*, WS_XML_READER*, WS_MESSAGE_DONE_CALLBACK, void*,
+                                   WS_ERROR*);
 HRESULT WINAPI WsReadNode(WS_XML_READER*, WS_ERROR*);
 HRESULT WINAPI WsReadStartAttribute(WS_XML_READER*, ULONG, WS_ERROR*);
 HRESULT WINAPI WsReadStartElement(WS_XML_READER*, WS_ERROR*);




More information about the wine-cvs mailing list