2016-04-22 09:42:47 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "windows.h"
|
2016-09-28 12:38:05 +02:00
|
|
|
#include "winsock2.h"
|
2016-04-22 09:42:47 +02:00
|
|
|
#include "webservices.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2017-02-15 14:17:10 +01:00
|
|
|
static inline void set_field_desc( WS_FIELD_DESCRIPTION *desc, WS_FIELD_MAPPING mapping,
|
|
|
|
WS_XML_STRING *localname, WS_XML_STRING *ns, WS_TYPE type,
|
|
|
|
void *type_desc, ULONG offset, ULONG options, ULONG count_offset,
|
|
|
|
WS_XML_STRING *item_localname, WS_XML_STRING *item_ns )
|
|
|
|
{
|
|
|
|
memset( desc, 0, sizeof(*desc) );
|
|
|
|
desc->mapping = mapping;
|
|
|
|
desc->localName = localname;
|
|
|
|
desc->ns = ns;
|
|
|
|
desc->type = type;
|
|
|
|
desc->typeDescription = type_desc;
|
|
|
|
desc->offset = offset;
|
|
|
|
desc->options = options;
|
|
|
|
desc->countOffset = count_offset;
|
|
|
|
desc->itemLocalName = item_localname;
|
|
|
|
desc->itemNs = item_ns;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_struct_desc( WS_STRUCT_DESCRIPTION *desc, ULONG size, ULONG alignment,
|
|
|
|
WS_FIELD_DESCRIPTION **fields, ULONG count, WS_XML_STRING *localname,
|
2017-02-15 14:17:12 +01:00
|
|
|
WS_XML_STRING *ns, ULONG options )
|
2017-02-15 14:17:10 +01:00
|
|
|
{
|
|
|
|
memset( desc, 0, sizeof(*desc) );
|
|
|
|
desc->size = size;
|
|
|
|
desc->alignment = alignment;
|
|
|
|
desc->fields = fields;
|
|
|
|
desc->fieldCount = count;
|
|
|
|
desc->typeLocalName = localname;
|
|
|
|
desc->typeNs = ns;
|
2017-02-15 14:17:12 +01:00
|
|
|
desc->structOptions = options;
|
2017-02-15 14:17:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_elem_desc( WS_ELEMENT_DESCRIPTION *desc, WS_XML_STRING *localname, WS_XML_STRING *ns,
|
|
|
|
WS_TYPE type, void *type_desc )
|
|
|
|
{
|
|
|
|
desc->elementLocalName = localname;
|
|
|
|
desc->elementNs = ns;
|
|
|
|
desc->type = type;
|
|
|
|
desc->typeDescription = type_desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_msg_desc( WS_MESSAGE_DESCRIPTION *desc, WS_XML_STRING *action,
|
|
|
|
WS_ELEMENT_DESCRIPTION *elem_desc )
|
|
|
|
{
|
|
|
|
desc->action = action;
|
|
|
|
desc->bodyElementDescription = elem_desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_param_desc( WS_PARAMETER_DESCRIPTION *desc, WS_PARAMETER_TYPE type,
|
|
|
|
USHORT input_index, USHORT output_index )
|
|
|
|
{
|
|
|
|
desc->parameterType = type;
|
|
|
|
desc->inputMessageIndex = input_index;
|
|
|
|
desc->outputMessageIndex = output_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_op_desc( WS_OPERATION_DESCRIPTION *desc, WS_MESSAGE_DESCRIPTION *input_msg,
|
|
|
|
WS_MESSAGE_DESCRIPTION *output_msg, ULONG count,
|
|
|
|
WS_PARAMETER_DESCRIPTION *param_desc )
|
|
|
|
{
|
|
|
|
memset( desc, 0, sizeof(*desc) );
|
|
|
|
desc->versionInfo = 1;
|
|
|
|
desc->inputMessageDescription = input_msg;
|
|
|
|
desc->outputMessageDescription = output_msg;
|
|
|
|
desc->parameterCount = count;
|
|
|
|
desc->parameterDescription = param_desc;
|
|
|
|
}
|
|
|
|
|
2016-04-22 09:42:47 +02:00
|
|
|
static void test_WsCreateServiceProxy(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WS_SERVICE_PROXY *proxy;
|
|
|
|
WS_SERVICE_PROXY_STATE state;
|
2017-04-05 11:40:23 +02:00
|
|
|
ULONG value;
|
2016-04-22 09:42:47 +02:00
|
|
|
|
|
|
|
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
|
2016-09-28 12:38:05 +02:00
|
|
|
0, NULL, 0, NULL, NULL );
|
2016-04-22 09:42:47 +02:00
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
proxy = NULL;
|
|
|
|
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
|
2016-09-28 12:38:05 +02:00
|
|
|
0, NULL, 0, &proxy, NULL );
|
2016-04-22 09:42:47 +02:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( proxy != NULL, "proxy not set\n" );
|
|
|
|
|
|
|
|
/* write-only property */
|
|
|
|
value = 0xdeadbeef;
|
2017-04-05 11:40:23 +02:00
|
|
|
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_CALL_TIMEOUT, &value, sizeof(value), NULL );
|
2016-04-22 09:42:47 +02:00
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
state = 0xdeadbeef;
|
2017-04-05 11:40:23 +02:00
|
|
|
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
|
2016-04-22 09:42:47 +02:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
|
|
|
|
|
|
|
|
WsFreeServiceProxy( proxy );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_WsCreateServiceProxyFromTemplate(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WS_SERVICE_PROXY *proxy;
|
|
|
|
WS_HTTP_POLICY_DESCRIPTION policy;
|
|
|
|
|
|
|
|
hr = WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE_REQUEST, NULL, 0, WS_HTTP_BINDING_TEMPLATE_TYPE,
|
|
|
|
NULL, 0, NULL, 0, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE_REQUEST, NULL, 0, WS_HTTP_BINDING_TEMPLATE_TYPE,
|
|
|
|
NULL, 0, NULL, 0, &proxy, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
memset( &policy, 0, sizeof(policy) );
|
|
|
|
proxy = NULL;
|
|
|
|
hr = WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE_REQUEST, NULL, 0, WS_HTTP_BINDING_TEMPLATE_TYPE,
|
|
|
|
NULL, 0, &policy, sizeof(policy), &proxy, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( proxy != NULL, "proxy not set\n" );
|
|
|
|
|
|
|
|
WsFreeServiceProxy( proxy );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_WsOpenServiceProxy(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WS_SERVICE_PROXY *proxy;
|
2017-04-05 11:40:23 +02:00
|
|
|
WS_SERVICE_PROXY_STATE state;
|
2016-04-22 09:42:47 +02:00
|
|
|
WS_HTTP_POLICY_DESCRIPTION policy;
|
|
|
|
WS_ENDPOINT_ADDRESS addr;
|
|
|
|
|
|
|
|
memset( &policy, 0, sizeof(policy) );
|
|
|
|
hr = WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE_REQUEST, NULL, 0, WS_HTTP_BINDING_TEMPLATE_TYPE,
|
|
|
|
NULL, 0, &policy, sizeof(policy), &proxy, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2017-04-05 11:40:23 +02:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
|
|
|
|
|
|
|
|
memset( &addr, 0, sizeof(addr) );
|
2020-03-17 15:35:43 +01:00
|
|
|
addr.url.length = ARRAY_SIZE( L"http://localhost/" ) - 1;
|
|
|
|
addr.url.chars = (WCHAR *)L"http://localhost/";
|
2016-04-22 09:42:47 +02:00
|
|
|
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2017-04-05 11:40:23 +02:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == WS_SERVICE_PROXY_STATE_OPEN, "got %u\n", state );
|
|
|
|
|
2016-04-22 09:42:47 +02:00
|
|
|
hr = WsCloseServiceProxy( proxy , NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2017-04-05 11:40:23 +02:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == WS_SERVICE_PROXY_STATE_CLOSED, "got %u\n", state );
|
|
|
|
|
2016-04-22 09:42:47 +02:00
|
|
|
WsFreeServiceProxy( proxy );
|
|
|
|
}
|
|
|
|
|
2017-04-05 11:40:24 +02:00
|
|
|
static void test_WsResetServiceProxy(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WS_SERVICE_PROXY *proxy;
|
|
|
|
WS_ENDPOINT_ADDRESS addr;
|
|
|
|
WS_SERVICE_PROXY_STATE state;
|
|
|
|
|
|
|
|
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
|
|
|
|
0, NULL, 0, &proxy, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsResetServiceProxy( proxy, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
|
|
|
|
|
|
|
|
memset( &addr, 0, sizeof(addr) );
|
2020-03-17 15:35:43 +01:00
|
|
|
addr.url.length = ARRAY_SIZE( L"http://localhost/" ) - 1;
|
|
|
|
addr.url.chars = (WCHAR *)L"http://localhost/";
|
2017-04-05 11:40:24 +02:00
|
|
|
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsResetServiceProxy( proxy, NULL );
|
|
|
|
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCloseServiceProxy( proxy , NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsResetServiceProxy( proxy, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
|
|
|
|
|
|
|
|
WsFreeServiceProxy( proxy );
|
|
|
|
}
|
|
|
|
|
2016-09-28 12:38:05 +02:00
|
|
|
static HRESULT create_channel( int port, WS_CHANNEL **ret )
|
|
|
|
{
|
|
|
|
WS_CHANNEL_PROPERTY prop[2];
|
|
|
|
WS_ENVELOPE_VERSION env_version = WS_ENVELOPE_VERSION_SOAP_1_1;
|
|
|
|
WS_ADDRESSING_VERSION addr_version = WS_ADDRESSING_VERSION_TRANSPORT;
|
|
|
|
WS_CHANNEL *channel;
|
|
|
|
WS_ENDPOINT_ADDRESS addr;
|
|
|
|
WCHAR buf[64];
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
prop[0].id = WS_CHANNEL_PROPERTY_ENVELOPE_VERSION;
|
|
|
|
prop[0].value = &env_version;
|
|
|
|
prop[0].valueSize = sizeof(env_version);
|
|
|
|
|
|
|
|
prop[1].id = WS_CHANNEL_PROPERTY_ADDRESSING_VERSION;
|
|
|
|
prop[1].value = &addr_version;
|
|
|
|
prop[1].valueSize = sizeof(addr_version);
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, prop, 2, NULL, &channel, NULL );
|
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
|
2017-04-05 11:40:23 +02:00
|
|
|
memset( &addr, 0, sizeof(addr) );
|
2020-03-17 15:35:43 +01:00
|
|
|
addr.url.length = wsprintfW( buf, L"http://127.0.0.1:%u", port );
|
2016-09-28 12:38:05 +02:00
|
|
|
addr.url.chars = buf;
|
|
|
|
hr = WsOpenChannel( channel, &addr, NULL, NULL );
|
|
|
|
if (hr == S_OK) *ret = channel;
|
|
|
|
else WsFreeChannel( channel );
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char req_test1[] =
|
|
|
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
|
|
|
|
"<req_test1 xmlns=\"ns\">-1</req_test1>"
|
|
|
|
"</s:Body></s:Envelope>";
|
|
|
|
|
|
|
|
static const char resp_test1[] =
|
|
|
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
|
|
|
|
"<resp_test1 xmlns=\"ns\">-2</resp_test1>"
|
|
|
|
"</s:Body></s:Envelope>";
|
|
|
|
|
|
|
|
static void test_WsSendMessage( int port, WS_XML_STRING *action )
|
|
|
|
{
|
|
|
|
WS_XML_STRING req = {9, (BYTE *)"req_test1"}, ns = {2, (BYTE *)"ns"};
|
|
|
|
WS_CHANNEL *channel;
|
|
|
|
WS_MESSAGE *msg;
|
|
|
|
WS_ELEMENT_DESCRIPTION body;
|
|
|
|
WS_MESSAGE_DESCRIPTION desc;
|
|
|
|
INT32 val = -1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = create_channel( port, &channel );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2017-02-15 14:17:10 +01:00
|
|
|
set_elem_desc( &body, &req, &ns, WS_INT32_TYPE, NULL );
|
|
|
|
set_msg_desc( &desc, action, &body );
|
2016-09-28 12:38:05 +02:00
|
|
|
hr = WsSendMessage( NULL, msg, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsSendMessage( channel, NULL, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsSendMessage( channel, msg, NULL, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsSendMessage( channel, msg, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCloseChannel( channel, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
WsFreeChannel( channel );
|
|
|
|
WsFreeMessage( msg );
|
|
|
|
}
|
|
|
|
|
2016-09-28 12:38:06 +02:00
|
|
|
static void test_WsReceiveMessage( int port )
|
|
|
|
{
|
|
|
|
WS_XML_STRING req = {9, (BYTE *)"req_test1"}, resp = {10, (BYTE *)"resp_test1"}, ns = {2, (BYTE *)"ns"};
|
|
|
|
WS_CHANNEL *channel;
|
|
|
|
WS_MESSAGE *msg;
|
|
|
|
WS_ELEMENT_DESCRIPTION body;
|
|
|
|
WS_MESSAGE_DESCRIPTION desc_req, desc_resp;
|
|
|
|
const WS_MESSAGE_DESCRIPTION *desc[1];
|
|
|
|
INT32 val = -1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = create_channel( port, &channel );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2017-02-15 14:17:10 +01:00
|
|
|
set_elem_desc( &body, &req, &ns, WS_INT32_TYPE, NULL );
|
|
|
|
set_msg_desc( &desc_req, &req, &body );
|
2016-09-28 12:38:06 +02:00
|
|
|
hr = WsSendMessage( channel, msg, &desc_req, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
WsFreeMessage( msg );
|
|
|
|
|
|
|
|
hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2017-02-15 14:17:10 +01:00
|
|
|
set_elem_desc( &body, &resp, &ns, WS_INT32_TYPE, NULL );
|
|
|
|
set_msg_desc( &desc_resp, &resp, &body );
|
2016-09-28 12:38:06 +02:00
|
|
|
desc[0] = &desc_resp;
|
|
|
|
hr = WsReceiveMessage( NULL, msg, desc, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
|
|
|
|
NULL, &val, sizeof(val), NULL, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsReceiveMessage( channel, NULL, desc, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
|
|
|
|
NULL, &val, sizeof(val), NULL, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsReceiveMessage( channel, msg, NULL, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
|
|
|
|
NULL, &val, sizeof(val), NULL, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsReceiveMessage( channel, msg, desc, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
|
|
|
|
NULL, &val, sizeof(val), NULL, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( val == -2, "got %d\n", val );
|
|
|
|
|
|
|
|
hr = WsCloseChannel( channel, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
WsFreeChannel( channel );
|
|
|
|
WsFreeMessage( msg );
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:29:58 +02:00
|
|
|
static WS_HTTP_HEADER_MAPPING mapped_request_header =
|
|
|
|
{
|
|
|
|
{19, (BYTE *)"MappedRequestHeader"}
|
|
|
|
};
|
|
|
|
|
|
|
|
static WS_HTTP_HEADER_MAPPING *request_header_mappings[] =
|
|
|
|
{
|
|
|
|
&mapped_request_header
|
|
|
|
};
|
|
|
|
|
|
|
|
static WS_HTTP_HEADER_MAPPING mapped_response_header =
|
|
|
|
{
|
|
|
|
{20, (BYTE *)"MappedResponseHeader"}
|
|
|
|
};
|
|
|
|
|
|
|
|
static WS_HTTP_HEADER_MAPPING *response_header_mappings[] =
|
|
|
|
{
|
|
|
|
&mapped_response_header
|
|
|
|
};
|
|
|
|
|
2016-10-25 13:03:23 +02:00
|
|
|
static HRESULT create_proxy( int port, WS_SERVICE_PROXY **ret )
|
|
|
|
{
|
|
|
|
WS_ENVELOPE_VERSION env_version;
|
|
|
|
WS_ADDRESSING_VERSION addr_version;
|
2019-09-25 14:29:58 +02:00
|
|
|
WS_HTTP_MESSAGE_MAPPING mapping;
|
|
|
|
WS_CHANNEL_PROPERTY prop[3];
|
2016-10-25 13:03:23 +02:00
|
|
|
WS_ENDPOINT_ADDRESS addr;
|
|
|
|
WS_SERVICE_PROXY *proxy;
|
|
|
|
WCHAR url[64];
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
env_version = WS_ENVELOPE_VERSION_SOAP_1_1;
|
|
|
|
prop[0].id = WS_CHANNEL_PROPERTY_ENVELOPE_VERSION;
|
|
|
|
prop[0].value = &env_version;
|
|
|
|
prop[0].valueSize = sizeof(env_version);
|
|
|
|
|
|
|
|
addr_version = WS_ADDRESSING_VERSION_TRANSPORT;
|
|
|
|
prop[1].id = WS_CHANNEL_PROPERTY_ADDRESSING_VERSION;
|
|
|
|
prop[1].value = &addr_version;
|
|
|
|
prop[1].valueSize = sizeof(addr_version);
|
|
|
|
|
2019-09-25 14:29:58 +02:00
|
|
|
mapping.requestMappingOptions = 0;
|
|
|
|
mapping.responseMappingOptions = 0;
|
|
|
|
mapping.requestHeaderMappings = request_header_mappings;
|
|
|
|
mapping.requestHeaderMappingCount = ARRAY_SIZE(request_header_mappings);
|
|
|
|
mapping.responseHeaderMappings = response_header_mappings;
|
|
|
|
mapping.responseHeaderMappingCount = ARRAY_SIZE(response_header_mappings);
|
|
|
|
|
|
|
|
prop[2].id = WS_CHANNEL_PROPERTY_HTTP_MESSAGE_MAPPING;
|
|
|
|
prop[2].value = &mapping;
|
|
|
|
prop[2].valueSize = sizeof(mapping);
|
|
|
|
|
2016-10-25 13:03:23 +02:00
|
|
|
*ret = NULL;
|
|
|
|
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
|
2018-06-08 22:19:02 +02:00
|
|
|
0, prop, ARRAY_SIZE( prop ), &proxy, NULL );
|
2016-10-25 13:03:23 +02:00
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
|
2017-04-05 11:40:23 +02:00
|
|
|
memset( &addr, 0, sizeof(addr) );
|
2020-03-17 15:35:43 +01:00
|
|
|
addr.url.length = wsprintfW( url, L"http://127.0.0.1:%u", port );
|
2016-10-25 13:03:23 +02:00
|
|
|
addr.url.chars = url;
|
|
|
|
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
|
|
|
|
if (hr == S_OK) *ret = proxy;
|
|
|
|
else WsFreeServiceProxy( proxy );
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:29:58 +02:00
|
|
|
static HRESULT set_output( WS_XML_WRITER *writer )
|
|
|
|
{
|
|
|
|
WS_XML_WRITER_TEXT_ENCODING text = {{ WS_XML_WRITER_ENCODING_TYPE_TEXT }, WS_CHARSET_UTF8 };
|
|
|
|
WS_XML_WRITER_BUFFER_OUTPUT buf = {{ WS_XML_WRITER_OUTPUT_TYPE_BUFFER }};
|
|
|
|
return WsSetOutput( writer, &text.encoding, &buf.output, NULL, 0, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_output_headers( WS_MESSAGE *msg )
|
|
|
|
{
|
|
|
|
WS_XML_WRITER *writer;
|
|
|
|
WS_XML_BUFFER *buf;
|
|
|
|
WS_BYTES bytes;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = WsCreateWriter( NULL, 0, &writer, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = set_output( writer );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsGetMessageProperty( msg, WS_MESSAGE_PROPERTY_HEADER_BUFFER, &buf, sizeof(buf), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsWriteXmlBuffer( writer, buf, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
memset( &bytes, 0, sizeof(bytes) );
|
|
|
|
hr = WsGetWriterProperty( writer, WS_XML_WRITER_PROPERTY_BYTES, &bytes, sizeof(bytes), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
WsFreeWriter( writer );
|
|
|
|
}
|
|
|
|
|
2016-10-25 13:03:23 +02:00
|
|
|
static const char req_test2[] =
|
|
|
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
|
2016-11-17 17:11:08 +01:00
|
|
|
"<req_test2 xmlns=\"ns\"><val>1</val><str>test</str><str>test2</str></req_test2>"
|
2016-10-25 13:03:23 +02:00
|
|
|
"</s:Body></s:Envelope>";
|
|
|
|
|
|
|
|
static const char resp_test2[] =
|
|
|
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
|
|
|
|
"<resp_test2 xmlns=\"ns\"><str>test</str><val>1</val><val>2</val></resp_test2>"
|
|
|
|
"</s:Body></s:Envelope>";
|
|
|
|
|
2019-09-25 14:29:58 +02:00
|
|
|
static HRESULT CALLBACK send_callback( WS_MESSAGE *msg, WS_HEAP *heap, void *state, WS_ERROR *error )
|
|
|
|
{
|
|
|
|
static const WS_XML_STRING header = {19, (BYTE *)"MappedRequestHeader"}, value = {5, (BYTE *)"value"};
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = WsAddMappedHeader( msg, &header, WS_XML_STRING_TYPE, WS_WRITE_REQUIRED_VALUE, &value, sizeof(value), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
check_output_headers( msg );
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT CALLBACK recv_callback( WS_MESSAGE *msg, WS_HEAP *heap, void *state, WS_ERROR *error )
|
|
|
|
{
|
|
|
|
static const WS_XML_STRING header = {20, (BYTE *)"MappedResponseHeader"};
|
|
|
|
WCHAR *str;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
check_output_headers( msg );
|
|
|
|
hr = WsGetMappedHeader( msg, &header, WS_SINGLETON_HEADER, 0, WS_WSZ_TYPE, WS_READ_OPTIONAL_POINTER, heap,
|
|
|
|
&str, sizeof(str), NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2020-03-17 15:35:43 +01:00
|
|
|
ok( !wcscmp(str, L"value"), "wrong value %s\n", wine_dbgstr_w(str) );
|
2019-09-25 14:29:58 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-10-25 13:03:23 +02:00
|
|
|
static void test_WsCall( int port )
|
|
|
|
{
|
|
|
|
WS_XML_STRING str = {3, (BYTE *)"str"};
|
|
|
|
WS_XML_STRING req = {3, (BYTE *)"req"};
|
|
|
|
WS_XML_STRING resp = {4, (BYTE *)"resp"};
|
|
|
|
WS_XML_STRING req_elem = {9, (BYTE *)"req_test2"};
|
|
|
|
WS_XML_STRING resp_elem = {10, (BYTE *)"resp_test2"};
|
|
|
|
WS_XML_STRING req_action = {9, (BYTE *)"req_test2"};
|
|
|
|
WS_XML_STRING resp_action = {10, (BYTE *)"resp_test2"};
|
|
|
|
WS_XML_STRING val = {3, (BYTE *)"val"};
|
|
|
|
WS_XML_STRING ns = {2, (BYTE *)"ns"};
|
|
|
|
HRESULT hr;
|
|
|
|
WS_SERVICE_PROXY *proxy;
|
2019-09-25 14:29:58 +02:00
|
|
|
WS_PROXY_MESSAGE_CALLBACK_CONTEXT ctx_send;
|
|
|
|
WS_PROXY_MESSAGE_CALLBACK_CONTEXT ctx_recv;
|
|
|
|
WS_CALL_PROPERTY prop[2];
|
2016-10-25 13:03:23 +02:00
|
|
|
WS_OPERATION_DESCRIPTION op;
|
|
|
|
WS_MESSAGE_DESCRIPTION input_msg, output_msg;
|
|
|
|
WS_ELEMENT_DESCRIPTION input_elem, output_elem;
|
|
|
|
WS_STRUCT_DESCRIPTION input_struct, output_struct;
|
2016-11-17 17:11:08 +01:00
|
|
|
WS_FIELD_DESCRIPTION f, f2, f3, f4, *fields[2], *fields2[2];
|
|
|
|
WS_PARAMETER_DESCRIPTION param[6];
|
|
|
|
const void *args[6];
|
2016-10-25 13:03:23 +02:00
|
|
|
WS_HEAP *heap;
|
|
|
|
INT32 **val_ptr;
|
|
|
|
WCHAR **str_ptr;
|
|
|
|
ULONG *count_ptr;
|
2016-11-17 17:11:08 +01:00
|
|
|
const WCHAR *str_array[2];
|
2016-10-25 13:03:23 +02:00
|
|
|
struct input
|
|
|
|
{
|
2016-11-17 17:11:08 +01:00
|
|
|
INT32 val;
|
|
|
|
ULONG count;
|
|
|
|
const WCHAR **str;
|
2016-10-25 13:03:23 +02:00
|
|
|
} in;
|
|
|
|
struct output
|
|
|
|
{
|
|
|
|
WCHAR *str;
|
|
|
|
ULONG count;
|
|
|
|
INT32 *val;
|
|
|
|
} out;
|
|
|
|
|
|
|
|
hr = WsCreateHeap( 1 << 16, 0, NULL, 0, &heap, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCall( NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = create_proxy( port, &proxy );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCall( proxy, NULL, NULL, NULL, NULL, 0, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
2017-02-15 14:17:10 +01:00
|
|
|
set_field_desc( &f, WS_ELEMENT_FIELD_MAPPING, &val, &ns, WS_INT32_TYPE, NULL, 0, 0, 0, NULL, NULL );
|
|
|
|
set_field_desc( &f4, WS_REPEATING_ELEMENT_FIELD_MAPPING, NULL, NULL, WS_WSZ_TYPE, NULL,
|
|
|
|
FIELD_OFFSET(struct input, str), 0, FIELD_OFFSET(struct input, count), &str, &ns );
|
2016-10-25 13:03:23 +02:00
|
|
|
fields[0] = &f;
|
2016-11-17 17:11:08 +01:00
|
|
|
fields[1] = &f4;
|
|
|
|
|
2017-02-15 14:17:12 +01:00
|
|
|
set_struct_desc( &input_struct, sizeof(struct input), TYPE_ALIGNMENT(struct input), fields, 2, &req, &ns, 0 );
|
2017-02-15 14:17:10 +01:00
|
|
|
set_elem_desc( &input_elem, &req_elem, &ns, WS_STRUCT_TYPE, &input_struct );
|
|
|
|
set_msg_desc( &input_msg, &req_action, &input_elem );
|
2016-10-25 13:03:23 +02:00
|
|
|
|
2017-02-15 14:17:10 +01:00
|
|
|
set_field_desc( &f2, WS_ELEMENT_FIELD_MAPPING, &str, &ns, WS_WSZ_TYPE, NULL, FIELD_OFFSET(struct output, str),
|
|
|
|
0, 0, NULL, NULL );
|
|
|
|
set_field_desc( &f3, WS_REPEATING_ELEMENT_FIELD_MAPPING, NULL, NULL, WS_INT32_TYPE, NULL,
|
|
|
|
FIELD_OFFSET(struct output, val), 0, FIELD_OFFSET(struct output, count), &val, &ns );
|
|
|
|
fields2[0] = &f2;
|
2016-10-25 13:03:23 +02:00
|
|
|
fields2[1] = &f3;
|
|
|
|
|
2017-02-15 14:17:12 +01:00
|
|
|
set_struct_desc( &output_struct, sizeof(struct output), TYPE_ALIGNMENT(struct output), fields2, 2, &resp, &ns, 0 );
|
2017-02-15 14:17:10 +01:00
|
|
|
set_elem_desc( &output_elem, &resp_elem, &ns, WS_STRUCT_TYPE, &output_struct );
|
|
|
|
set_msg_desc( &output_msg, &resp_action, &output_elem );
|
|
|
|
|
|
|
|
set_param_desc( ¶m[0], WS_PARAMETER_TYPE_NORMAL, 0, 0xffff );
|
|
|
|
set_param_desc( ¶m[1], WS_PARAMETER_TYPE_ARRAY, 1, 0xffff );
|
|
|
|
set_param_desc( ¶m[2], WS_PARAMETER_TYPE_ARRAY_COUNT, 1, 0xffff );
|
|
|
|
set_param_desc( ¶m[3], WS_PARAMETER_TYPE_NORMAL, 0xffff, 0 );
|
|
|
|
set_param_desc( ¶m[4], WS_PARAMETER_TYPE_ARRAY, 0xffff, 1 );
|
|
|
|
set_param_desc( ¶m[5], WS_PARAMETER_TYPE_ARRAY_COUNT, 0xffff, 1 );
|
|
|
|
|
|
|
|
set_op_desc( &op, &input_msg, &output_msg, 6, param );
|
2016-10-25 13:03:23 +02:00
|
|
|
hr = WsCall( proxy, &op, NULL, NULL, NULL, 0, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
in.val = 1;
|
2020-03-17 15:35:43 +01:00
|
|
|
str_array[0] = L"test";
|
|
|
|
str_array[1] = L"test2";
|
2016-11-17 17:11:08 +01:00
|
|
|
in.str = str_array;
|
|
|
|
in.count = 2;
|
|
|
|
|
2016-10-25 13:03:23 +02:00
|
|
|
args[0] = &in.val;
|
2016-11-17 17:11:08 +01:00
|
|
|
args[1] = &in.str;
|
|
|
|
args[2] = &in.count;
|
2016-10-25 13:03:23 +02:00
|
|
|
|
|
|
|
out.str = NULL;
|
|
|
|
out.count = 0;
|
2016-11-17 17:11:08 +01:00
|
|
|
out.val = NULL;
|
2016-10-25 13:03:23 +02:00
|
|
|
str_ptr = &out.str;
|
|
|
|
val_ptr = &out.val;
|
|
|
|
count_ptr = &out.count;
|
2016-11-17 17:11:08 +01:00
|
|
|
|
|
|
|
args[3] = &str_ptr;
|
|
|
|
args[4] = &val_ptr;
|
|
|
|
args[5] = &count_ptr;
|
2016-10-25 13:03:23 +02:00
|
|
|
|
2019-09-25 14:29:58 +02:00
|
|
|
ctx_send.callback = send_callback;
|
|
|
|
ctx_send.state = NULL;
|
|
|
|
|
|
|
|
prop[0].id = WS_CALL_PROPERTY_SEND_MESSAGE_CONTEXT;
|
|
|
|
prop[0].value = &ctx_send;
|
|
|
|
prop[0].valueSize = sizeof(ctx_send);
|
|
|
|
|
|
|
|
ctx_recv.callback = recv_callback;
|
|
|
|
ctx_recv.state = NULL;
|
|
|
|
|
|
|
|
prop[1].id = WS_CALL_PROPERTY_RECEIVE_MESSAGE_CONTEXT;
|
|
|
|
prop[1].value = &ctx_recv;
|
|
|
|
prop[1].valueSize = sizeof(ctx_recv);
|
|
|
|
|
|
|
|
hr = WsCall( proxy, &op, args, heap, prop, ARRAY_SIZE(prop), NULL, NULL );
|
2016-10-25 13:03:23 +02:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2020-03-17 15:35:43 +01:00
|
|
|
ok( !wcscmp( out.str, L"test" ), "wrong data\n" );
|
2016-10-25 13:03:23 +02:00
|
|
|
ok( out.count == 2, "got %u\n", out.count );
|
|
|
|
ok( out.val[0] == 1, "got %u\n", out.val[0] );
|
|
|
|
ok( out.val[1] == 2, "got %u\n", out.val[1] );
|
|
|
|
|
|
|
|
hr = WsCloseServiceProxy( proxy, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
WsFreeServiceProxy( proxy );
|
|
|
|
WsFreeHeap( heap );
|
|
|
|
}
|
|
|
|
|
2017-02-15 14:17:12 +01:00
|
|
|
static const char req_test3[] =
|
|
|
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
|
|
|
|
"<req_test3 xmlns=\"ns\"><val>1</val></req_test3>"
|
|
|
|
"</s:Body></s:Envelope>";
|
|
|
|
|
|
|
|
static const char resp_test3[] =
|
|
|
|
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body/></s:Envelope>";
|
|
|
|
|
|
|
|
static void test_empty_response( int port )
|
|
|
|
{
|
|
|
|
WS_XML_STRING req = {3, (BYTE *)"req"};
|
|
|
|
WS_XML_STRING resp = {4, (BYTE *)"resp"};
|
|
|
|
WS_XML_STRING req_action = {9, (BYTE *)"req_test3"};
|
|
|
|
WS_XML_STRING resp_action = {10, (BYTE *)"resp_test3"};
|
|
|
|
WS_XML_STRING req_elem = {9, (BYTE *)"req_test3"};
|
|
|
|
WS_XML_STRING resp_elem = {10, (BYTE *)"resp_test3"};
|
|
|
|
WS_XML_STRING ns = {2, (BYTE *)"ns"};
|
|
|
|
WS_XML_STRING ns2 = {0, (BYTE *)""};
|
|
|
|
WS_XML_STRING val = {3, (BYTE *)"val"};
|
|
|
|
HRESULT hr;
|
|
|
|
WS_SERVICE_PROXY *proxy;
|
|
|
|
WS_FIELD_DESCRIPTION f, *fields[1];
|
|
|
|
WS_STRUCT_DESCRIPTION input_struct, output_struct;
|
|
|
|
WS_ELEMENT_DESCRIPTION input_elem, output_elem;
|
|
|
|
WS_MESSAGE_DESCRIPTION input_msg, output_msg;
|
|
|
|
WS_PARAMETER_DESCRIPTION param[1];
|
|
|
|
WS_OPERATION_DESCRIPTION op;
|
|
|
|
const void *args[1];
|
|
|
|
WS_HEAP *heap;
|
|
|
|
struct input
|
|
|
|
{
|
|
|
|
INT32 val;
|
|
|
|
} in;
|
|
|
|
|
|
|
|
hr = WsCreateHeap( 1 << 16, 0, NULL, 0, &heap, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = create_proxy( port, &proxy );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
set_field_desc( &f, WS_ELEMENT_FIELD_MAPPING, &val, &ns, WS_INT32_TYPE, NULL, 0, 0, 0, NULL, NULL );
|
|
|
|
fields[0] = &f;
|
|
|
|
|
|
|
|
set_struct_desc( &input_struct, sizeof(struct input), TYPE_ALIGNMENT(struct input), fields, 1, &req, &ns, 0 );
|
|
|
|
set_elem_desc( &input_elem, &req_elem, &ns, WS_STRUCT_TYPE, &input_struct );
|
|
|
|
set_msg_desc( &input_msg, &req_action, &input_elem );
|
|
|
|
|
|
|
|
set_struct_desc( &output_struct, 0, 1, NULL, 0, &resp, &ns2, 0x6 );
|
|
|
|
set_elem_desc( &output_elem, &resp_elem, &ns, WS_STRUCT_TYPE, NULL );
|
|
|
|
set_msg_desc( &output_msg, &resp_action, &output_elem );
|
|
|
|
|
|
|
|
set_param_desc( param, WS_PARAMETER_TYPE_NORMAL, 0, 0xffff );
|
|
|
|
set_op_desc( &op, &input_msg, &output_msg, 1, param );
|
|
|
|
|
|
|
|
in.val = 1;
|
|
|
|
args[0] = &in.val;
|
|
|
|
hr = WsCall( proxy, &op, args, heap, NULL, 0, NULL, NULL );
|
|
|
|
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
|
|
|
|
|
|
|
set_elem_desc( &output_elem, &resp_elem, &ns, WS_STRUCT_TYPE, &output_struct );
|
|
|
|
hr = WsCall( proxy, &op, args, heap, NULL, 0, NULL, NULL );
|
|
|
|
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = WsCloseServiceProxy( proxy, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
WsFreeServiceProxy( proxy );
|
|
|
|
WsFreeHeap( heap );
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char status_200[] = "HTTP/1.1 200 OK\r\n";
|
|
|
|
|
2016-09-28 12:38:05 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char *req_action;
|
|
|
|
const char *req_data;
|
|
|
|
unsigned int req_len;
|
2017-02-15 14:17:12 +01:00
|
|
|
const char *resp_status;
|
2016-09-28 12:38:05 +02:00
|
|
|
const char *resp_data;
|
|
|
|
unsigned int resp_len;
|
|
|
|
}
|
|
|
|
tests[] =
|
|
|
|
{
|
2017-02-15 14:17:12 +01:00
|
|
|
{ "req_test1", req_test1, sizeof(req_test1)-1, status_200, resp_test1, sizeof(resp_test1)-1 },
|
|
|
|
{ "req_test2", req_test2, sizeof(req_test2)-1, status_200, resp_test2, sizeof(resp_test2)-1 },
|
|
|
|
{ "req_test3", req_test3, sizeof(req_test3)-1, status_200, resp_test3, sizeof(resp_test3)-1 },
|
2016-09-28 12:38:05 +02:00
|
|
|
};
|
|
|
|
|
2017-02-15 14:17:12 +01:00
|
|
|
static void send_response( int c, const char *status, const char *data, unsigned int len )
|
2016-09-28 12:38:05 +02:00
|
|
|
{
|
|
|
|
static const char headers[] =
|
2019-09-25 14:29:58 +02:00
|
|
|
"Content-Type: text/xml; charset=utf-8\r\nConnection: close\r\nMappedResponseHeader: value\r\n";
|
2016-09-28 12:38:05 +02:00
|
|
|
static const char fmt[] =
|
2017-02-15 14:17:12 +01:00
|
|
|
"Content-Length: %u\r\n\r\n";
|
2016-09-28 12:38:05 +02:00
|
|
|
char buf[128];
|
|
|
|
|
2017-02-15 14:17:12 +01:00
|
|
|
send( c, status, strlen(status), 0 );
|
2016-09-28 12:38:05 +02:00
|
|
|
send( c, headers, sizeof(headers) - 1, 0 );
|
2017-02-15 14:17:12 +01:00
|
|
|
sprintf( buf, fmt, len );
|
2016-09-28 12:38:05 +02:00
|
|
|
send( c, buf, strlen(buf), 0 );
|
|
|
|
send( c, data, len, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
struct server_info
|
|
|
|
{
|
|
|
|
HANDLE event;
|
|
|
|
int port;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD CALLBACK server_proc( void *arg )
|
|
|
|
{
|
|
|
|
struct server_info *info = arg;
|
|
|
|
int len, res, c = -1, i, j, on = 1, quit;
|
|
|
|
WSADATA wsa;
|
|
|
|
SOCKET s;
|
|
|
|
struct sockaddr_in sa;
|
|
|
|
char buf[1024];
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
WSAStartup( MAKEWORD(1,1), &wsa );
|
|
|
|
if ((s = socket( AF_INET, SOCK_STREAM, 0 )) == INVALID_SOCKET) return 1;
|
|
|
|
setsockopt( s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on) );
|
|
|
|
|
|
|
|
memset( &sa, 0, sizeof(sa) );
|
|
|
|
sa.sin_family = AF_INET;
|
|
|
|
sa.sin_port = htons( info->port );
|
|
|
|
sa.sin_addr.S_un.S_addr = inet_addr( "127.0.0.1" );
|
|
|
|
if (bind( s, (struct sockaddr *)&sa, sizeof(sa) ) < 0) return 1;
|
|
|
|
|
|
|
|
listen( s, 0 );
|
|
|
|
SetEvent( info->event );
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = accept( s, NULL, NULL );
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
for (i = 0; i < sizeof(buf) - 1; i++)
|
|
|
|
{
|
|
|
|
if ((res = recv( c, &buf[i], 1, 0 )) != 1) break;
|
|
|
|
if (i < 4) continue;
|
|
|
|
if (buf[i - 2] == '\n' && buf[i] == '\n' && buf[i - 3] == '\r' && buf[i - 1] == '\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
buf[i] = 0;
|
|
|
|
quit = strstr( buf, "SOAPAction: \"quit\"" ) != NULL;
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
if ((p = strstr( buf, "Content-Length: " )))
|
|
|
|
{
|
|
|
|
p += strlen( "Content-Length: " );
|
|
|
|
while (isdigit( *p ))
|
|
|
|
{
|
|
|
|
len *= 10;
|
|
|
|
len += *p++ - '0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
if ((res = recv( c, &buf[i], 1, 0 )) != 1) break;
|
|
|
|
}
|
|
|
|
buf[i] = 0;
|
|
|
|
|
2018-06-08 22:19:02 +02:00
|
|
|
for (j = 0; j < ARRAY_SIZE( tests ); j++)
|
2016-09-28 12:38:05 +02:00
|
|
|
{
|
|
|
|
if (strstr( buf, tests[j].req_action ))
|
|
|
|
{
|
|
|
|
if (tests[j].req_data)
|
|
|
|
{
|
|
|
|
int data_len = strlen( buf );
|
2019-09-25 14:29:58 +02:00
|
|
|
ok( tests[j].req_len == data_len, "%u: got data length %u expected %u\n",
|
2016-09-28 12:38:05 +02:00
|
|
|
j, data_len, tests[j].req_len );
|
|
|
|
if (tests[j].req_len == data_len)
|
2019-09-25 14:29:58 +02:00
|
|
|
ok( !memcmp( tests[j].req_data, buf, tests[j].req_len ),
|
|
|
|
"%u: got data '%s' expected '%s'\n", j, buf, tests[j].req_data );
|
2016-09-28 12:38:05 +02:00
|
|
|
}
|
2017-02-15 14:17:12 +01:00
|
|
|
send_response( c, tests[j].resp_status, tests[j].resp_data, tests[j].resp_len );
|
2016-10-25 13:03:23 +02:00
|
|
|
break;
|
2016-09-28 12:38:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shutdown( c, 2 );
|
|
|
|
closesocket( c );
|
|
|
|
if (quit) break;
|
|
|
|
}
|
2019-02-09 16:55:49 +01:00
|
|
|
closesocket( s );
|
2016-09-28 12:38:05 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-22 09:42:47 +02:00
|
|
|
START_TEST(proxy)
|
|
|
|
{
|
2016-09-28 12:38:05 +02:00
|
|
|
WS_XML_STRING test1 = {9, (BYTE *)"req_test1"};
|
|
|
|
WS_XML_STRING quit = {4, (BYTE *)"quit"};
|
|
|
|
struct server_info info;
|
|
|
|
HANDLE thread;
|
|
|
|
DWORD ret;
|
|
|
|
|
2016-04-22 09:42:47 +02:00
|
|
|
test_WsCreateServiceProxy();
|
|
|
|
test_WsCreateServiceProxyFromTemplate();
|
|
|
|
test_WsOpenServiceProxy();
|
2017-04-05 11:40:24 +02:00
|
|
|
test_WsResetServiceProxy();
|
2016-09-28 12:38:05 +02:00
|
|
|
|
|
|
|
info.port = 7533;
|
|
|
|
info.event = CreateEventW( NULL, 0, 0, NULL );
|
|
|
|
thread = CreateThread( NULL, 0, server_proc, &info, 0, NULL );
|
|
|
|
ok( thread != NULL, "failed to create server thread %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = WaitForSingleObject( info.event, 3000 );
|
|
|
|
ok(ret == WAIT_OBJECT_0, "failed to start test server %u\n", GetLastError());
|
2018-01-04 18:10:45 +01:00
|
|
|
if (ret != WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
CloseHandle(thread);
|
|
|
|
return;
|
|
|
|
}
|
2016-09-28 12:38:05 +02:00
|
|
|
|
|
|
|
test_WsSendMessage( info.port, &test1 );
|
2016-09-28 12:38:06 +02:00
|
|
|
test_WsReceiveMessage( info.port );
|
2016-10-25 13:03:23 +02:00
|
|
|
test_WsCall( info.port );
|
2017-02-15 14:17:12 +01:00
|
|
|
test_empty_response( info.port );
|
2016-09-28 12:38:06 +02:00
|
|
|
|
2016-09-28 12:38:05 +02:00
|
|
|
test_WsSendMessage( info.port, &quit );
|
|
|
|
WaitForSingleObject( thread, 3000 );
|
2018-01-04 18:10:45 +01:00
|
|
|
CloseHandle(thread);
|
2016-04-22 09:42:47 +02:00
|
|
|
}
|