2 * Copyright 2016 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "webservices.h"
22 #include "wine/test.h"
24 static void test_WsCreateMessage(void)
28 WS_MESSAGE_STATE state
;
29 WS_ENVELOPE_VERSION env_version
;
30 WS_ADDRESSING_VERSION addr_version
;
31 WS_MESSAGE_PROPERTY prop
;
33 hr
= WsCreateMessage( 0, 0, NULL
, 0, NULL
, NULL
);
34 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
36 hr
= WsCreateMessage( 0, 0, NULL
, 0, &msg
, NULL
);
37 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
39 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, 0, NULL
, 0, &msg
, NULL
);
40 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
42 hr
= WsCreateMessage( 0, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
43 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
45 env_version
= WS_ENVELOPE_VERSION_SOAP_1_1
;
46 prop
.id
= WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
;
47 prop
.value
= &env_version
;
48 prop
.valueSize
= sizeof(env_version
);
49 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, &prop
,
51 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
53 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
,
55 ok( hr
== S_OK
, "got %08x\n", hr
);
58 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
59 ok( hr
== S_OK
, "got %08x\n", hr
);
60 ok( state
== WS_MESSAGE_STATE_EMPTY
, "got %u\n", state
);
62 env_version
= 0xdeadbeef;
63 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
64 sizeof(env_version
), NULL
);
65 ok( hr
== S_OK
, "got %08x\n", hr
);
66 ok( env_version
== WS_ENVELOPE_VERSION_SOAP_1_1
, "got %u\n", env_version
);
68 addr_version
= 0xdeadbeef;
69 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
, &addr_version
,
70 sizeof(addr_version
), NULL
);
71 ok( hr
== S_OK
, "got %08x\n", hr
);
72 ok( addr_version
== WS_ADDRESSING_VERSION_0_9
, "got %u\n", addr_version
);
74 state
= WS_MESSAGE_STATE_EMPTY
;
75 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
76 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
78 env_version
= WS_ENVELOPE_VERSION_SOAP_1_1
;
79 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
80 sizeof(env_version
), NULL
);
81 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
83 addr_version
= WS_ADDRESSING_VERSION_0_9
;
84 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
, &addr_version
,
85 sizeof(addr_version
), NULL
);
86 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
90 static void test_WsCreateMessageForChannel(void)
95 WS_MESSAGE_STATE state
;
96 WS_ENVELOPE_VERSION env_version
;
97 WS_ADDRESSING_VERSION addr_version
;
98 WS_CHANNEL_PROPERTY prop
;
101 hr
= WsCreateMessageForChannel( NULL
, NULL
, 0, NULL
, NULL
);
102 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
104 hr
= WsCreateMessageForChannel( NULL
, NULL
, 0, &msg
, NULL
);
105 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
107 hr
= WsCreateChannel( WS_CHANNEL_TYPE_REQUEST
, WS_HTTP_CHANNEL_BINDING
, NULL
, 0, NULL
,
109 ok( hr
== S_OK
, "got %08x\n", hr
);
111 hr
= WsCreateMessageForChannel( channel
, NULL
, 0, &msg
, NULL
);
112 ok( hr
== S_OK
, "got %08x\n", hr
);
115 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
116 ok( hr
== S_OK
, "got %08x\n", hr
);
117 ok( state
== WS_MESSAGE_STATE_EMPTY
, "got %u\n", state
);
119 env_version
= 0xdeadbeef;
120 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
121 sizeof(env_version
), NULL
);
122 ok( hr
== S_OK
, "got %08x\n", hr
);
123 ok( env_version
== WS_ENVELOPE_VERSION_SOAP_1_2
, "got %u\n", env_version
);
125 addr_version
= 0xdeadbeef;
126 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
, &addr_version
,
127 sizeof(addr_version
), NULL
);
128 ok( hr
== S_OK
, "got %08x\n", hr
);
129 ok( addr_version
== WS_ADDRESSING_VERSION_1_0
, "got %u\n", addr_version
);
131 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
133 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
135 WsFreeChannel( channel
);
136 WsFreeMessage( msg
);
138 env_version
= WS_ENVELOPE_VERSION_SOAP_1_1
;
139 prop
.id
= WS_CHANNEL_PROPERTY_ENVELOPE_VERSION
;
140 prop
.value
= &env_version
;
141 prop
.valueSize
= sizeof(env_version
);
142 hr
= WsCreateChannel( WS_CHANNEL_TYPE_REQUEST
, WS_HTTP_CHANNEL_BINDING
, &prop
, 1, NULL
,
144 ok( hr
== S_OK
, "got %08x\n", hr
);
146 hr
= WsCreateMessageForChannel( channel
, NULL
, 0, &msg
, NULL
);
147 ok( hr
== S_OK
, "got %08x\n", hr
);
149 env_version
= 0xdeadbeef;
150 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
151 sizeof(env_version
), NULL
);
152 ok( hr
== S_OK
, "got %08x\n", hr
);
153 ok( env_version
== WS_ENVELOPE_VERSION_SOAP_1_1
, "got %u\n", env_version
);
155 WsFreeChannel( channel
);
156 WsFreeMessage( msg
);
159 static void test_WsInitializeMessage(void)
163 WS_MESSAGE_STATE state
;
164 WS_ENVELOPE_VERSION env_version
;
165 WS_ADDRESSING_VERSION addr_version
;
168 hr
= WsInitializeMessage( NULL
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
169 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
171 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
,
173 ok( hr
== S_OK
, "got %08x\n", hr
);
175 hr
= WsInitializeMessage( msg
, 0xdeadbeef, NULL
, NULL
);
176 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
178 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
179 ok( hr
== S_OK
, "got %08x\n", hr
);
181 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
182 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
185 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
186 ok( hr
== S_OK
, "got %08x\n", hr
);
187 ok( state
== WS_MESSAGE_STATE_INITIALIZED
, "got %u\n", state
);
190 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
192 ok( hr
== S_OK
, "got %08x\n", hr
);
193 ok( !addressed
, "unexpected value %d\n", addressed
);
195 state
= WS_MESSAGE_STATE_EMPTY
;
196 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
197 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
199 env_version
= WS_ENVELOPE_VERSION_SOAP_1_1
;
200 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
201 sizeof(env_version
), NULL
);
202 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
204 addr_version
= WS_ADDRESSING_VERSION_0_9
;
205 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
, &addr_version
,
206 sizeof(addr_version
), NULL
);
207 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
208 WsFreeMessage( msg
);
211 static void test_WsAddressMessage(void)
213 static WCHAR localhost
[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t','/',0};
216 WS_ENDPOINT_ADDRESS endpoint
;
219 hr
= WsAddressMessage( NULL
, NULL
, NULL
);
220 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
222 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
,
224 ok( hr
== S_OK
, "got %08x\n", hr
);
226 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
228 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
230 hr
= WsAddressMessage( msg
, NULL
, NULL
);
231 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
233 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
234 ok( hr
== S_OK
, "got %08x\n", hr
);
237 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
239 ok( hr
== S_OK
, "got %08x\n", hr
);
240 ok( !addressed
, "unexpected value %d\n", addressed
);
242 hr
= WsAddressMessage( msg
, NULL
, NULL
);
243 ok( hr
== S_OK
, "got %08x\n", hr
);
246 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
248 ok( hr
== S_OK
, "got %08x\n", hr
);
249 ok( addressed
== TRUE
, "unexpected value %d\n", addressed
);
250 WsFreeMessage( msg
);
252 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
,
254 ok( hr
== S_OK
, "got %08x\n", hr
);
256 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
257 ok( hr
== S_OK
, "got %08x\n", hr
);
259 memset( &endpoint
, 0, sizeof(endpoint
) );
260 endpoint
.url
.chars
= localhost
;
261 endpoint
.url
.length
= sizeof(localhost
)/sizeof(localhost
[0]);
262 hr
= WsAddressMessage( msg
, &endpoint
, NULL
);
263 ok( hr
== S_OK
, "got %08x\n", hr
);
266 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
268 ok( hr
== S_OK
, "got %08x\n", hr
);
269 ok( addressed
== TRUE
, "unexpected value %d\n", addressed
);
270 WsFreeMessage( msg
);
273 static HRESULT
set_output( WS_XML_WRITER
*writer
)
275 WS_XML_WRITER_TEXT_ENCODING text
= { {WS_XML_WRITER_ENCODING_TYPE_TEXT
}, WS_CHARSET_UTF8
};
276 WS_XML_WRITER_BUFFER_OUTPUT buf
= { {WS_XML_WRITER_OUTPUT_TYPE_BUFFER
} };
277 return WsSetOutput( writer
, &text
.encoding
, &buf
.output
, NULL
, 0, NULL
);
280 static void check_output( WS_XML_WRITER
*writer
, const char *expected
, int len
, unsigned int skip_start
,
281 unsigned int skip_len
, unsigned int line
)
286 if (len
== -1) len
= strlen( expected
);
287 memset( &bytes
, 0, sizeof(bytes
) );
288 hr
= WsGetWriterProperty( writer
, WS_XML_WRITER_PROPERTY_BYTES
, &bytes
, sizeof(bytes
), NULL
);
289 ok( hr
== S_OK
, "%u: got %08x\n", line
, hr
);
290 ok( bytes
.length
== len
, "%u: got %u expected %u\n", line
, bytes
.length
, len
);
291 if (bytes
.length
!= len
) return;
294 ok( !memcmp( bytes
.bytes
, expected
, skip_start
), "%u: got %s expected %s\n", line
,
295 bytes
.bytes
, expected
);
296 ok( !memcmp( bytes
.bytes
+ skip_start
+ skip_len
, expected
+ skip_start
+ skip_len
,
297 len
- skip_start
- skip_len
), "%u: got %s expected %s\n", line
, bytes
.bytes
, expected
);
300 ok( !memcmp( bytes
.bytes
, expected
, len
), "%u: got %s expected %s\n", line
, bytes
.bytes
,
304 static void check_output_header( WS_MESSAGE
*msg
, const char *expected
, int len
, unsigned int skip_start
,
305 unsigned int skip_len
, unsigned int line
)
307 WS_XML_WRITER
*writer
;
311 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
312 ok( hr
== S_OK
, "got %08x\n", hr
);
314 hr
= set_output( writer
);
315 ok( hr
== S_OK
, "got %08x\n", hr
);
317 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_HEADER_BUFFER
, &buf
, sizeof(buf
), NULL
);
318 ok( hr
== S_OK
, "got %08x\n", hr
);
320 hr
= WsWriteXmlBuffer( writer
, buf
, NULL
);
321 ok( hr
== S_OK
, "got %08x\n", hr
);
323 check_output( writer
, expected
, len
, skip_start
, skip_len
, line
);
324 WsFreeWriter( writer
);
327 static void test_WsWriteEnvelopeStart(void)
329 static const char expected
[] =
330 "<s:Envelope xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" "
331 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header>"
332 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
333 "<a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>"
334 "</a:ReplyTo></s:Header>";
335 static const char expected2
[] =
336 "<s:Envelope xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" "
337 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header>"
338 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
339 "<a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>"
340 "</a:ReplyTo></s:Header><s:Body/></s:Envelope>";
341 static const char expected3
[] =
342 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header/><s:Body/></s:Envelope>";
343 static const char expected4
[] =
344 "<Envelope><Header/><Body/></Envelope>";
345 static const char expected5
[] =
346 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
347 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
348 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
349 "</s:Header><s:Body/></s:Envelope>";
352 WS_XML_WRITER
*writer
;
353 WS_MESSAGE_STATE state
;
355 hr
= WsWriteEnvelopeStart( NULL
, NULL
, NULL
, NULL
, NULL
);
356 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
358 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
359 ok( hr
== S_OK
, "got %08x\n", hr
);
361 hr
= WsWriteEnvelopeStart( NULL
, writer
, NULL
, NULL
, NULL
);
362 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
364 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
,
366 ok( hr
== S_OK
, "got %08x\n", hr
);
368 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
369 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
371 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
372 ok( hr
== S_OK
, "got %08x\n", hr
);
373 hr
= set_output( writer
);
374 ok( hr
== S_OK
, "got %08x\n", hr
);
375 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
376 ok( hr
== S_OK
, "got %08x\n", hr
);
377 check_output( writer
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
378 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
381 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
382 ok( hr
== S_OK
, "got %08x\n", hr
);
383 ok( state
== WS_MESSAGE_STATE_WRITING
, "got %u\n", state
);
384 WsFreeMessage( msg
);
386 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_TRANSPORT
, NULL
, 0, &msg
,
388 ok( hr
== S_OK
, "got %08x\n", hr
);
389 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
390 ok( hr
== S_OK
, "got %08x\n", hr
);
391 hr
= set_output( writer
);
392 ok( hr
== S_OK
, "got %08x\n", hr
);
393 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
394 ok( hr
== S_OK
, "got %08x\n", hr
);
395 check_output_header( msg
, expected3
, -1, 0, 0, __LINE__
);
396 WsFreeMessage( msg
);
398 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_NONE
, WS_ADDRESSING_VERSION_TRANSPORT
, NULL
, 0, &msg
,
400 ok( hr
== S_OK
, "got %08x\n", hr
);
401 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
402 ok( hr
== S_OK
, "got %08x\n", hr
);
403 hr
= set_output( writer
);
404 ok( hr
== S_OK
, "got %08x\n", hr
);
405 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
406 ok( hr
== S_OK
, "got %08x\n", hr
);
407 check_output_header( msg
, expected4
, -1, 0, 0, __LINE__
);
408 WsFreeMessage( msg
);
410 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
412 ok( hr
== S_OK
, "got %08x\n", hr
);
413 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
414 ok( hr
== S_OK
, "got %08x\n", hr
);
415 hr
= set_output( writer
);
416 ok( hr
== S_OK
, "got %08x\n", hr
);
417 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
418 ok( hr
== S_OK
, "got %08x\n", hr
);
419 check_output_header( msg
, expected5
, -1, strstr(expected5
, "urn:uuid:") - expected5
, 46, __LINE__
);
420 WsFreeMessage( msg
);
422 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
424 ok( hr
== S_OK
, "got %08x\n", hr
);
425 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
426 ok( hr
== S_OK
, "got %08x\n", hr
);
427 WsFreeMessage( msg
);
429 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_NONE
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
,
431 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
432 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_NONE
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
434 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
435 WsFreeWriter( writer
);
438 static void test_WsWriteEnvelopeEnd(void)
440 static const char expected
[] =
441 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
442 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
443 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
444 "</s:Header><s:Body/></s:Envelope>";
447 WS_XML_WRITER
*writer
;
448 WS_MESSAGE_STATE state
;
450 hr
= WsWriteEnvelopeEnd( NULL
, NULL
);
451 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
453 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
455 ok( hr
== S_OK
, "got %08x\n", hr
);
457 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
458 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
460 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
461 ok( hr
== S_OK
, "got %08x\n", hr
);
463 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
464 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
466 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
467 ok( hr
== S_OK
, "got %08x\n", hr
);
469 hr
= set_output( writer
);
470 ok( hr
== S_OK
, "got %08x\n", hr
);
472 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
473 ok( hr
== S_OK
, "got %08x\n", hr
);
475 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
476 ok( hr
== S_OK
, "got %08x\n", hr
);
477 check_output( writer
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
478 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
481 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
482 ok( hr
== S_OK
, "got %08x\n", hr
);
483 ok( state
== WS_MESSAGE_STATE_DONE
, "got %u\n", state
);
485 WsFreeMessage( msg
);
486 WsFreeWriter( writer
);
489 static void test_WsWriteBody(void)
491 static char expected
[] =
492 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
493 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
494 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
495 "</s:Header><s:Body><u xmlns=\"ns\"><val>1</val></u></s:Body></s:Envelope>";
496 static char expected2
[] =
497 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
498 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
499 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
500 "</s:Header><s:Body/></s:Envelope>";
501 WS_XML_STRING localname
= {1, (BYTE
*)"t"}, localname2
= {1, (BYTE
*)"u"};
502 WS_XML_STRING val
= {3, (BYTE
*)"val"}, ns
= {2, (BYTE
*)"ns"};
505 WS_XML_WRITER
*writer
;
506 WS_MESSAGE_STATE state
;
507 WS_ELEMENT_DESCRIPTION desc
;
508 WS_STRUCT_DESCRIPTION s
;
509 WS_FIELD_DESCRIPTION f
, *fields
[1];
515 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
517 ok( hr
== S_OK
, "got %08x\n", hr
);
519 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
520 ok( hr
== S_OK
, "got %08x\n", hr
);
522 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
523 ok( hr
== S_OK
, "got %08x\n", hr
);
525 hr
= set_output( writer
);
526 ok( hr
== S_OK
, "got %08x\n", hr
);
528 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
529 ok( hr
== S_OK
, "got %08x\n", hr
);
531 hr
= WsWriteBody( NULL
, NULL
, 0, NULL
, 0, NULL
);
532 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
534 hr
= WsWriteBody( msg
, NULL
, 0, NULL
, 0, NULL
);
535 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
537 memset( &f
, 0, sizeof(f
) );
538 f
.mapping
= WS_ELEMENT_FIELD_MAPPING
;
541 f
.type
= WS_UINT32_TYPE
;
544 memset( &s
, 0, sizeof(s
) );
545 s
.size
= sizeof(struct test
);
546 s
.alignment
= TYPE_ALIGNMENT(struct test
);
549 s
.typeLocalName
= &localname
;
552 desc
.elementLocalName
= &localname2
;
553 desc
.elementNs
= &ns
;
554 desc
.type
= WS_STRUCT_TYPE
;
555 desc
.typeDescription
= &s
;
559 hr
= WsWriteBody( msg
, &desc
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
560 ok( hr
== S_OK
, "got %08x\n", hr
);
561 check_output( writer
, expected
, 240, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
562 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
565 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
566 ok( hr
== S_OK
, "got %08x\n", hr
);
567 ok( state
== WS_MESSAGE_STATE_WRITING
, "got %u\n", state
);
569 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
570 ok( hr
== S_OK
, "got %08x\n", hr
);
571 check_output( writer
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
572 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
574 hr
= WsWriteBody( msg
, &desc
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
575 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
577 WsFreeMessage( msg
);
578 WsFreeWriter( writer
);
581 static void test_WsSetHeader(void)
583 static const char expected
[] =
584 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
585 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
586 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
587 "<a:Action s:mustUnderstand=\"1\">action</a:Action></s:Header>"
588 "<s:Body/></s:Envelope>";
589 static const char expected2
[] =
590 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
591 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
592 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
593 "<a:Action s:mustUnderstand=\"1\">action2</a:Action></s:Header>"
594 "<s:Body/></s:Envelope>";
595 static const WCHAR action
[] = {'a','c','t','i','o','n',0};
596 static const WS_XML_STRING action2
= {7, (BYTE
*)"action2"};
599 WS_XML_WRITER
*writer
;
600 const WCHAR
*ptr
= action
;
602 hr
= WsSetHeader( NULL
, 0, 0, 0, NULL
, 0, NULL
);
603 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
605 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
607 ok( hr
== S_OK
, "got %08x\n", hr
);
609 hr
= WsSetHeader( msg
, 0, 0, 0, NULL
, 0, NULL
);
610 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
612 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
,
614 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
616 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
617 ok( hr
== S_OK
, "got %08x\n", hr
);
619 hr
= WsSetHeader( msg
, 0, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
620 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
622 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
,
624 ok( hr
== S_OK
, "got %08x\n", hr
);
625 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
627 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
628 ok( hr
== S_OK
, "got %08x\n", hr
);
630 hr
= set_output( writer
);
631 ok( hr
== S_OK
, "got %08x\n", hr
);
633 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
634 ok( hr
== S_OK
, "got %08x\n", hr
);
635 check_output( writer
, expected
, 250, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
636 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
638 /* called after WsWriteEnvelopeStart */
639 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &action2
,
640 sizeof(action2
), NULL
);
641 ok( hr
== S_OK
, "got %08x\n", hr
);
642 check_output( writer
, expected
, 250, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
643 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
645 WsFreeMessage( msg
);
646 WsFreeWriter( writer
);
649 static void test_WsRemoveHeader(void)
651 static const char expected
[] =
652 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
653 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
654 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
655 "<a:Action s:mustUnderstand=\"1\">action</a:Action></s:Header>"
656 "<s:Body/></s:Envelope>";
657 static const char expected2
[] =
658 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
659 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
660 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
661 "</s:Header><s:Body/></s:Envelope>";
662 static const WS_XML_STRING action
= {6, (BYTE
*)"action"};
666 hr
= WsSetHeader( NULL
, 0, 0, 0, NULL
, 0, NULL
);
667 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
669 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
671 ok( hr
== S_OK
, "got %08x\n", hr
);
673 hr
= WsRemoveHeader( NULL
, 0, NULL
);
674 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
676 hr
= WsRemoveHeader( msg
, 0, NULL
);
677 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
679 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
680 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
682 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
683 ok( hr
== S_OK
, "got %08x\n", hr
);
684 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
686 hr
= WsRemoveHeader( msg
, 0, NULL
);
687 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
689 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
690 ok( hr
== S_OK
, "got %08x\n", hr
);
691 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
693 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &action
,
694 sizeof(action
), NULL
);
695 ok( hr
== S_OK
, "got %08x\n", hr
);
696 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
698 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
699 ok( hr
== S_OK
, "got %08x\n", hr
);
700 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
703 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
704 ok( hr
== S_OK
, "got %08x\n", hr
);
705 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
707 WsFreeMessage( msg
);
710 static void test_WsAddMappedHeader(void)
712 static const WS_XML_STRING header
= {6, (BYTE
*)"Header"}, value
= {5, (BYTE
*)"value"};
716 hr
= WsAddMappedHeader( NULL
, NULL
, 0, 0, NULL
, 0, NULL
);
717 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
719 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
720 ok( hr
== S_OK
, "got %08x\n", hr
);
722 hr
= WsAddMappedHeader( msg
, NULL
, 0, 0, NULL
, 0, NULL
);
723 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
725 hr
= WsAddMappedHeader( msg
, &header
, 0, 0, NULL
, 0, NULL
);
726 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
728 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
729 ok( hr
== S_OK
, "got %08x\n", hr
);
731 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, NULL
, 0, NULL
);
732 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
734 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), NULL
);
735 ok( hr
== S_OK
, "got %08x\n", hr
);
738 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), NULL
);
739 ok( hr
== S_OK
, "got %08x\n", hr
);
741 WsFreeMessage( msg
);
744 static void test_WsRemoveMappedHeader(void)
746 static const WS_XML_STRING header
= {6, (BYTE
*)"Header"}, value
= {5, (BYTE
*)"value"};
750 hr
= WsRemoveMappedHeader( NULL
, NULL
, NULL
);
751 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
753 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
754 ok( hr
== S_OK
, "got %08x\n", hr
);
756 hr
= WsRemoveMappedHeader( msg
, NULL
, NULL
);
757 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
759 hr
= WsRemoveMappedHeader( msg
, &header
, NULL
);
760 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
762 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
763 ok( hr
== S_OK
, "got %08x\n", hr
);
765 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), NULL
);
766 ok( hr
== S_OK
, "got %08x\n", hr
);
768 hr
= WsRemoveMappedHeader( msg
, &header
, NULL
);
769 ok( hr
== S_OK
, "got %08x\n", hr
);
772 hr
= WsRemoveMappedHeader( msg
, &header
, NULL
);
773 ok( hr
== S_OK
, "got %08x\n", hr
);
775 WsFreeMessage( msg
);
778 static void test_WsAddCustomHeader(void)
780 static const char expected
[] =
781 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
782 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
783 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
784 "<header xmlns=\"ns\">value</header></s:Header><s:Body/></s:Envelope>";
785 static const char expected2
[] =
786 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
787 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
788 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
789 "</s:Header><s:Body/></s:Envelope>";
790 static const char expected3
[] =
791 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
792 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
793 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
794 "<header xmlns=\"ns\">value</header><header xmlns=\"ns\">value2</header>"
795 "</s:Header><s:Body/></s:Envelope>";
796 static const char expected4
[] =
797 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
798 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
799 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
800 "<header xmlns=\"ns\">value</header><header xmlns=\"ns\">value2</header>"
801 "<header2 xmlns=\"ns\">value2</header2></s:Header><s:Body/></s:Envelope>";
802 static WS_XML_STRING header
= {6, (BYTE
*)"header"}, ns
= {2, (BYTE
*)"ns"};
803 static WS_XML_STRING header2
= {7, (BYTE
*)"header2"};
804 static WCHAR valueW
[] = {'v','a','l','u','e',0};
805 static WCHAR value2W
[] = {'v','a','l','u','e','2',0};
808 WS_ELEMENT_DESCRIPTION desc
;
809 WS_STRUCT_DESCRIPTION s
;
810 WS_FIELD_DESCRIPTION f
, *fields
[1];
816 hr
= WsAddCustomHeader( NULL
, NULL
, 0, NULL
, 0, 0, NULL
);
817 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
819 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
820 ok( hr
== S_OK
, "got %08x\n", hr
);
822 hr
= WsAddCustomHeader( msg
, NULL
, 0, NULL
, 0, 0, NULL
);
823 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
825 memset( &f
, 0, sizeof(f
) );
826 f
.mapping
= WS_TEXT_FIELD_MAPPING
;
827 f
.type
= WS_WSZ_TYPE
;
830 memset( &s
, 0, sizeof(s
) );
831 s
.size
= sizeof(struct header
);
832 s
.alignment
= TYPE_ALIGNMENT(struct header
);
836 desc
.elementLocalName
= &header
;
837 desc
.elementNs
= &ns
;
838 desc
.type
= WS_STRUCT_TYPE
;
839 desc
.typeDescription
= &s
;
840 hr
= WsAddCustomHeader( msg
, &desc
, 0, NULL
, 0, 0, NULL
);
841 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
843 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
844 ok( hr
== S_OK
, "got %08x\n", hr
);
845 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
848 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &test
, sizeof(test
), 0, NULL
);
849 ok( hr
== S_OK
, "got %08x\n", hr
);
850 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
852 test
.value
= value2W
;
853 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &test
, sizeof(test
), 0, NULL
);
854 ok( hr
== S_OK
, "got %08x\n", hr
);
855 check_output_header( msg
, expected3
, -1, strstr(expected3
, "urn:uuid:") - expected3
, 46, __LINE__
);
857 desc
.elementLocalName
= &header2
;
858 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &test
, sizeof(test
), 0, NULL
);
859 ok( hr
== S_OK
, "got %08x\n", hr
);
860 check_output_header( msg
, expected4
, -1, strstr(expected4
, "urn:uuid:") - expected4
, 46, __LINE__
);
862 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, NULL
, 0, 0, NULL
);
863 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
865 WsFreeMessage( msg
);
868 static void test_WsRemoveCustomHeader(void)
870 static const char expected
[] =
871 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
872 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
873 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
874 "<test xmlns=\"ns\">value</test></s:Header><s:Body/></s:Envelope>";
875 static const char expected2
[] =
876 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
877 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
878 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
879 "</s:Header><s:Body/></s:Envelope>";
880 static const char expected3
[] =
881 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
882 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
883 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
884 "<test xmlns=\"ns\">value</test><test xmlns=\"ns\">value2</test>"
885 "</s:Header><s:Body/></s:Envelope>";
886 static WS_XML_STRING localname
= {4, (BYTE
*)"test"}, ns
= {2, (BYTE
*)"ns"};
887 static const WS_XML_STRING value
= {5, (BYTE
*)"value"};
888 static const WS_XML_STRING value2
= {6, (BYTE
*)"value2"};
891 WS_ELEMENT_DESCRIPTION desc
;
893 hr
= WsRemoveCustomHeader( NULL
, NULL
, NULL
, NULL
);
894 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
896 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
897 ok( hr
== S_OK
, "got %08x\n", hr
);
899 hr
= WsRemoveCustomHeader( msg
, &localname
, &ns
, NULL
);
900 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
902 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
903 ok( hr
== S_OK
, "got %08x\n", hr
);
904 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
906 desc
.elementLocalName
= &localname
;
907 desc
.elementNs
= &ns
;
908 desc
.type
= WS_XML_STRING_TYPE
;
909 desc
.typeDescription
= NULL
;
910 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), 0, NULL
);
911 ok( hr
== S_OK
, "got %08x\n", hr
);
912 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
914 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &value2
, sizeof(value2
), 0, NULL
);
915 ok( hr
== S_OK
, "got %08x\n", hr
);
916 check_output_header( msg
, expected3
, -1, strstr(expected3
, "urn:uuid:") - expected3
, 46, __LINE__
);
918 hr
= WsRemoveCustomHeader( msg
, NULL
, NULL
, NULL
);
919 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
921 hr
= WsRemoveCustomHeader( msg
, &localname
, NULL
, NULL
);
922 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
924 hr
= WsRemoveCustomHeader( msg
, &localname
, &ns
, NULL
);
925 ok( hr
== S_OK
, "got %08x\n", hr
);
926 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
929 hr
= WsRemoveCustomHeader( msg
, &localname
, &ns
, NULL
);
930 ok( hr
== S_OK
, "got %08x\n", hr
);
932 WsFreeMessage( msg
);
935 static HRESULT
set_input( WS_XML_READER
*reader
, const char *data
, ULONG size
)
937 WS_XML_READER_TEXT_ENCODING text
= {{WS_XML_READER_ENCODING_TYPE_TEXT
}, WS_CHARSET_AUTO
};
938 WS_XML_READER_BUFFER_INPUT buf
;
940 buf
.input
.inputType
= WS_XML_READER_INPUT_TYPE_BUFFER
;
941 buf
.encodedData
= (void *)data
;
942 buf
.encodedDataSize
= size
;
943 return WsSetInput( reader
, &text
.encoding
, &buf
.input
, NULL
, 0, NULL
);
946 static void test_WsReadEnvelopeStart(void)
948 static const char xml
[] =
949 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body/></s:Envelope>";
950 WS_MESSAGE
*msg
, *msg2
;
951 WS_XML_READER
*reader
;
952 WS_MESSAGE_STATE state
;
953 const WS_XML_NODE
*node
;
956 hr
= WsReadEnvelopeStart( NULL
, NULL
, NULL
, NULL
, NULL
);
957 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
959 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
960 ok( hr
== S_OK
, "got %08x\n", hr
);
962 hr
= WsReadEnvelopeStart( msg
, NULL
, NULL
, NULL
, NULL
);
963 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
965 hr
= WsCreateReader( NULL
, 0, &reader
, NULL
);
966 ok( hr
== S_OK
, "got %08x\n", hr
);
968 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
969 ok( hr
== S_OK
, "got %08x\n", hr
);
971 hr
= WsReadEnvelopeStart( msg
, reader
, NULL
, NULL
, NULL
);
972 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
974 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg2
, NULL
);
975 ok( hr
== S_OK
, "got %08x\n", hr
);
977 hr
= set_input( reader
, xml
, strlen(xml
) );
978 ok( hr
== S_OK
, "got %08x\n", hr
);
980 hr
= WsReadEnvelopeStart( msg2
, reader
, NULL
, NULL
, NULL
);
981 ok( hr
== S_OK
, "got %08x\n", hr
);
984 hr
= WsGetMessageProperty( msg2
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
985 ok( hr
== S_OK
, "got %08x\n", hr
);
986 ok( state
== WS_MESSAGE_STATE_READING
, "got %u\n", state
);
988 hr
= WsGetReaderNode( reader
, &node
, NULL
);
989 ok( hr
== S_OK
, "got %08x\n", hr
);
990 ok( node
->nodeType
== WS_XML_NODE_TYPE_END_ELEMENT
, "got %u\n", node
->nodeType
);
992 hr
= WsReadEndElement( reader
, NULL
);
993 ok( hr
== S_OK
, "got %08x\n", hr
);
995 hr
= WsGetReaderNode( reader
, &node
, NULL
);
996 ok( hr
== S_OK
, "got %08x\n", hr
);
997 ok( node
->nodeType
== WS_XML_NODE_TYPE_END_ELEMENT
, "got %u\n", node
->nodeType
);
999 hr
= WsReadEndElement( reader
, NULL
);
1000 ok( hr
== S_OK
, "got %08x\n", hr
);
1002 hr
= WsGetReaderNode( reader
, &node
, NULL
);
1003 ok( hr
== S_OK
, "got %08x\n", hr
);
1004 ok( node
->nodeType
== WS_XML_NODE_TYPE_EOF
, "got %u\n", node
->nodeType
);
1006 WsFreeMessage( msg
);
1007 WsFreeMessage( msg2
);
1008 WsFreeReader( reader
);
1011 static void test_WsReadEnvelopeEnd(void)
1013 static const char xml
[] =
1014 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body></s:Body></s:Envelope>";
1015 WS_MESSAGE
*msg
, *msg2
;
1016 WS_XML_READER
*reader
;
1017 WS_MESSAGE_STATE state
;
1020 hr
= WsReadEnvelopeEnd( NULL
, NULL
);
1021 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1023 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
1024 ok( hr
== S_OK
, "got %08x\n", hr
);
1026 hr
= WsCreateReader( NULL
, 0, &reader
, NULL
);
1027 ok( hr
== S_OK
, "got %08x\n", hr
);
1029 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1030 ok( hr
== S_OK
, "got %08x\n", hr
);
1032 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg2
, NULL
);
1033 ok( hr
== S_OK
, "got %08x\n", hr
);
1035 hr
= set_input( reader
, xml
, strlen(xml
) );
1036 ok( hr
== S_OK
, "got %08x\n", hr
);
1038 hr
= WsReadEnvelopeEnd( msg2
, NULL
);
1039 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
1041 hr
= WsReadEnvelopeStart( msg2
, reader
, NULL
, NULL
, NULL
);
1042 ok( hr
== S_OK
, "got %08x\n", hr
);
1044 hr
= WsReadEnvelopeEnd( msg2
, NULL
);
1045 ok( hr
== S_OK
, "got %08x\n", hr
);
1048 hr
= WsGetMessageProperty( msg2
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
1049 ok( hr
== S_OK
, "got %08x\n", hr
);
1050 ok( state
== WS_MESSAGE_STATE_DONE
, "got %u\n", state
);
1052 WsFreeMessage( msg
);
1053 WsFreeMessage( msg2
);
1054 WsFreeReader( reader
);
1057 static void test_WsReadBody(void)
1059 static const char xml
[] =
1060 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
1061 "<u xmlns=\"ns\"><val>1</val></u></s:Body></s:Envelope>";
1063 WS_MESSAGE
*msg
, *msg2
;
1064 WS_XML_READER
*reader
;
1065 WS_MESSAGE_STATE state
;
1066 WS_XML_STRING localname
= {1, (BYTE
*)"t"}, localname2
= {1, (BYTE
*)"u"};
1067 WS_XML_STRING val
= {3, (BYTE
*)"val"}, ns
= {2, (BYTE
*)"ns"};
1068 WS_ELEMENT_DESCRIPTION desc
;
1069 WS_STRUCT_DESCRIPTION s
;
1070 WS_FIELD_DESCRIPTION f
, *fields
[1];
1077 hr
= WsCreateHeap( 1 << 16, 0, NULL
, 0, &heap
, NULL
);
1078 ok( hr
== S_OK
, "got %08x\n", hr
);
1080 hr
= WsReadBody( NULL
, NULL
, 0, NULL
, NULL
, 0, NULL
);
1081 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1083 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
1084 ok( hr
== S_OK
, "got %08x\n", hr
);
1086 hr
= WsCreateReader( NULL
, 0, &reader
, NULL
);
1087 ok( hr
== S_OK
, "got %08x\n", hr
);
1089 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1090 ok( hr
== S_OK
, "got %08x\n", hr
);
1092 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg2
, NULL
);
1093 ok( hr
== S_OK
, "got %08x\n", hr
);
1095 hr
= WsReadBody( msg2
, NULL
, 0, NULL
, NULL
, 0, NULL
);
1096 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1098 hr
= set_input( reader
, xml
, strlen(xml
) );
1099 ok( hr
== S_OK
, "got %08x\n", hr
);
1101 hr
= WsReadEnvelopeStart( msg2
, reader
, NULL
, NULL
, NULL
);
1102 ok( hr
== S_OK
, "got %08x\n", hr
);
1104 hr
= WsReadBody( msg2
, NULL
, WS_READ_REQUIRED_VALUE
, heap
, &test
, sizeof(test
), NULL
);
1105 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1107 memset( &f
, 0, sizeof(f
) );
1108 f
.mapping
= WS_ELEMENT_FIELD_MAPPING
;
1111 f
.type
= WS_UINT32_TYPE
;
1114 memset( &s
, 0, sizeof(s
) );
1115 s
.size
= sizeof(struct test
);
1116 s
.alignment
= TYPE_ALIGNMENT(struct test
);
1119 s
.typeLocalName
= &localname
;
1122 desc
.elementLocalName
= &localname2
;
1123 desc
.elementNs
= &ns
;
1124 desc
.type
= WS_STRUCT_TYPE
;
1125 desc
.typeDescription
= &s
;
1127 memset( &test
, 0, sizeof(test
) );
1128 hr
= WsReadBody( msg2
, &desc
, WS_READ_REQUIRED_VALUE
, heap
, &test
, sizeof(test
), NULL
);
1129 ok( hr
== S_OK
, "got %08x\n", hr
);
1130 ok( test
.val
== 1, "got %u\n", test
.val
);
1133 hr
= WsGetMessageProperty( msg2
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
1134 ok( hr
== S_OK
, "got %08x\n", hr
);
1135 ok( state
== WS_MESSAGE_STATE_READING
, "got %u\n", state
);
1137 hr
= WsReadEnvelopeEnd( msg2
, NULL
);
1138 ok( hr
== S_OK
, "got %08x\n", hr
);
1140 WsFreeMessage( msg
);
1141 WsFreeMessage( msg2
);
1142 WsFreeReader( reader
);
1146 static void test_WsResetMessage(void)
1149 WS_MESSAGE_STATE state
;
1150 WS_ENVELOPE_VERSION env_version
;
1151 WS_ADDRESSING_VERSION addr_version
;
1154 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
1155 ok( hr
== S_OK
, "got %08x\n", hr
);
1157 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1158 ok( hr
== S_OK
, "got %08x\n", hr
);
1160 hr
= WsResetMessage( msg
, NULL
);
1161 ok( hr
== S_OK
, "got %08x\n", hr
);
1164 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
1165 ok( hr
== S_OK
, "got %08x\n", hr
);
1166 ok( state
== WS_MESSAGE_STATE_EMPTY
, "got %u\n", state
);
1168 env_version
= 0xdeadbeef;
1169 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
1170 sizeof(env_version
), NULL
);
1171 ok( hr
== S_OK
, "got %08x\n", hr
);
1172 ok( env_version
== WS_ENVELOPE_VERSION_SOAP_1_1
, "got %u\n", env_version
);
1174 addr_version
= 0xdeadbeef;
1175 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
, &addr_version
,
1176 sizeof(addr_version
), NULL
);
1177 ok( hr
== S_OK
, "got %08x\n", hr
);
1178 ok( addr_version
== WS_ADDRESSING_VERSION_0_9
, "got %u\n", addr_version
);
1180 WsFreeMessage( msg
);
1183 static void test_WsGetHeader(void)
1185 static char expected
[] =
1186 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
1187 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
1188 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
1189 "<a:Action s:mustUnderstand=\"1\">action</a:Action></s:Header><s:Body/></s:Envelope>";
1190 static char expected2
[] =
1191 "<Envelope><Header><Action mustUnderstand=\"1\" "
1192 "xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">action</Action>"
1193 "</Header><Body/></Envelope>";
1194 static char expected3
[] =
1195 "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
1196 "<Action s:mustUnderstand=\"1\" "
1197 "xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">action</Action>"
1198 "</s:Header><s:Body/></s:Envelope>";
1199 static WCHAR action
[] = {'a','c','t','i','o','n',0};
1204 hr
= WsGetHeader( NULL
, 0, 0, 0, NULL
, NULL
, 0, NULL
);
1205 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1207 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
1208 ok( hr
== S_OK
, "got %08x\n", hr
);
1210 hr
= WsGetHeader( msg
, 0, 0, 0, NULL
, NULL
, 0, NULL
);
1211 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1213 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1214 ok( hr
== S_OK
, "got %08x\n", hr
);
1216 hr
= WsGetHeader( msg
, 0, 0, 0, NULL
, NULL
, 0, NULL
);
1217 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1219 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, 0, 0, NULL
, NULL
, 0, NULL
);
1220 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1222 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, 0, NULL
, NULL
, 0, NULL
);
1223 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1225 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_READ_NILLABLE_POINTER
, NULL
, NULL
, 0, NULL
);
1226 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1228 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_READ_REQUIRED_POINTER
, NULL
, NULL
, 0, NULL
);
1229 ok( hr
== WS_E_INVALID_FORMAT
, "got %08x\n", hr
);
1232 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
1233 ok( hr
== S_OK
, "got %08x\n", hr
);
1234 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
1236 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_READ_REQUIRED_POINTER
, NULL
, NULL
, 0, NULL
);
1237 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1240 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_READ_REQUIRED_POINTER
, NULL
, &ptr
, 0, NULL
);
1241 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1244 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_READ_REQUIRED_POINTER
, NULL
, &ptr
, sizeof(ptr
), NULL
);
1245 ok( hr
== S_OK
, "got %08x\n", hr
);
1246 ok( ptr
!= NULL
, "ptr not set\n" );
1247 ok( !memcmp( ptr
, action
, sizeof(action
) ), "wrong data\n" );
1248 WsFreeMessage( msg
);
1250 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_NONE
, WS_ADDRESSING_VERSION_TRANSPORT
, NULL
, 0, &msg
, NULL
);
1251 ok( hr
== S_OK
, "got %08x\n", hr
);
1253 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1254 ok( hr
== S_OK
, "got %08x\n", hr
);
1257 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
1258 ok( hr
== S_OK
, "got %08x\n", hr
);
1259 if (hr
== S_OK
) check_output_header( msg
, expected2
, -1, 0, 0, __LINE__
);
1262 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_READ_REQUIRED_POINTER
, NULL
, &ptr
, sizeof(ptr
), NULL
);
1263 ok( hr
== S_OK
, "got %08x\n", hr
);
1264 ok( ptr
!= NULL
, "ptr not set\n" );
1265 ok( !memcmp( ptr
, action
, sizeof(action
) ), "wrong data\n" );
1266 WsFreeMessage( msg
);
1268 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_TRANSPORT
, NULL
, 0, &msg
, NULL
);
1269 ok( hr
== S_OK
, "got %08x\n", hr
);
1271 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1272 ok( hr
== S_OK
, "got %08x\n", hr
);
1275 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
1276 ok( hr
== S_OK
, "got %08x\n", hr
);
1277 if (hr
== S_OK
) check_output_header( msg
, expected3
, -1, 0, 0, __LINE__
);
1280 hr
= WsGetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_READ_REQUIRED_POINTER
, NULL
, &ptr
, sizeof(ptr
), NULL
);
1281 ok( hr
== S_OK
, "got %08x\n", hr
);
1282 ok( ptr
!= NULL
, "ptr not set\n" );
1283 ok( !memcmp( ptr
, action
, sizeof(action
) ), "wrong data\n" );
1284 WsFreeMessage( msg
);
1287 static void test_WsGetCustomHeader(void)
1289 static char expected
[] =
1290 "<Envelope><Header><Custom xmlns=\"ns\">value</Custom></Header><Body/></Envelope>";
1291 static WS_XML_STRING custom
= {6, (BYTE
*)"Custom"}, ns
= {2, (BYTE
*)"ns"};
1292 static WCHAR valueW
[] = {'v','a','l','u','e',0};
1293 WS_ELEMENT_DESCRIPTION desc
;
1294 WS_STRUCT_DESCRIPTION s
;
1295 WS_FIELD_DESCRIPTION f
, *fields
[1];
1303 hr
= WsGetCustomHeader( NULL
, NULL
, 0, 0, 0, NULL
, NULL
, 0, NULL
, NULL
);
1304 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1306 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_NONE
, WS_ADDRESSING_VERSION_TRANSPORT
, NULL
, 0, &msg
, NULL
);
1307 ok( hr
== S_OK
, "got %08x\n", hr
);
1309 hr
= WsGetCustomHeader( msg
, NULL
, 0, 0, 0, NULL
, NULL
, 0, NULL
, NULL
);
1310 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1312 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1313 ok( hr
== S_OK
, "got %08x\n", hr
);
1315 memset( &f
, 0, sizeof(f
) );
1316 f
.mapping
= WS_TEXT_FIELD_MAPPING
;
1317 f
.type
= WS_WSZ_TYPE
;
1320 memset( &s
, 0, sizeof(s
) );
1321 s
.size
= sizeof(struct header
);
1322 s
.alignment
= TYPE_ALIGNMENT(struct header
);
1326 desc
.elementLocalName
= &custom
;
1327 desc
.elementNs
= &ns
;
1328 desc
.type
= WS_STRUCT_TYPE
;
1329 desc
.typeDescription
= &s
;
1331 test
.value
= valueW
;
1332 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &test
, sizeof(test
), 0, NULL
);
1333 ok( hr
== S_OK
, "got %08x\n", hr
);
1334 check_output_header( msg
, expected
, -1, 0, 0, __LINE__
);
1336 hr
= WsGetCustomHeader( msg
, &desc
, 0, 0, 0, NULL
, NULL
, 0, NULL
, NULL
);
1337 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1339 hr
= WsGetCustomHeader( msg
, &desc
, WS_SINGLETON_HEADER
, 1, 0, NULL
, NULL
, 0, NULL
, NULL
);
1340 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1342 hr
= WsGetCustomHeader( msg
, &desc
, WS_SINGLETON_HEADER
, 0, WS_READ_REQUIRED_VALUE
, NULL
, NULL
, 0, NULL
, NULL
);
1343 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1345 memset( &test
, 0, sizeof(test
) );
1346 hr
= WsGetCustomHeader( msg
, &desc
, WS_SINGLETON_HEADER
, 0, WS_READ_REQUIRED_VALUE
, NULL
, &test
, sizeof(test
),
1348 ok( hr
== S_OK
, "got %08x\n", hr
);
1349 ok( test
.value
!= NULL
, "value not set\n" );
1350 ok( !memcmp( test
.value
, valueW
, sizeof(valueW
) ), "wrong value\n" );
1351 WsFreeMessage( msg
);
1356 test_WsCreateMessage();
1357 test_WsCreateMessageForChannel();
1358 test_WsInitializeMessage();
1359 test_WsAddressMessage();
1360 test_WsWriteEnvelopeStart();
1361 test_WsWriteEnvelopeEnd();
1364 test_WsRemoveHeader();
1365 test_WsAddMappedHeader();
1366 test_WsRemoveMappedHeader();
1367 test_WsAddCustomHeader();
1368 test_WsRemoveCustomHeader();
1369 test_WsReadEnvelopeStart();
1370 test_WsReadEnvelopeEnd();
1372 test_WsResetMessage();
1374 test_WsGetCustomHeader();