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
;
169 hr
= WsInitializeMessage( NULL
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
170 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
172 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
,
174 ok( hr
== S_OK
, "got %08x\n", hr
);
176 hr
= WsInitializeMessage( msg
, 0xdeadbeef, NULL
, NULL
);
177 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
179 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
180 ok( hr
== S_OK
, "got %08x\n", hr
);
182 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
183 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
186 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
187 ok( hr
== S_OK
, "got %08x\n", hr
);
188 ok( state
== WS_MESSAGE_STATE_INITIALIZED
, "got %u\n", state
);
191 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
193 ok( hr
== S_OK
, "got %08x\n", hr
);
194 ok( !addressed
, "unexpected value %d\n", addressed
);
196 state
= WS_MESSAGE_STATE_EMPTY
;
197 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
198 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
200 env_version
= WS_ENVELOPE_VERSION_SOAP_1_1
;
201 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
202 sizeof(env_version
), NULL
);
203 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
205 addr_version
= WS_ADDRESSING_VERSION_0_9
;
206 hr
= WsSetMessageProperty( msg
, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
, &addr_version
,
207 sizeof(addr_version
), NULL
);
208 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
209 WsFreeMessage( msg
);
212 static void test_WsAddressMessage(void)
214 static WCHAR localhost
[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t','/',0};
217 WS_ENDPOINT_ADDRESS endpoint
;
220 hr
= WsAddressMessage( NULL
, NULL
, NULL
);
221 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
223 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
,
225 ok( hr
== S_OK
, "got %08x\n", hr
);
227 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
229 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
231 hr
= WsAddressMessage( msg
, NULL
, NULL
);
232 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
234 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
235 ok( hr
== S_OK
, "got %08x\n", hr
);
238 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
240 ok( hr
== S_OK
, "got %08x\n", hr
);
241 ok( !addressed
, "unexpected value %d\n", addressed
);
243 hr
= WsAddressMessage( msg
, NULL
, NULL
);
244 ok( hr
== S_OK
, "got %08x\n", hr
);
247 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
249 ok( hr
== S_OK
, "got %08x\n", hr
);
250 ok( addressed
== TRUE
, "unexpected value %d\n", addressed
);
251 WsFreeMessage( msg
);
253 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
,
255 ok( hr
== S_OK
, "got %08x\n", hr
);
257 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
258 ok( hr
== S_OK
, "got %08x\n", hr
);
260 memset( &endpoint
, 0, sizeof(endpoint
) );
261 endpoint
.url
.chars
= localhost
;
262 endpoint
.url
.length
= sizeof(localhost
)/sizeof(localhost
[0]);
263 hr
= WsAddressMessage( msg
, &endpoint
, NULL
);
264 ok( hr
== S_OK
, "got %08x\n", hr
);
267 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_IS_ADDRESSED
, &addressed
, sizeof(addressed
),
269 ok( hr
== S_OK
, "got %08x\n", hr
);
270 ok( addressed
== TRUE
, "unexpected value %d\n", addressed
);
271 WsFreeMessage( msg
);
274 static HRESULT
set_output( WS_XML_WRITER
*writer
)
276 WS_XML_WRITER_TEXT_ENCODING text
= { {WS_XML_WRITER_ENCODING_TYPE_TEXT
}, WS_CHARSET_UTF8
};
277 WS_XML_WRITER_BUFFER_OUTPUT buf
= { {WS_XML_WRITER_OUTPUT_TYPE_BUFFER
} };
278 return WsSetOutput( writer
, &text
.encoding
, &buf
.output
, NULL
, 0, NULL
);
281 static void check_output( WS_XML_WRITER
*writer
, const char *expected
, int len
, unsigned int skip_start
,
282 unsigned int skip_len
, unsigned int line
)
287 if (len
== -1) len
= strlen( expected
);
288 memset( &bytes
, 0, sizeof(bytes
) );
289 hr
= WsGetWriterProperty( writer
, WS_XML_WRITER_PROPERTY_BYTES
, &bytes
, sizeof(bytes
), NULL
);
290 ok( hr
== S_OK
, "%u: got %08x\n", line
, hr
);
291 ok( bytes
.length
== len
, "%u: got %u expected %u\n", line
, bytes
.length
, len
);
292 if (bytes
.length
!= len
) return;
295 ok( !memcmp( bytes
.bytes
, expected
, skip_start
), "%u: got %s expected %s\n", line
,
296 bytes
.bytes
, expected
);
297 ok( !memcmp( bytes
.bytes
+ skip_start
+ skip_len
, expected
+ skip_start
+ skip_len
,
298 len
- skip_start
- skip_len
), "%u: got %s expected %s\n", line
, bytes
.bytes
, expected
);
301 ok( !memcmp( bytes
.bytes
, expected
, len
), "%u: got %s expected %s\n", line
, bytes
.bytes
,
305 static void check_output_header( WS_MESSAGE
*msg
, const char *expected
, int len
, unsigned int skip_start
,
306 unsigned int skip_len
, unsigned int line
)
308 WS_XML_WRITER
*writer
;
312 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
313 ok( hr
== S_OK
, "got %08x\n", hr
);
315 hr
= set_output( writer
);
316 ok( hr
== S_OK
, "got %08x\n", hr
);
318 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_HEADER_BUFFER
, &buf
, sizeof(buf
), NULL
);
319 ok( hr
== S_OK
, "got %08x\n", hr
);
321 hr
= WsWriteXmlBuffer( writer
, buf
, NULL
);
322 ok( hr
== S_OK
, "got %08x\n", hr
);
324 check_output( writer
, expected
, len
, skip_start
, skip_len
, line
);
325 WsFreeWriter( writer
);
328 static void test_WsWriteEnvelopeStart(void)
330 static const char expected
[] =
331 "<s:Envelope xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" "
332 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header>"
333 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
334 "<a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>"
335 "</a:ReplyTo></s:Header>";
336 static const char expected2
[] =
337 "<s:Envelope xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" "
338 "xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header>"
339 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
340 "<a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>"
341 "</a:ReplyTo></s:Header><s:Body/></s:Envelope>";
342 static const char expected3
[] =
343 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Header/><s:Body/></s:Envelope>";
346 WS_XML_WRITER
*writer
;
347 WS_MESSAGE_STATE state
;
349 hr
= WsWriteEnvelopeStart( NULL
, NULL
, NULL
, NULL
, NULL
);
350 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
352 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
353 ok( hr
== S_OK
, "got %08x\n", hr
);
355 hr
= WsWriteEnvelopeStart( NULL
, writer
, NULL
, NULL
, NULL
);
356 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
358 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
,
360 ok( hr
== S_OK
, "got %08x\n", hr
);
362 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
363 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
365 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
366 ok( hr
== S_OK
, "got %08x\n", hr
);
368 hr
= set_output( writer
);
369 ok( hr
== S_OK
, "got %08x\n", hr
);
371 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
372 ok( hr
== S_OK
, "got %08x\n", hr
);
373 check_output( writer
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
374 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
377 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
378 ok( hr
== S_OK
, "got %08x\n", hr
);
379 ok( state
== WS_MESSAGE_STATE_WRITING
, "got %u\n", state
);
380 WsFreeMessage( msg
);
382 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_TRANSPORT
, NULL
, 0, &msg
,
384 ok( hr
== S_OK
, "got %08x\n", hr
);
386 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
387 ok( hr
== S_OK
, "got %08x\n", hr
);
389 hr
= set_output( writer
);
390 ok( hr
== S_OK
, "got %08x\n", hr
);
392 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
393 ok( hr
== S_OK
, "got %08x\n", hr
);
394 check_output_header( msg
, expected3
, -1, 0, 0, __LINE__
);
396 WsFreeMessage( msg
);
397 WsFreeWriter( writer
);
400 static void test_WsWriteEnvelopeEnd(void)
402 static const char expected
[] =
403 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
404 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
405 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
406 "</s:Header><s:Body/></s:Envelope>";
409 WS_XML_WRITER
*writer
;
410 WS_MESSAGE_STATE state
;
412 hr
= WsWriteEnvelopeEnd( NULL
, NULL
);
413 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
415 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
417 ok( hr
== S_OK
, "got %08x\n", hr
);
419 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
420 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
422 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
423 ok( hr
== S_OK
, "got %08x\n", hr
);
425 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
426 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
428 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
429 ok( hr
== S_OK
, "got %08x\n", hr
);
431 hr
= set_output( writer
);
432 ok( hr
== S_OK
, "got %08x\n", hr
);
434 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
435 ok( hr
== S_OK
, "got %08x\n", hr
);
437 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
438 ok( hr
== S_OK
, "got %08x\n", hr
);
439 check_output( writer
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
440 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
443 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
444 ok( hr
== S_OK
, "got %08x\n", hr
);
445 ok( state
== WS_MESSAGE_STATE_DONE
, "got %u\n", state
);
447 WsFreeMessage( msg
);
448 WsFreeWriter( writer
);
451 static void test_WsWriteBody(void)
453 static char expected
[] =
454 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
455 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
456 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
457 "</s:Header><s:Body><u xmlns=\"ns\"><val>1</val></u></s:Body></s:Envelope>";
458 static char expected2
[] =
459 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
460 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
461 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
462 "</s:Header><s:Body/></s:Envelope>";
463 WS_XML_STRING localname
= {1, (BYTE
*)"t"}, localname2
= {1, (BYTE
*)"u"};
464 WS_XML_STRING val
= {3, (BYTE
*)"val"}, ns
= {2, (BYTE
*)"ns"};
467 WS_XML_WRITER
*writer
;
468 WS_MESSAGE_STATE state
;
469 WS_ELEMENT_DESCRIPTION desc
;
470 WS_STRUCT_DESCRIPTION s
;
471 WS_FIELD_DESCRIPTION f
, *fields
[1];
477 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
479 ok( hr
== S_OK
, "got %08x\n", hr
);
481 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
482 ok( hr
== S_OK
, "got %08x\n", hr
);
484 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
485 ok( hr
== S_OK
, "got %08x\n", hr
);
487 hr
= set_output( writer
);
488 ok( hr
== S_OK
, "got %08x\n", hr
);
490 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
491 ok( hr
== S_OK
, "got %08x\n", hr
);
493 hr
= WsWriteBody( NULL
, NULL
, 0, NULL
, 0, NULL
);
494 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
496 hr
= WsWriteBody( msg
, NULL
, 0, NULL
, 0, NULL
);
497 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
499 memset( &f
, 0, sizeof(f
) );
500 f
.mapping
= WS_ELEMENT_FIELD_MAPPING
;
503 f
.type
= WS_UINT32_TYPE
;
506 memset( &s
, 0, sizeof(s
) );
507 s
.size
= sizeof(struct test
);
508 s
.alignment
= TYPE_ALIGNMENT(struct test
);
511 s
.typeLocalName
= &localname
;
514 desc
.elementLocalName
= &localname2
;
515 desc
.elementNs
= &ns
;
516 desc
.type
= WS_STRUCT_TYPE
;
517 desc
.typeDescription
= &s
;
521 hr
= WsWriteBody( msg
, &desc
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
522 ok( hr
== S_OK
, "got %08x\n", hr
);
523 check_output( writer
, expected
, 240, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
524 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
527 hr
= WsGetMessageProperty( msg
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
528 ok( hr
== S_OK
, "got %08x\n", hr
);
529 ok( state
== WS_MESSAGE_STATE_WRITING
, "got %u\n", state
);
531 hr
= WsWriteEnvelopeEnd( msg
, NULL
);
532 ok( hr
== S_OK
, "got %08x\n", hr
);
533 check_output( writer
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
534 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
536 hr
= WsWriteBody( msg
, &desc
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
537 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
539 WsFreeMessage( msg
);
540 WsFreeWriter( writer
);
543 static void test_WsSetHeader(void)
545 static const char expected
[] =
546 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
547 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
548 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
549 "<a:Action s:mustUnderstand=\"1\">action</a:Action></s:Header>"
550 "<s:Body/></s:Envelope>";
551 static const char expected2
[] =
552 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
553 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
554 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
555 "<a:Action s:mustUnderstand=\"1\">action2</a:Action></s:Header>"
556 "<s:Body/></s:Envelope>";
557 static const WCHAR action
[] = {'a','c','t','i','o','n',0};
558 static const WS_XML_STRING action2
= {7, (BYTE
*)"action2"};
561 WS_XML_WRITER
*writer
;
562 const WCHAR
*ptr
= action
;
564 hr
= WsSetHeader( NULL
, 0, 0, 0, NULL
, 0, NULL
);
565 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
567 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
569 ok( hr
== S_OK
, "got %08x\n", hr
);
571 hr
= WsSetHeader( msg
, 0, 0, 0, NULL
, 0, NULL
);
572 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
574 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
,
576 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
578 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
579 ok( hr
== S_OK
, "got %08x\n", hr
);
581 hr
= WsSetHeader( msg
, 0, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
, sizeof(ptr
), NULL
);
582 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
584 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_WSZ_TYPE
, WS_WRITE_REQUIRED_POINTER
, &ptr
,
586 ok( hr
== S_OK
, "got %08x\n", hr
);
587 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
589 hr
= WsCreateWriter( NULL
, 0, &writer
, NULL
);
590 ok( hr
== S_OK
, "got %08x\n", hr
);
592 hr
= set_output( writer
);
593 ok( hr
== S_OK
, "got %08x\n", hr
);
595 hr
= WsWriteEnvelopeStart( msg
, writer
, NULL
, NULL
, NULL
);
596 ok( hr
== S_OK
, "got %08x\n", hr
);
597 check_output( writer
, expected
, 250, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
598 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
600 /* called after WsWriteEnvelopeStart */
601 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &action2
,
602 sizeof(action2
), NULL
);
603 ok( hr
== S_OK
, "got %08x\n", hr
);
604 check_output( writer
, expected
, 250, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
605 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
607 WsFreeMessage( msg
);
608 WsFreeWriter( writer
);
611 static void test_WsRemoveHeader(void)
613 static const char expected
[] =
614 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
615 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
616 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
617 "<a:Action s:mustUnderstand=\"1\">action</a:Action></s:Header>"
618 "<s:Body/></s:Envelope>";
619 static const char expected2
[] =
620 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
621 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
622 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
623 "</s:Header><s:Body/></s:Envelope>";
624 static const WS_XML_STRING action
= {6, (BYTE
*)"action"};
628 hr
= WsSetHeader( NULL
, 0, 0, 0, NULL
, 0, NULL
);
629 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
631 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
,
633 ok( hr
== S_OK
, "got %08x\n", hr
);
635 hr
= WsRemoveHeader( NULL
, 0, NULL
);
636 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
638 hr
= WsRemoveHeader( msg
, 0, NULL
);
639 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
641 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
642 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
644 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
645 ok( hr
== S_OK
, "got %08x\n", hr
);
646 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
648 hr
= WsRemoveHeader( msg
, 0, NULL
);
649 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
651 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
652 ok( hr
== S_OK
, "got %08x\n", hr
);
653 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
655 hr
= WsSetHeader( msg
, WS_ACTION_HEADER
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &action
,
656 sizeof(action
), NULL
);
657 ok( hr
== S_OK
, "got %08x\n", hr
);
658 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
660 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
661 ok( hr
== S_OK
, "got %08x\n", hr
);
662 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
665 hr
= WsRemoveHeader( msg
, WS_ACTION_HEADER
, NULL
);
666 ok( hr
== S_OK
, "got %08x\n", hr
);
667 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
669 WsFreeMessage( msg
);
672 static void test_WsAddMappedHeader(void)
674 static const WS_XML_STRING header
= {6, (BYTE
*)"Header"}, value
= {5, (BYTE
*)"value"};
678 hr
= WsAddMappedHeader( NULL
, NULL
, 0, 0, NULL
, 0, NULL
);
679 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
681 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
682 ok( hr
== S_OK
, "got %08x\n", hr
);
684 hr
= WsAddMappedHeader( msg
, NULL
, 0, 0, NULL
, 0, NULL
);
685 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
687 hr
= WsAddMappedHeader( msg
, &header
, 0, 0, NULL
, 0, NULL
);
688 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
690 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
691 ok( hr
== S_OK
, "got %08x\n", hr
);
693 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, NULL
, 0, NULL
);
694 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
696 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), NULL
);
697 ok( hr
== S_OK
, "got %08x\n", hr
);
700 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), NULL
);
701 ok( hr
== S_OK
, "got %08x\n", hr
);
703 WsFreeMessage( msg
);
706 static void test_WsRemoveMappedHeader(void)
708 static const WS_XML_STRING header
= {6, (BYTE
*)"Header"}, value
= {5, (BYTE
*)"value"};
712 hr
= WsRemoveMappedHeader( NULL
, NULL
, NULL
);
713 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
715 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
716 ok( hr
== S_OK
, "got %08x\n", hr
);
718 hr
= WsRemoveMappedHeader( msg
, NULL
, NULL
);
719 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
721 hr
= WsRemoveMappedHeader( msg
, &header
, NULL
);
722 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
724 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
725 ok( hr
== S_OK
, "got %08x\n", hr
);
727 hr
= WsAddMappedHeader( msg
, &header
, WS_XML_STRING_TYPE
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), NULL
);
728 ok( hr
== S_OK
, "got %08x\n", hr
);
730 hr
= WsRemoveMappedHeader( msg
, &header
, NULL
);
731 ok( hr
== S_OK
, "got %08x\n", hr
);
734 hr
= WsRemoveMappedHeader( msg
, &header
, NULL
);
735 ok( hr
== S_OK
, "got %08x\n", hr
);
737 WsFreeMessage( msg
);
740 static void test_WsAddCustomHeader(void)
742 static const char expected
[] =
743 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
744 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
745 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
746 "<header xmlns=\"ns\">value</header></s:Header><s:Body/></s:Envelope>";
747 static const char expected2
[] =
748 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
749 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
750 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
751 "</s:Header><s:Body/></s:Envelope>";
752 static const char expected3
[] =
753 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
754 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
755 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
756 "<header xmlns=\"ns\">value</header><header xmlns=\"ns\">value2</header>"
757 "</s:Header><s:Body/></s:Envelope>";
758 static const char expected4
[] =
759 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
760 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
761 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
762 "<header xmlns=\"ns\">value</header><header xmlns=\"ns\">value2</header>"
763 "<header2 xmlns=\"ns\">value2</header2></s:Header><s:Body/></s:Envelope>";
764 static WS_XML_STRING header
= {6, (BYTE
*)"header"}, ns
= {2, (BYTE
*)"ns"};
765 static WS_XML_STRING header2
= {7, (BYTE
*)"header2"};
766 static WCHAR valueW
[] = {'v','a','l','u','e',0};
767 static WCHAR value2W
[] = {'v','a','l','u','e','2',0};
770 WS_ELEMENT_DESCRIPTION desc
;
771 WS_STRUCT_DESCRIPTION s
;
772 WS_FIELD_DESCRIPTION f
, *fields
[1];
778 hr
= WsAddCustomHeader( NULL
, NULL
, 0, NULL
, 0, 0, NULL
);
779 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
781 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
782 ok( hr
== S_OK
, "got %08x\n", hr
);
784 hr
= WsAddCustomHeader( msg
, NULL
, 0, NULL
, 0, 0, NULL
);
785 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
787 memset( &f
, 0, sizeof(f
) );
788 f
.mapping
= WS_TEXT_FIELD_MAPPING
;
789 f
.type
= WS_WSZ_TYPE
;
792 memset( &s
, 0, sizeof(s
) );
793 s
.size
= sizeof(struct header
);
794 s
.alignment
= TYPE_ALIGNMENT(struct header
);
798 desc
.elementLocalName
= &header
;
799 desc
.elementNs
= &ns
;
800 desc
.type
= WS_STRUCT_TYPE
;
801 desc
.typeDescription
= &s
;
802 hr
= WsAddCustomHeader( msg
, &desc
, 0, NULL
, 0, 0, NULL
);
803 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
805 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
806 ok( hr
== S_OK
, "got %08x\n", hr
);
807 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
810 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &test
, sizeof(test
), 0, NULL
);
811 ok( hr
== S_OK
, "got %08x\n", hr
);
812 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
814 test
.value
= value2W
;
815 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &test
, sizeof(test
), 0, NULL
);
816 ok( hr
== S_OK
, "got %08x\n", hr
);
817 check_output_header( msg
, expected3
, -1, strstr(expected3
, "urn:uuid:") - expected3
, 46, __LINE__
);
819 desc
.elementLocalName
= &header2
;
820 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &test
, sizeof(test
), 0, NULL
);
821 ok( hr
== S_OK
, "got %08x\n", hr
);
822 check_output_header( msg
, expected4
, -1, strstr(expected4
, "urn:uuid:") - expected4
, 46, __LINE__
);
824 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, NULL
, 0, 0, NULL
);
825 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
827 WsFreeMessage( msg
);
830 static void test_WsRemoveCustomHeader(void)
832 static const char expected
[] =
833 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
834 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
835 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
836 "<test xmlns=\"ns\">value</test></s:Header><s:Body/></s:Envelope>";
837 static const char expected2
[] =
838 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
839 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
840 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
841 "</s:Header><s:Body/></s:Envelope>";
842 static const char expected3
[] =
843 "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" "
844 "xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header>"
845 "<a:MessageID>urn:uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
846 "<test xmlns=\"ns\">value</test><test xmlns=\"ns\">value2</test>"
847 "</s:Header><s:Body/></s:Envelope>";
848 static WS_XML_STRING localname
= {4, (BYTE
*)"test"}, ns
= {2, (BYTE
*)"ns"};
849 static const WS_XML_STRING value
= {5, (BYTE
*)"value"};
850 static const WS_XML_STRING value2
= {6, (BYTE
*)"value2"};
853 WS_ELEMENT_DESCRIPTION desc
;
855 hr
= WsRemoveCustomHeader( NULL
, NULL
, NULL
, NULL
);
856 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
858 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_2
, WS_ADDRESSING_VERSION_1_0
, NULL
, 0, &msg
, NULL
);
859 ok( hr
== S_OK
, "got %08x\n", hr
);
861 hr
= WsRemoveCustomHeader( msg
, &localname
, &ns
, NULL
);
862 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
864 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
865 ok( hr
== S_OK
, "got %08x\n", hr
);
866 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
868 desc
.elementLocalName
= &localname
;
869 desc
.elementNs
= &ns
;
870 desc
.type
= WS_XML_STRING_TYPE
;
871 desc
.typeDescription
= NULL
;
872 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &value
, sizeof(value
), 0, NULL
);
873 ok( hr
== S_OK
, "got %08x\n", hr
);
874 check_output_header( msg
, expected
, -1, strstr(expected
, "urn:uuid:") - expected
, 46, __LINE__
);
876 hr
= WsAddCustomHeader( msg
, &desc
, WS_WRITE_REQUIRED_VALUE
, &value2
, sizeof(value2
), 0, NULL
);
877 ok( hr
== S_OK
, "got %08x\n", hr
);
878 check_output_header( msg
, expected3
, -1, strstr(expected3
, "urn:uuid:") - expected3
, 46, __LINE__
);
880 hr
= WsRemoveCustomHeader( msg
, NULL
, NULL
, NULL
);
881 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
883 hr
= WsRemoveCustomHeader( msg
, &localname
, NULL
, NULL
);
884 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
886 hr
= WsRemoveCustomHeader( msg
, &localname
, &ns
, NULL
);
887 ok( hr
== S_OK
, "got %08x\n", hr
);
888 check_output_header( msg
, expected2
, -1, strstr(expected2
, "urn:uuid:") - expected2
, 46, __LINE__
);
891 hr
= WsRemoveCustomHeader( msg
, &localname
, &ns
, NULL
);
892 ok( hr
== S_OK
, "got %08x\n", hr
);
894 WsFreeMessage( msg
);
897 static HRESULT
set_input( WS_XML_READER
*reader
, const char *data
, ULONG size
)
899 WS_XML_READER_TEXT_ENCODING text
= {{WS_XML_READER_ENCODING_TYPE_TEXT
}, WS_CHARSET_AUTO
};
900 WS_XML_READER_BUFFER_INPUT buf
;
902 buf
.input
.inputType
= WS_XML_READER_INPUT_TYPE_BUFFER
;
903 buf
.encodedData
= (void *)data
;
904 buf
.encodedDataSize
= size
;
905 return WsSetInput( reader
, &text
.encoding
, &buf
.input
, NULL
, 0, NULL
);
908 static void test_WsReadEnvelopeStart(void)
910 static const char xml
[] =
911 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body/></s:Envelope>";
912 WS_MESSAGE
*msg
, *msg2
;
913 WS_XML_READER
*reader
;
914 WS_MESSAGE_STATE state
;
917 hr
= WsReadEnvelopeStart( NULL
, NULL
, NULL
, NULL
, NULL
);
918 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
920 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
921 ok( hr
== S_OK
, "got %08x\n", hr
);
923 hr
= WsReadEnvelopeStart( msg
, NULL
, NULL
, NULL
, NULL
);
924 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
926 hr
= WsCreateReader( NULL
, 0, &reader
, NULL
);
927 ok( hr
== S_OK
, "got %08x\n", hr
);
929 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
930 ok( hr
== S_OK
, "got %08x\n", hr
);
932 hr
= WsReadEnvelopeStart( msg
, reader
, NULL
, NULL
, NULL
);
933 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
935 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg2
, NULL
);
936 ok( hr
== S_OK
, "got %08x\n", hr
);
938 hr
= set_input( reader
, xml
, strlen(xml
) );
939 ok( hr
== S_OK
, "got %08x\n", hr
);
941 hr
= WsReadEnvelopeStart( msg2
, reader
, NULL
, NULL
, NULL
);
942 ok( hr
== S_OK
, "got %08x\n", hr
);
945 hr
= WsGetMessageProperty( msg2
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
946 ok( hr
== S_OK
, "got %08x\n", hr
);
947 ok( state
== WS_MESSAGE_STATE_READING
, "got %u\n", state
);
949 WsFreeMessage( msg
);
950 WsFreeMessage( msg2
);
951 WsFreeReader( reader
);
954 static void test_WsReadEnvelopeEnd(void)
956 static const char xml
[] =
957 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body></s:Body></s:Envelope>";
958 WS_MESSAGE
*msg
, *msg2
;
959 WS_XML_READER
*reader
;
960 WS_MESSAGE_STATE state
;
963 hr
= WsReadEnvelopeEnd( NULL
, NULL
);
964 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
966 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
967 ok( hr
== S_OK
, "got %08x\n", hr
);
969 hr
= WsCreateReader( NULL
, 0, &reader
, NULL
);
970 ok( hr
== S_OK
, "got %08x\n", hr
);
972 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
973 ok( hr
== S_OK
, "got %08x\n", hr
);
975 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg2
, NULL
);
976 ok( hr
== S_OK
, "got %08x\n", hr
);
978 hr
= set_input( reader
, xml
, strlen(xml
) );
979 ok( hr
== S_OK
, "got %08x\n", hr
);
981 hr
= WsReadEnvelopeEnd( msg2
, NULL
);
982 ok( hr
== WS_E_INVALID_OPERATION
, "got %08x\n", hr
);
984 hr
= WsReadEnvelopeStart( msg2
, reader
, NULL
, NULL
, NULL
);
985 ok( hr
== S_OK
, "got %08x\n", hr
);
987 hr
= WsReadEnvelopeEnd( msg2
, NULL
);
988 ok( hr
== S_OK
, "got %08x\n", hr
);
991 hr
= WsGetMessageProperty( msg2
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
992 ok( hr
== S_OK
, "got %08x\n", hr
);
993 ok( state
== WS_MESSAGE_STATE_DONE
, "got %u\n", state
);
995 WsFreeMessage( msg
);
996 WsFreeMessage( msg2
);
997 WsFreeReader( reader
);
1000 static void test_WsReadBody(void)
1002 static const char xml
[] =
1003 "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>"
1004 "<u xmlns=\"ns\"><val>1</val></u></s:Body></s:Envelope>";
1006 WS_MESSAGE
*msg
, *msg2
;
1007 WS_XML_READER
*reader
;
1008 WS_MESSAGE_STATE state
;
1009 WS_XML_STRING localname
= {1, (BYTE
*)"t"}, localname2
= {1, (BYTE
*)"u"};
1010 WS_XML_STRING val
= {3, (BYTE
*)"val"}, ns
= {2, (BYTE
*)"ns"};
1011 WS_ELEMENT_DESCRIPTION desc
;
1012 WS_STRUCT_DESCRIPTION s
;
1013 WS_FIELD_DESCRIPTION f
, *fields
[1];
1020 hr
= WsCreateHeap( 1 << 16, 0, NULL
, 0, &heap
, NULL
);
1021 ok( hr
== S_OK
, "got %08x\n", hr
);
1023 hr
= WsReadBody( NULL
, NULL
, 0, NULL
, NULL
, 0, NULL
);
1024 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1026 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg
, NULL
);
1027 ok( hr
== S_OK
, "got %08x\n", hr
);
1029 hr
= WsCreateReader( NULL
, 0, &reader
, NULL
);
1030 ok( hr
== S_OK
, "got %08x\n", hr
);
1032 hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
1033 ok( hr
== S_OK
, "got %08x\n", hr
);
1035 hr
= WsCreateMessage( WS_ENVELOPE_VERSION_SOAP_1_1
, WS_ADDRESSING_VERSION_0_9
, NULL
, 0, &msg2
, NULL
);
1036 ok( hr
== S_OK
, "got %08x\n", hr
);
1038 hr
= WsReadBody( msg2
, NULL
, 0, NULL
, NULL
, 0, NULL
);
1039 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1041 hr
= set_input( reader
, xml
, strlen(xml
) );
1042 ok( hr
== S_OK
, "got %08x\n", hr
);
1044 hr
= WsReadEnvelopeStart( msg2
, reader
, NULL
, NULL
, NULL
);
1045 ok( hr
== S_OK
, "got %08x\n", hr
);
1047 hr
= WsReadBody( msg2
, NULL
, WS_READ_REQUIRED_VALUE
, heap
, &test
, sizeof(test
), NULL
);
1048 ok( hr
== E_INVALIDARG
, "got %08x\n", hr
);
1050 memset( &f
, 0, sizeof(f
) );
1051 f
.mapping
= WS_ELEMENT_FIELD_MAPPING
;
1054 f
.type
= WS_UINT32_TYPE
;
1057 memset( &s
, 0, sizeof(s
) );
1058 s
.size
= sizeof(struct test
);
1059 s
.alignment
= TYPE_ALIGNMENT(struct test
);
1062 s
.typeLocalName
= &localname
;
1065 desc
.elementLocalName
= &localname2
;
1066 desc
.elementNs
= &ns
;
1067 desc
.type
= WS_STRUCT_TYPE
;
1068 desc
.typeDescription
= &s
;
1070 memset( &test
, 0, sizeof(test
) );
1071 hr
= WsReadBody( msg2
, &desc
, WS_READ_REQUIRED_VALUE
, heap
, &test
, sizeof(test
), NULL
);
1072 ok( hr
== S_OK
, "got %08x\n", hr
);
1073 ok( test
.val
== 1, "got %u\n", test
.val
);
1076 hr
= WsGetMessageProperty( msg2
, WS_MESSAGE_PROPERTY_STATE
, &state
, sizeof(state
), NULL
);
1077 ok( hr
== S_OK
, "got %08x\n", hr
);
1078 ok( state
== WS_MESSAGE_STATE_READING
, "got %u\n", state
);
1080 hr
= WsReadEnvelopeEnd( msg2
, NULL
);
1081 ok( hr
== S_OK
, "got %08x\n", hr
);
1083 WsFreeMessage( msg
);
1084 WsFreeMessage( msg2
);
1085 WsFreeReader( reader
);
1091 test_WsCreateMessage();
1092 test_WsCreateMessageForChannel();
1093 test_WsInitializeMessage();
1094 test_WsAddressMessage();
1095 test_WsWriteEnvelopeStart();
1096 test_WsWriteEnvelopeEnd();
1099 test_WsRemoveHeader();
1100 test_WsAddMappedHeader();
1101 test_WsRemoveMappedHeader();
1102 test_WsAddCustomHeader();
1103 test_WsRemoveCustomHeader();
1104 test_WsReadEnvelopeStart();
1105 test_WsReadEnvelopeEnd();