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
25 #include "webservices.h"
27 #include "wine/debug.h"
28 #include "wine/heap.h"
29 #include "wine/list.h"
30 #include "webservices_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(webservices
);
35 static const struct prop_desc channel_props
[] =
37 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE */
38 { sizeof(UINT64
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_STREAMED_MESSAGE_SIZE */
39 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_STREAMED_START_SIZE */
40 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_STREAMED_FLUSH_SIZE */
41 { sizeof(WS_ENCODING
), TRUE
}, /* WS_CHANNEL_PROPERTY_ENCODING */
42 { sizeof(WS_ENVELOPE_VERSION
), FALSE
}, /* WS_CHANNEL_PROPERTY_ENVELOPE_VERSION */
43 { sizeof(WS_ADDRESSING_VERSION
), FALSE
}, /* WS_CHANNEL_PROPERTY_ADDRESSING_VERSION */
44 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_SESSION_DICTIONARY_SIZE */
45 { sizeof(WS_CHANNEL_STATE
), TRUE
}, /* WS_CHANNEL_PROPERTY_STATE */
46 { sizeof(WS_CALLBACK_MODEL
), FALSE
}, /* WS_CHANNEL_PROPERTY_ASYNC_CALLBACK_MODEL */
47 { sizeof(WS_IP_VERSION
), FALSE
}, /* WS_CHANNEL_PROPERTY_IP_VERSION */
48 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT */
49 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_CONNECT_TIMEOUT */
50 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_SEND_TIMEOUT */
51 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_RECEIVE_RESPONSE_TIMEOUT */
52 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_RECEIVE_TIMEOUT */
53 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_CLOSE_TIMEOUT */
54 { sizeof(BOOL
), FALSE
}, /* WS_CHANNEL_PROPERTY_ENABLE_TIMEOUTS */
55 { sizeof(WS_TRANSFER_MODE
), FALSE
}, /* WS_CHANNEL_PROPERTY_TRANSFER_MODE */
56 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MULTICAST_INTERFACE */
57 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MULTICAST_HOPS */
58 { sizeof(WS_ENDPOINT_ADDRESS
), TRUE
}, /* WS_CHANNEL_PROPERTY_REMOTE_ADDRESS */
59 { sizeof(SOCKADDR_STORAGE
), TRUE
}, /* WS_CHANNEL_PROPERTY_REMOTE_IP_ADDRESS */
60 { sizeof(ULONGLONG
), TRUE
}, /* WS_CHANNEL_PROPERTY_HTTP_CONNECTION_ID */
61 { sizeof(WS_CUSTOM_CHANNEL_CALLBACKS
), FALSE
}, /* WS_CHANNEL_PROPERTY_CUSTOM_CHANNEL_CALLBACKS */
62 { 0, FALSE
}, /* WS_CHANNEL_PROPERTY_CUSTOM_CHANNEL_PARAMETERS */
63 { sizeof(void *), FALSE
}, /* WS_CHANNEL_PROPERTY_CUSTOM_CHANNEL_INSTANCE */
64 { sizeof(WS_STRING
), TRUE
}, /* WS_CHANNEL_PROPERTY_TRANSPORT_URL */
65 { sizeof(BOOL
), FALSE
}, /* WS_CHANNEL_PROPERTY_NO_DELAY */
66 { sizeof(BOOL
), FALSE
}, /* WS_CHANNEL_PROPERTY_SEND_KEEP_ALIVES */
67 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_KEEP_ALIVE_TIME */
68 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_KEEP_ALIVE_INTERVAL */
69 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_HTTP_SERVER_CONNECTIONS */
70 { sizeof(BOOL
), TRUE
}, /* WS_CHANNEL_PROPERTY_IS_SESSION_SHUT_DOWN */
71 { sizeof(WS_CHANNEL_TYPE
), TRUE
}, /* WS_CHANNEL_PROPERTY_CHANNEL_TYPE */
72 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_TRIM_BUFFERED_MESSAGE_SIZE */
73 { sizeof(WS_CHANNEL_ENCODER
), FALSE
}, /* WS_CHANNEL_PROPERTY_ENCODER */
74 { sizeof(WS_CHANNEL_DECODER
), FALSE
}, /* WS_CHANNEL_PROPERTY_DECODER */
75 { sizeof(WS_PROTECTION_LEVEL
), TRUE
}, /* WS_CHANNEL_PROPERTY_PROTECTION_LEVEL */
76 { sizeof(WS_COOKIE_MODE
), FALSE
}, /* WS_CHANNEL_PROPERTY_COOKIE_MODE */
77 { sizeof(WS_HTTP_PROXY_SETTING_MODE
), FALSE
}, /* WS_CHANNEL_PROPERTY_HTTP_PROXY_SETTING_MODE */
78 { sizeof(WS_CUSTOM_HTTP_PROXY
), FALSE
}, /* WS_CHANNEL_PROPERTY_CUSTOM_HTTP_PROXY */
79 { sizeof(WS_HTTP_MESSAGE_MAPPING
), FALSE
}, /* WS_CHANNEL_PROPERTY_HTTP_MESSAGE_MAPPING */
80 { sizeof(BOOL
), FALSE
}, /* WS_CHANNEL_PROPERTY_ENABLE_HTTP_REDIRECT */
81 { sizeof(WS_HTTP_REDIRECT_CALLBACK_CONTEXT
), FALSE
}, /* WS_CHANNEL_PROPERTY_HTTP_REDIRECT_CALLBACK_CONTEXT */
82 { sizeof(BOOL
), FALSE
}, /* WS_CHANNEL_PROPERTY_FAULTS_AS_ERRORS */
83 { sizeof(BOOL
), FALSE
}, /* WS_CHANNEL_PROPERTY_ALLOW_UNSECURED_FAULTS */
84 { sizeof(WCHAR
*), TRUE
}, /* WS_CHANNEL_PROPERTY_HTTP_SERVER_SPN */
85 { sizeof(WCHAR
*), TRUE
}, /* WS_CHANNEL_PROPERTY_HTTP_PROXY_SPN */
86 { sizeof(ULONG
), FALSE
} /* WS_CHANNEL_PROPERTY_MAX_HTTP_REQUEST_HEADERS_BUFFER_SIZE */
92 void (*proc
)( struct task
* );
104 static struct task
*dequeue_task( struct queue
*queue
)
108 EnterCriticalSection( &queue
->cs
);
109 TRACE( "%u tasks queued\n", list_count( &queue
->tasks
) );
110 task
= LIST_ENTRY( list_head( &queue
->tasks
), struct task
, entry
);
111 if (task
) list_remove( &task
->entry
);
112 LeaveCriticalSection( &queue
->cs
);
114 TRACE( "returning task %p\n", task
);
118 static void CALLBACK
queue_runner( TP_CALLBACK_INSTANCE
*instance
, void *ctx
)
120 struct queue
*queue
= ctx
;
121 HANDLE handles
[] = { queue
->wait
, queue
->cancel
};
123 SetEvent( queue
->ready
);
126 DWORD err
= WaitForMultipleObjects( 2, handles
, FALSE
, INFINITE
);
132 while ((task
= dequeue_task( queue
)))
139 case WAIT_OBJECT_0
+ 1:
140 TRACE( "cancelled\n" );
141 SetEvent( queue
->ready
);
145 ERR( "wait failed %u\n", err
);
151 static HRESULT
start_queue( struct queue
*queue
)
153 HRESULT hr
= E_OUTOFMEMORY
;
155 if (queue
->wait
) return S_OK
;
156 list_init( &queue
->tasks
);
157 if (!(queue
->wait
= CreateEventW( NULL
, FALSE
, FALSE
, NULL
))) goto error
;
158 if (!(queue
->cancel
= CreateEventW( NULL
, FALSE
, FALSE
, NULL
))) goto error
;
159 if (!(queue
->ready
= CreateEventW( NULL
, FALSE
, FALSE
, NULL
))) goto error
;
160 if (!TrySubmitThreadpoolCallback( queue_runner
, queue
, NULL
)) hr
= HRESULT_FROM_WIN32( GetLastError() );
163 WaitForSingleObject( queue
->ready
, INFINITE
);
168 CloseHandle( queue
->wait
);
170 CloseHandle( queue
->cancel
);
171 queue
->cancel
= NULL
;
172 CloseHandle( queue
->ready
);
177 static HRESULT
queue_task( struct queue
*queue
, struct task
*task
)
180 if ((hr
= start_queue( queue
)) != S_OK
) return hr
;
182 EnterCriticalSection( &queue
->cs
);
183 TRACE( "queueing task %p\n", task
);
184 list_add_tail( &queue
->tasks
, &task
->entry
);
185 LeaveCriticalSection( &queue
->cs
);
187 SetEvent( queue
->wait
);
193 SESSION_STATE_UNINITIALIZED
,
194 SESSION_STATE_SETUP_COMPLETE
,
195 SESSION_STATE_SHUTDOWN
,
202 WS_CHANNEL_TYPE type
;
203 WS_CHANNEL_BINDING binding
;
204 WS_CHANNEL_STATE state
;
205 WS_ENDPOINT_ADDRESS addr
;
206 WS_XML_WRITER
*writer
;
207 WS_XML_READER
*reader
;
209 WS_ENCODING encoding
;
210 enum session_state session_state
;
211 struct dictionary dict_send
;
212 struct dictionary dict_recv
;
238 struct prop prop
[ARRAY_SIZE( channel_props
)];
241 #define CHANNEL_MAGIC (('C' << 24) | ('H' << 16) | ('A' << 8) | 'N')
243 static struct channel
*alloc_channel(void)
245 static const ULONG count
= ARRAY_SIZE( channel_props
);
247 ULONG size
= sizeof(*ret
) + prop_size( channel_props
, count
);
249 if (!(ret
= heap_alloc_zero( size
))) return NULL
;
251 ret
->magic
= CHANNEL_MAGIC
;
252 InitializeCriticalSection( &ret
->cs
);
253 InitializeCriticalSection( &ret
->send_q
.cs
);
254 InitializeCriticalSection( &ret
->recv_q
.cs
);
255 ret
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": channel.cs");
256 ret
->send_q
.cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": channel.send_q.cs");
257 ret
->recv_q
.cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": channel.recv_q.cs");
259 prop_init( channel_props
, count
, ret
->prop
, &ret
[1] );
260 ret
->prop_count
= count
;
264 static void clear_addr( WS_ENDPOINT_ADDRESS
*addr
)
266 heap_free( addr
->url
.chars
);
267 addr
->url
.chars
= NULL
;
268 addr
->url
.length
= 0;
271 static void clear_queue( struct queue
*queue
)
275 SetEvent( queue
->cancel
);
276 WaitForSingleObject( queue
->ready
, INFINITE
);
278 while ((ptr
= list_head( &queue
->tasks
)))
280 struct task
*task
= LIST_ENTRY( ptr
, struct task
, entry
);
281 list_remove( &task
->entry
);
285 CloseHandle( queue
->wait
);
287 CloseHandle( queue
->cancel
);
288 queue
->cancel
= NULL
;
289 CloseHandle( queue
->ready
);
293 static void reset_channel( struct channel
*channel
)
295 clear_queue( &channel
->send_q
);
296 clear_queue( &channel
->recv_q
);
297 channel
->state
= WS_CHANNEL_STATE_CREATED
;
298 channel
->session_state
= SESSION_STATE_UNINITIALIZED
;
299 clear_addr( &channel
->addr
);
300 clear_dict( &channel
->dict_send
);
301 clear_dict( &channel
->dict_recv
);
303 channel
->read_size
= 0;
305 switch (channel
->binding
)
307 case WS_HTTP_CHANNEL_BINDING
:
308 WinHttpCloseHandle( channel
->u
.http
.request
);
309 channel
->u
.http
.request
= NULL
;
310 WinHttpCloseHandle( channel
->u
.http
.connect
);
311 channel
->u
.http
.connect
= NULL
;
312 WinHttpCloseHandle( channel
->u
.http
.session
);
313 channel
->u
.http
.session
= NULL
;
314 heap_free( channel
->u
.http
.path
);
315 channel
->u
.http
.path
= NULL
;
316 channel
->u
.http
.flags
= 0;
319 case WS_TCP_CHANNEL_BINDING
:
320 closesocket( channel
->u
.tcp
.socket
);
321 channel
->u
.tcp
.socket
= -1;
324 case WS_UDP_CHANNEL_BINDING
:
325 closesocket( channel
->u
.udp
.socket
);
326 channel
->u
.udp
.socket
= -1;
333 static void free_header_mappings( WS_HTTP_HEADER_MAPPING
**mappings
, ULONG count
)
336 for (i
= 0; i
< count
; i
++) heap_free( mappings
[i
] );
337 heap_free( mappings
);
340 static void free_message_mapping( const WS_HTTP_MESSAGE_MAPPING
*mapping
)
342 free_header_mappings( mapping
->requestHeaderMappings
, mapping
->requestHeaderMappingCount
);
343 free_header_mappings( mapping
->responseHeaderMappings
, mapping
->responseHeaderMappingCount
);
346 static void free_props( struct channel
*channel
)
348 struct prop
*prop
= &channel
->prop
[WS_CHANNEL_PROPERTY_HTTP_MESSAGE_MAPPING
];
349 WS_HTTP_MESSAGE_MAPPING
*mapping
= (WS_HTTP_MESSAGE_MAPPING
*)prop
->value
;
350 free_message_mapping( mapping
);
353 static void free_channel( struct channel
*channel
)
355 reset_channel( channel
);
357 WsFreeWriter( channel
->writer
);
358 WsFreeReader( channel
->reader
);
360 heap_free( channel
->read_buf
);
361 free_props( channel
);
363 channel
->send_q
.cs
.DebugInfo
->Spare
[0] = 0;
364 channel
->recv_q
.cs
.DebugInfo
->Spare
[0] = 0;
365 channel
->cs
.DebugInfo
->Spare
[0] = 0;
366 DeleteCriticalSection( &channel
->send_q
.cs
);
367 DeleteCriticalSection( &channel
->recv_q
.cs
);
368 DeleteCriticalSection( &channel
->cs
);
369 heap_free( channel
);
372 static WS_HTTP_HEADER_MAPPING
*dup_header_mapping( const WS_HTTP_HEADER_MAPPING
*src
)
374 WS_HTTP_HEADER_MAPPING
*dst
;
376 if (!(dst
= heap_alloc( sizeof(*dst
) + src
->headerName
.length
))) return NULL
;
378 dst
->headerName
.bytes
= (BYTE
*)(dst
+ 1);
379 memcpy( dst
->headerName
.bytes
, src
->headerName
.bytes
, src
->headerName
.length
);
380 dst
->headerName
.length
= src
->headerName
.length
;
381 dst
->headerMappingOptions
= src
->headerMappingOptions
;
385 static HRESULT
dup_message_mapping( const WS_HTTP_MESSAGE_MAPPING
*src
, WS_HTTP_MESSAGE_MAPPING
*dst
)
389 size
= src
->requestHeaderMappingCount
* sizeof(*dst
->responseHeaderMappings
);
390 if (!(dst
->requestHeaderMappings
= heap_alloc( size
))) return E_OUTOFMEMORY
;
392 for (i
= 0; i
< src
->requestHeaderMappingCount
; i
++)
394 if (!(dst
->requestHeaderMappings
[i
] = dup_header_mapping( src
->requestHeaderMappings
[i
] )))
396 free_header_mappings( dst
->requestHeaderMappings
, i
);
397 return E_OUTOFMEMORY
;
401 size
= src
->responseHeaderMappingCount
* sizeof(*dst
->responseHeaderMappings
);
402 if (!(dst
->responseHeaderMappings
= heap_alloc( size
)))
404 heap_free( dst
->responseHeaderMappings
);
405 return E_OUTOFMEMORY
;
408 for (i
= 0; i
< src
->responseHeaderMappingCount
; i
++)
410 if (!(dst
->responseHeaderMappings
[i
] = dup_header_mapping( src
->responseHeaderMappings
[i
] )))
412 free_header_mappings( dst
->responseHeaderMappings
, i
);
413 return E_OUTOFMEMORY
;
417 dst
->requestMappingOptions
= src
->requestMappingOptions
;
418 dst
->responseMappingOptions
= src
->responseMappingOptions
;
419 dst
->requestHeaderMappingCount
= src
->requestHeaderMappingCount
;
420 dst
->responseHeaderMappingCount
= src
->responseHeaderMappingCount
;
424 static HRESULT
create_channel( WS_CHANNEL_TYPE type
, WS_CHANNEL_BINDING binding
,
425 const WS_CHANNEL_PROPERTY
*properties
, ULONG count
, struct channel
**ret
)
427 struct channel
*channel
;
428 ULONG i
, msg_size
= 65536;
429 WS_ENVELOPE_VERSION env_version
= WS_ENVELOPE_VERSION_SOAP_1_2
;
430 WS_ADDRESSING_VERSION addr_version
= WS_ADDRESSING_VERSION_1_0
;
433 if (!(channel
= alloc_channel())) return E_OUTOFMEMORY
;
435 prop_set( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE
,
436 &msg_size
, sizeof(msg_size
) );
437 prop_set( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_ENVELOPE_VERSION
,
438 &env_version
, sizeof(env_version
) );
439 prop_set( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_ADDRESSING_VERSION
,
440 &addr_version
, sizeof(addr_version
) );
442 channel
->type
= type
;
443 channel
->binding
= binding
;
445 switch (channel
->binding
)
447 case WS_HTTP_CHANNEL_BINDING
:
448 channel
->encoding
= WS_ENCODING_XML_UTF8
;
451 case WS_TCP_CHANNEL_BINDING
:
452 channel
->u
.tcp
.socket
= -1;
453 channel
->encoding
= WS_ENCODING_XML_BINARY_SESSION_1
;
456 case WS_UDP_CHANNEL_BINDING
:
457 channel
->u
.udp
.socket
= -1;
458 channel
->encoding
= WS_ENCODING_XML_UTF8
;
464 for (i
= 0; i
< count
; i
++)
466 const WS_CHANNEL_PROPERTY
*prop
= &properties
[i
];
468 TRACE( "property id %u value %p size %u\n", prop
->id
, prop
->value
, prop
->valueSize
);
469 if (prop
->valueSize
== sizeof(ULONG
) && prop
->value
) TRACE( " value %08x\n", *(ULONG
*)prop
->value
);
473 case WS_CHANNEL_PROPERTY_ENCODING
:
474 if (!prop
->value
|| prop
->valueSize
!= sizeof(channel
->encoding
))
476 free_channel( channel
);
479 channel
->encoding
= *(WS_ENCODING
*)prop
->value
;
482 case WS_CHANNEL_PROPERTY_HTTP_MESSAGE_MAPPING
:
484 const WS_HTTP_MESSAGE_MAPPING
*src
= (WS_HTTP_MESSAGE_MAPPING
*)prop
->value
;
485 WS_HTTP_MESSAGE_MAPPING dst
;
487 if (!prop
->value
|| prop
->valueSize
!= sizeof(*src
))
489 free_channel( channel
);
493 if ((hr
= dup_message_mapping( src
, &dst
)) != S_OK
) return hr
;
495 if ((hr
= prop_set( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_HTTP_MESSAGE_MAPPING
, &dst
,
496 sizeof(dst
) )) != S_OK
)
498 free_message_mapping( &dst
);
499 free_channel( channel
);
506 if ((hr
= prop_set( channel
->prop
, channel
->prop_count
, prop
->id
, prop
->value
, prop
->valueSize
)) != S_OK
)
508 free_channel( channel
);
519 /**************************************************************************
520 * WsCreateChannel [webservices.@]
522 HRESULT WINAPI
WsCreateChannel( WS_CHANNEL_TYPE type
, WS_CHANNEL_BINDING binding
,
523 const WS_CHANNEL_PROPERTY
*properties
, ULONG count
,
524 const WS_SECURITY_DESCRIPTION
*desc
, WS_CHANNEL
**handle
,
527 struct channel
*channel
;
530 TRACE( "%u %u %p %u %p %p %p\n", type
, binding
, properties
, count
, desc
, handle
, error
);
531 if (error
) FIXME( "ignoring error parameter\n" );
532 if (desc
) FIXME( "ignoring security description\n" );
534 if (!handle
) return E_INVALIDARG
;
536 if (type
!= WS_CHANNEL_TYPE_REQUEST
&& type
!= WS_CHANNEL_TYPE_DUPLEX
&&
537 type
!= WS_CHANNEL_TYPE_DUPLEX_SESSION
)
539 FIXME( "channel type %u not implemented\n", type
);
542 if (binding
!= WS_HTTP_CHANNEL_BINDING
&& binding
!= WS_TCP_CHANNEL_BINDING
&&
543 binding
!= WS_UDP_CHANNEL_BINDING
)
545 FIXME( "channel binding %u not implemented\n", binding
);
549 if ((hr
= create_channel( type
, binding
, properties
, count
, &channel
)) != S_OK
) return hr
;
551 TRACE( "created %p\n", channel
);
552 *handle
= (WS_CHANNEL
*)channel
;
556 /**************************************************************************
557 * WsCreateChannelForListener [webservices.@]
559 HRESULT WINAPI
WsCreateChannelForListener( WS_LISTENER
*listener_handle
, const WS_CHANNEL_PROPERTY
*properties
,
560 ULONG count
, WS_CHANNEL
**handle
, WS_ERROR
*error
)
562 struct channel
*channel
;
563 WS_CHANNEL_TYPE type
;
564 WS_CHANNEL_BINDING binding
;
567 TRACE( "%p %p %u %p %p\n", listener_handle
, properties
, count
, handle
, error
);
568 if (error
) FIXME( "ignoring error parameter\n" );
570 if (!listener_handle
|| !handle
) return E_INVALIDARG
;
572 if ((hr
= WsGetListenerProperty( listener_handle
, WS_LISTENER_PROPERTY_CHANNEL_TYPE
, &type
,
573 sizeof(type
), NULL
)) != S_OK
) return hr
;
575 if ((hr
= WsGetListenerProperty( listener_handle
, WS_LISTENER_PROPERTY_CHANNEL_BINDING
, &binding
,
576 sizeof(binding
), NULL
)) != S_OK
) return hr
;
578 if ((hr
= create_channel( type
, binding
, properties
, count
, &channel
)) != S_OK
) return hr
;
580 TRACE( "created %p\n", channel
);
581 *handle
= (WS_CHANNEL
*)channel
;
585 /**************************************************************************
586 * WsFreeChannel [webservices.@]
588 void WINAPI
WsFreeChannel( WS_CHANNEL
*handle
)
590 struct channel
*channel
= (struct channel
*)handle
;
592 TRACE( "%p\n", handle
);
594 if (!channel
) return;
596 EnterCriticalSection( &channel
->cs
);
598 if (channel
->magic
!= CHANNEL_MAGIC
)
600 LeaveCriticalSection( &channel
->cs
);
606 LeaveCriticalSection( &channel
->cs
);
607 free_channel( channel
);
610 /**************************************************************************
611 * WsResetChannel [webservices.@]
613 HRESULT WINAPI
WsResetChannel( WS_CHANNEL
*handle
, WS_ERROR
*error
)
615 struct channel
*channel
= (struct channel
*)handle
;
618 TRACE( "%p %p\n", handle
, error
);
619 if (error
) FIXME( "ignoring error parameter\n" );
621 if (!channel
) return E_INVALIDARG
;
623 EnterCriticalSection( &channel
->cs
);
625 if (channel
->magic
!= CHANNEL_MAGIC
)
627 LeaveCriticalSection( &channel
->cs
);
631 if (channel
->state
!= WS_CHANNEL_STATE_CREATED
&& channel
->state
!= WS_CHANNEL_STATE_CLOSED
)
632 hr
= WS_E_INVALID_OPERATION
;
634 reset_channel( channel
);
636 LeaveCriticalSection( &channel
->cs
);
637 TRACE( "returning %08x\n", hr
);
641 /**************************************************************************
642 * WsGetChannelProperty [webservices.@]
644 HRESULT WINAPI
WsGetChannelProperty( WS_CHANNEL
*handle
, WS_CHANNEL_PROPERTY_ID id
, void *buf
,
645 ULONG size
, WS_ERROR
*error
)
647 struct channel
*channel
= (struct channel
*)handle
;
650 TRACE( "%p %u %p %u %p\n", handle
, id
, buf
, size
, error
);
651 if (error
) FIXME( "ignoring error parameter\n" );
653 if (!channel
) return E_INVALIDARG
;
655 EnterCriticalSection( &channel
->cs
);
657 if (channel
->magic
!= CHANNEL_MAGIC
)
659 LeaveCriticalSection( &channel
->cs
);
665 case WS_CHANNEL_PROPERTY_CHANNEL_TYPE
:
666 if (!buf
|| size
!= sizeof(channel
->type
)) hr
= E_INVALIDARG
;
667 else *(WS_CHANNEL_TYPE
*)buf
= channel
->type
;
670 case WS_CHANNEL_PROPERTY_ENCODING
:
671 if (!buf
|| size
!= sizeof(channel
->encoding
)) hr
= E_INVALIDARG
;
672 else *(WS_ENCODING
*)buf
= channel
->encoding
;
676 hr
= prop_get( channel
->prop
, channel
->prop_count
, id
, buf
, size
);
679 LeaveCriticalSection( &channel
->cs
);
680 TRACE( "returning %08x\n", hr
);
684 /**************************************************************************
685 * WsSetChannelProperty [webservices.@]
687 HRESULT WINAPI
WsSetChannelProperty( WS_CHANNEL
*handle
, WS_CHANNEL_PROPERTY_ID id
, const void *value
,
688 ULONG size
, WS_ERROR
*error
)
690 struct channel
*channel
= (struct channel
*)handle
;
693 TRACE( "%p %u %p %u\n", handle
, id
, value
, size
);
694 if (error
) FIXME( "ignoring error parameter\n" );
696 if (!channel
) return E_INVALIDARG
;
698 EnterCriticalSection( &channel
->cs
);
700 if (channel
->magic
!= CHANNEL_MAGIC
)
702 LeaveCriticalSection( &channel
->cs
);
706 hr
= prop_set( channel
->prop
, channel
->prop_count
, id
, value
, size
);
708 LeaveCriticalSection( &channel
->cs
);
709 TRACE( "returning %08x\n", hr
);
713 static HRESULT
open_channel( struct channel
*channel
, const WS_ENDPOINT_ADDRESS
*endpoint
)
715 if (endpoint
->headers
|| endpoint
->extensions
|| endpoint
->identity
)
717 FIXME( "headers, extensions or identity not supported\n" );
721 TRACE( "endpoint %s\n", debugstr_wn(endpoint
->url
.chars
, endpoint
->url
.length
) );
723 if (!(channel
->addr
.url
.chars
= heap_alloc( endpoint
->url
.length
* sizeof(WCHAR
) ))) return E_OUTOFMEMORY
;
724 memcpy( channel
->addr
.url
.chars
, endpoint
->url
.chars
, endpoint
->url
.length
* sizeof(WCHAR
) );
725 channel
->addr
.url
.length
= endpoint
->url
.length
;
727 channel
->state
= WS_CHANNEL_STATE_OPEN
;
731 /**************************************************************************
732 * WsOpenChannel [webservices.@]
734 HRESULT WINAPI
WsOpenChannel( WS_CHANNEL
*handle
, const WS_ENDPOINT_ADDRESS
*endpoint
,
735 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
737 struct channel
*channel
= (struct channel
*)handle
;
740 TRACE( "%p %p %p %p\n", handle
, endpoint
, ctx
, error
);
741 if (error
) FIXME( "ignoring error parameter\n" );
742 if (ctx
) FIXME( "ignoring ctx parameter\n" );
744 if (!channel
|| !endpoint
) return E_INVALIDARG
;
746 EnterCriticalSection( &channel
->cs
);
748 if (channel
->magic
!= CHANNEL_MAGIC
)
750 LeaveCriticalSection( &channel
->cs
);
754 if (channel
->state
!= WS_CHANNEL_STATE_CREATED
) hr
= WS_E_INVALID_OPERATION
;
755 else hr
= open_channel( channel
, endpoint
);
757 LeaveCriticalSection( &channel
->cs
);
758 TRACE( "returning %08x\n", hr
);
762 enum frame_record_type
764 FRAME_RECORD_TYPE_VERSION
,
765 FRAME_RECORD_TYPE_MODE
,
766 FRAME_RECORD_TYPE_VIA
,
767 FRAME_RECORD_TYPE_KNOWN_ENCODING
,
768 FRAME_RECORD_TYPE_EXTENSIBLE_ENCODING
,
769 FRAME_RECORD_TYPE_UNSIZED_ENVELOPE
,
770 FRAME_RECORD_TYPE_SIZED_ENVELOPE
,
771 FRAME_RECORD_TYPE_END
,
772 FRAME_RECORD_TYPE_FAULT
,
773 FRAME_RECORD_TYPE_UPGRADE_REQUEST
,
774 FRAME_RECORD_TYPE_UPGRADE_RESPONSE
,
775 FRAME_RECORD_TYPE_PREAMBLE_ACK
,
776 FRAME_RECORD_TYPE_PREAMBLE_END
,
779 static HRESULT
send_byte( SOCKET socket
, BYTE byte
)
781 int count
= send( socket
, (char *)&byte
, 1, 0 );
782 if (count
< 0) return HRESULT_FROM_WIN32( WSAGetLastError() );
783 if (count
!= 1) return WS_E_OTHER
;
787 static HRESULT
shutdown_session( struct channel
*channel
)
791 if (channel
->state
!= WS_CHANNEL_STATE_OPEN
||
792 (channel
->type
!= WS_CHANNEL_TYPE_OUTPUT_SESSION
&&
793 channel
->type
!= WS_CHANNEL_TYPE_DUPLEX_SESSION
) ||
794 channel
->session_state
>= SESSION_STATE_SHUTDOWN
) return WS_E_INVALID_OPERATION
;
796 switch (channel
->binding
)
798 case WS_TCP_CHANNEL_BINDING
:
799 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_END
)) != S_OK
) return hr
;
800 channel
->session_state
= SESSION_STATE_SHUTDOWN
;
804 FIXME( "unhandled binding %u\n", channel
->binding
);
809 HRESULT WINAPI
WsShutdownSessionChannel( WS_CHANNEL
*handle
, const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
811 struct channel
*channel
= (struct channel
*)handle
;
814 TRACE( "%p %p %p\n", handle
, ctx
, error
);
815 if (error
) FIXME( "ignoring error parameter\n" );
816 if (ctx
) FIXME( "ignoring ctx parameter\n" );
818 if (!channel
) return E_INVALIDARG
;
820 EnterCriticalSection( &channel
->cs
);
822 if (channel
->magic
!= CHANNEL_MAGIC
)
824 LeaveCriticalSection( &channel
->cs
);
828 hr
= shutdown_session( channel
);
830 LeaveCriticalSection( &channel
->cs
);
831 TRACE( "returning %08x\n", hr
);
835 static void close_channel( struct channel
*channel
)
837 reset_channel( channel
);
838 channel
->state
= WS_CHANNEL_STATE_CLOSED
;
841 /**************************************************************************
842 * WsCloseChannel [webservices.@]
844 HRESULT WINAPI
WsCloseChannel( WS_CHANNEL
*handle
, const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
846 struct channel
*channel
= (struct channel
*)handle
;
849 TRACE( "%p %p %p\n", handle
, ctx
, error
);
850 if (error
) FIXME( "ignoring error parameter\n" );
851 if (ctx
) FIXME( "ignoring ctx parameter\n" );
853 if (!channel
) return E_INVALIDARG
;
855 EnterCriticalSection( &channel
->cs
);
857 if (channel
->magic
!= CHANNEL_MAGIC
)
859 LeaveCriticalSection( &channel
->cs
);
863 close_channel( channel
);
865 LeaveCriticalSection( &channel
->cs
);
866 TRACE( "returning %08x\n", hr
);
870 static HRESULT
parse_http_url( const WCHAR
*url
, ULONG len
, URL_COMPONENTS
*uc
)
872 HRESULT hr
= E_OUTOFMEMORY
;
876 memset( uc
, 0, sizeof(*uc
) );
877 uc
->dwStructSize
= sizeof(*uc
);
878 uc
->dwHostNameLength
= 128;
879 uc
->lpszHostName
= heap_alloc( uc
->dwHostNameLength
* sizeof(WCHAR
) );
880 uc
->dwUrlPathLength
= 128;
881 uc
->lpszUrlPath
= heap_alloc( uc
->dwUrlPathLength
* sizeof(WCHAR
) );
882 uc
->dwExtraInfoLength
= 128;
883 uc
->lpszExtraInfo
= heap_alloc( uc
->dwExtraInfoLength
* sizeof(WCHAR
) );
884 if (!uc
->lpszHostName
|| !uc
->lpszUrlPath
|| !uc
->lpszExtraInfo
) goto error
;
886 if (!WinHttpCrackUrl( url
, len
, ICU_DECODE
, uc
))
888 if ((err
= GetLastError()) != ERROR_INSUFFICIENT_BUFFER
)
890 hr
= HRESULT_FROM_WIN32( err
);
893 if (!(tmp
= heap_realloc( uc
->lpszHostName
, uc
->dwHostNameLength
* sizeof(WCHAR
) ))) goto error
;
894 uc
->lpszHostName
= tmp
;
895 if (!(tmp
= heap_realloc( uc
->lpszUrlPath
, uc
->dwUrlPathLength
* sizeof(WCHAR
) ))) goto error
;
896 uc
->lpszUrlPath
= tmp
;
897 if (!(tmp
= heap_realloc( uc
->lpszExtraInfo
, uc
->dwExtraInfoLength
* sizeof(WCHAR
) ))) goto error
;
898 uc
->lpszExtraInfo
= tmp
;
899 WinHttpCrackUrl( url
, len
, ICU_DECODE
, uc
);
905 heap_free( uc
->lpszHostName
);
906 heap_free( uc
->lpszUrlPath
);
907 heap_free( uc
->lpszExtraInfo
);
911 static HRESULT
connect_channel_http( struct channel
*channel
)
913 HINTERNET ses
= NULL
, con
= NULL
;
917 if (channel
->u
.http
.connect
) return S_OK
;
919 if ((hr
= parse_http_url( channel
->addr
.url
.chars
, channel
->addr
.url
.length
, &uc
)) != S_OK
) return hr
;
920 if (!(channel
->u
.http
.path
= heap_alloc( (uc
.dwUrlPathLength
+ uc
.dwExtraInfoLength
+ 1) * sizeof(WCHAR
) )))
927 lstrcpyW( channel
->u
.http
.path
, uc
.lpszUrlPath
);
928 if (uc
.dwExtraInfoLength
) lstrcatW( channel
->u
.http
.path
, uc
.lpszExtraInfo
);
931 channel
->u
.http
.flags
= WINHTTP_FLAG_REFRESH
;
934 case INTERNET_SCHEME_HTTP
: break;
935 case INTERNET_SCHEME_HTTPS
:
936 channel
->u
.http
.flags
|= WINHTTP_FLAG_SECURE
;
940 hr
= WS_E_INVALID_ENDPOINT_URL
;
944 if (!(ses
= WinHttpOpen( L
"MS-WebServices/1.0", 0, NULL
, NULL
, 0 )))
946 hr
= HRESULT_FROM_WIN32( GetLastError() );
949 if (!(con
= WinHttpConnect( ses
, uc
.lpszHostName
, uc
.nPort
, 0 )))
951 hr
= HRESULT_FROM_WIN32( GetLastError() );
955 channel
->u
.http
.session
= ses
;
956 channel
->u
.http
.connect
= con
;
961 WinHttpCloseHandle( con
);
962 WinHttpCloseHandle( ses
);
964 heap_free( uc
.lpszHostName
);
965 heap_free( uc
.lpszUrlPath
);
966 heap_free( uc
.lpszExtraInfo
);
970 static HRESULT
connect_channel_tcp( struct channel
*channel
)
972 struct sockaddr_storage storage
;
973 struct sockaddr
*addr
= (struct sockaddr
*)&storage
;
974 BOOL nodelay
= FALSE
;
976 WS_URL_SCHEME_TYPE scheme
;
981 if (channel
->u
.tcp
.socket
!= -1) return S_OK
;
983 if ((hr
= parse_url( &channel
->addr
.url
, &scheme
, &host
, &port
)) != S_OK
) return hr
;
984 if (scheme
!= WS_URL_NETTCP_SCHEME_TYPE
)
987 return WS_E_INVALID_ENDPOINT_URL
;
992 hr
= resolve_hostname( host
, port
, addr
, &addr_len
, 0 );
994 if (hr
!= S_OK
) return hr
;
996 if ((channel
->u
.tcp
.socket
= socket( addr
->sa_family
, SOCK_STREAM
, 0 )) == -1)
997 return HRESULT_FROM_WIN32( WSAGetLastError() );
999 if (connect( channel
->u
.tcp
.socket
, addr
, addr_len
) < 0)
1001 closesocket( channel
->u
.tcp
.socket
);
1002 channel
->u
.tcp
.socket
= -1;
1003 return HRESULT_FROM_WIN32( WSAGetLastError() );
1006 prop_get( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_NO_DELAY
, &nodelay
, sizeof(nodelay
) );
1007 setsockopt( channel
->u
.tcp
.socket
, IPPROTO_TCP
, TCP_NODELAY
, (const char *)&nodelay
, sizeof(nodelay
) );
1011 static HRESULT
connect_channel_udp( struct channel
*channel
)
1013 struct sockaddr_storage storage
;
1014 struct sockaddr
*addr
= (struct sockaddr
*)&storage
;
1016 WS_URL_SCHEME_TYPE scheme
;
1021 if (channel
->u
.udp
.socket
!= -1) return S_OK
;
1023 if ((hr
= parse_url( &channel
->addr
.url
, &scheme
, &host
, &port
)) != S_OK
) return hr
;
1024 if (scheme
!= WS_URL_SOAPUDP_SCHEME_TYPE
)
1027 return WS_E_INVALID_ENDPOINT_URL
;
1032 hr
= resolve_hostname( host
, port
, addr
, &addr_len
, 0 );
1034 if (hr
!= S_OK
) return hr
;
1036 if ((channel
->u
.udp
.socket
= socket( addr
->sa_family
, SOCK_DGRAM
, 0 )) == -1)
1037 return HRESULT_FROM_WIN32( WSAGetLastError() );
1039 if (connect( channel
->u
.udp
.socket
, addr
, addr_len
) < 0)
1041 closesocket( channel
->u
.udp
.socket
);
1042 channel
->u
.udp
.socket
= -1;
1043 return HRESULT_FROM_WIN32( WSAGetLastError() );
1049 static HRESULT
connect_channel( struct channel
*channel
)
1051 switch (channel
->binding
)
1053 case WS_HTTP_CHANNEL_BINDING
:
1054 return connect_channel_http( channel
);
1056 case WS_TCP_CHANNEL_BINDING
:
1057 return connect_channel_tcp( channel
);
1059 case WS_UDP_CHANNEL_BINDING
:
1060 return connect_channel_udp( channel
);
1063 ERR( "unhandled binding %u\n", channel
->binding
);
1068 static HRESULT
send_message_http( HINTERNET request
, BYTE
*data
, ULONG len
)
1070 if (!WinHttpSendRequest( request
, NULL
, 0, data
, len
, len
, 0 ))
1071 return HRESULT_FROM_WIN32( GetLastError() );
1073 if (!WinHttpReceiveResponse( request
, NULL
))
1074 return HRESULT_FROM_WIN32( GetLastError() );
1078 static HRESULT
send_bytes( SOCKET socket
, BYTE
*bytes
, int len
)
1080 int count
= send( socket
, (char *)bytes
, len
, 0 );
1081 if (count
< 0) return HRESULT_FROM_WIN32( WSAGetLastError() );
1082 if (count
!= len
) return WS_E_OTHER
;
1086 static HRESULT
send_size( SOCKET socket
, ULONG size
)
1089 if (size
< 0x80) return send_byte( socket
, size
);
1090 if ((hr
= send_byte( socket
, (size
& 0x7f) | 0x80 )) != S_OK
) return hr
;
1091 if ((size
>>= 7) < 0x80) return send_byte( socket
, size
);
1092 if ((hr
= send_byte( socket
, (size
& 0x7f) | 0x80 )) != S_OK
) return hr
;
1093 if ((size
>>= 7) < 0x80) return send_byte( socket
, size
);
1094 if ((hr
= send_byte( socket
, (size
& 0x7f) | 0x80 )) != S_OK
) return hr
;
1095 if ((size
>>= 7) < 0x80) return send_byte( socket
, size
);
1096 if ((hr
= send_byte( socket
, (size
& 0x7f) | 0x80 )) != S_OK
) return hr
;
1097 if ((size
>>= 7) < 0x08) return send_byte( socket
, size
);
1098 return E_INVALIDARG
;
1101 static inline ULONG
size_length( ULONG size
)
1103 if (size
< 0x80) return 1;
1104 if (size
< 0x4000) return 2;
1105 if (size
< 0x200000) return 3;
1106 if (size
< 0x10000000) return 4;
1110 static ULONG
string_table_size( const struct dictionary
*dict
)
1113 for (i
= 0; i
< dict
->dict
.stringCount
; i
++)
1115 if (dict
->sequence
[i
] == dict
->current_sequence
)
1116 size
+= size_length( dict
->dict
.strings
[i
].length
) + dict
->dict
.strings
[i
].length
;
1121 static HRESULT
send_string_table( SOCKET socket
, const struct dictionary
*dict
)
1125 for (i
= 0; i
< dict
->dict
.stringCount
; i
++)
1127 if (dict
->sequence
[i
] != dict
->current_sequence
) continue;
1128 if ((hr
= send_size( socket
, dict
->dict
.strings
[i
].length
)) != S_OK
) return hr
;
1129 if ((hr
= send_bytes( socket
, dict
->dict
.strings
[i
].bytes
, dict
->dict
.strings
[i
].length
)) != S_OK
) return hr
;
1134 static HRESULT
string_to_utf8( const WS_STRING
*str
, unsigned char **ret
, int *len
)
1136 *len
= WideCharToMultiByte( CP_UTF8
, 0, str
->chars
, str
->length
, NULL
, 0, NULL
, NULL
);
1137 if (!(*ret
= heap_alloc( *len
))) return E_OUTOFMEMORY
;
1138 WideCharToMultiByte( CP_UTF8
, 0, str
->chars
, str
->length
, (char *)*ret
, *len
, NULL
, NULL
);
1144 SESSION_MODE_INVALID
= 0,
1145 SESSION_MODE_SINGLETON
= 1,
1146 SESSION_MODE_DUPLEX
= 2,
1147 SESSION_MODE_SIMPLEX
= 3,
1150 static enum session_mode
map_channel_type( struct channel
*channel
)
1152 switch (channel
->type
)
1154 case WS_CHANNEL_TYPE_DUPLEX_SESSION
: return SESSION_MODE_DUPLEX
;
1156 FIXME( "unhandled channel type %08x\n", channel
->type
);
1157 return SESSION_MODE_INVALID
;
1163 KNOWN_ENCODING_SOAP11_UTF8
= 0x00,
1164 KNOWN_ENCODING_SOAP11_UTF16
= 0x01,
1165 KNOWN_ENCODING_SOAP11_UTF16LE
= 0x02,
1166 KNOWN_ENCODING_SOAP12_UTF8
= 0x03,
1167 KNOWN_ENCODING_SOAP12_UTF16
= 0x04,
1168 KNOWN_ENCODING_SOAP12_UTF16LE
= 0x05,
1169 KNOWN_ENCODING_SOAP12_MTOM
= 0x06,
1170 KNOWN_ENCODING_SOAP12_BINARY
= 0x07,
1171 KNOWN_ENCODING_SOAP12_BINARY_SESSION
= 0x08,
1174 static enum known_encoding
map_channel_encoding( struct channel
*channel
)
1176 WS_ENVELOPE_VERSION version
;
1178 prop_get( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_ENVELOPE_VERSION
, &version
, sizeof(version
) );
1182 case WS_ENVELOPE_VERSION_SOAP_1_1
:
1183 switch (channel
->encoding
)
1185 case WS_ENCODING_XML_UTF8
: return KNOWN_ENCODING_SOAP11_UTF8
;
1186 case WS_ENCODING_XML_UTF16LE
: return KNOWN_ENCODING_SOAP11_UTF16LE
;
1188 FIXME( "unhandled version/encoding %u/%u\n", version
, channel
->encoding
);
1191 case WS_ENVELOPE_VERSION_SOAP_1_2
:
1192 switch (channel
->encoding
)
1194 case WS_ENCODING_XML_UTF8
: return KNOWN_ENCODING_SOAP12_UTF8
;
1195 case WS_ENCODING_XML_UTF16LE
: return KNOWN_ENCODING_SOAP12_UTF16LE
;
1196 case WS_ENCODING_XML_BINARY_1
: return KNOWN_ENCODING_SOAP12_BINARY
;
1197 case WS_ENCODING_XML_BINARY_SESSION_1
: return KNOWN_ENCODING_SOAP12_BINARY_SESSION
;
1199 FIXME( "unhandled version/encoding %u/%u\n", version
, channel
->encoding
);
1203 ERR( "unhandled version %u\n", version
);
1208 #define FRAME_VERSION_MAJOR 1
1209 #define FRAME_VERSION_MINOR 1
1211 static HRESULT
send_preamble( struct channel
*channel
)
1217 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_VERSION
)) != S_OK
) return hr
;
1218 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_VERSION_MAJOR
)) != S_OK
) return hr
;
1219 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_VERSION_MINOR
)) != S_OK
) return hr
;
1221 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_MODE
)) != S_OK
) return hr
;
1222 if ((hr
= send_byte( channel
->u
.tcp
.socket
, map_channel_type(channel
) )) != S_OK
) return hr
;
1224 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_VIA
)) != S_OK
) return hr
;
1225 if ((hr
= string_to_utf8( &channel
->addr
.url
, &url
, &len
)) != S_OK
) return hr
;
1226 if ((hr
= send_size( channel
->u
.tcp
.socket
, len
)) != S_OK
) goto done
;
1227 if ((hr
= send_bytes( channel
->u
.tcp
.socket
, url
, len
)) != S_OK
) goto done
;
1229 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_KNOWN_ENCODING
)) != S_OK
) goto done
;
1230 if ((hr
= send_byte( channel
->u
.tcp
.socket
, map_channel_encoding(channel
) )) != S_OK
) goto done
;
1231 hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_PREAMBLE_END
);
1238 static HRESULT
receive_bytes( struct channel
*channel
, unsigned char *bytes
, int len
)
1240 int count
= recv( channel
->u
.tcp
.socket
, (char *)bytes
, len
, 0 );
1241 if (count
< 0) return HRESULT_FROM_WIN32( WSAGetLastError() );
1242 if (count
!= len
) return WS_E_INVALID_FORMAT
;
1246 static HRESULT
receive_preamble_ack( struct channel
*channel
)
1251 if ((hr
= receive_bytes( channel
, &byte
, 1 )) != S_OK
) return hr
;
1252 if (byte
!= FRAME_RECORD_TYPE_PREAMBLE_ACK
) return WS_E_INVALID_FORMAT
;
1253 channel
->session_state
= SESSION_STATE_SETUP_COMPLETE
;
1257 static HRESULT
send_sized_envelope( struct channel
*channel
, BYTE
*data
, ULONG len
)
1259 ULONG table_size
= string_table_size( &channel
->dict_send
);
1262 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_SIZED_ENVELOPE
)) != S_OK
) return hr
;
1263 if ((hr
= send_size( channel
->u
.tcp
.socket
, size_length(table_size
) + table_size
+ len
)) != S_OK
) return hr
;
1264 if ((hr
= send_size( channel
->u
.tcp
.socket
, table_size
)) != S_OK
) return hr
;
1265 if ((hr
= send_string_table( channel
->u
.tcp
.socket
, &channel
->dict_send
)) != S_OK
) return hr
;
1266 return send_bytes( channel
->u
.tcp
.socket
, data
, len
);
1269 static HRESULT
open_http_request( struct channel
*channel
, HINTERNET
*req
)
1271 if ((*req
= WinHttpOpenRequest( channel
->u
.http
.connect
, L
"POST", channel
->u
.http
.path
,
1272 NULL
, NULL
, NULL
, channel
->u
.http
.flags
))) return S_OK
;
1273 return HRESULT_FROM_WIN32( GetLastError() );
1276 static HRESULT
send_message( struct channel
*channel
, WS_MESSAGE
*msg
)
1278 WS_XML_WRITER
*writer
;
1283 WsGetMessageProperty( channel
->msg
, WS_MESSAGE_PROPERTY_BODY_WRITER
, &writer
, sizeof(writer
), NULL
);
1284 WsGetWriterProperty( writer
, WS_XML_WRITER_PROPERTY_BYTES
, &buf
, sizeof(buf
), NULL
);
1286 switch (channel
->binding
)
1288 case WS_HTTP_CHANNEL_BINDING
:
1289 if (channel
->u
.http
.request
)
1291 WinHttpCloseHandle( channel
->u
.http
.request
);
1292 channel
->u
.http
.request
= NULL
;
1294 if ((hr
= open_http_request( channel
, &channel
->u
.http
.request
)) != S_OK
) return hr
;
1295 if ((hr
= message_insert_http_headers( msg
, channel
->u
.http
.request
)) != S_OK
) return hr
;
1296 return send_message_http( channel
->u
.http
.request
, buf
.bytes
, buf
.length
);
1298 case WS_TCP_CHANNEL_BINDING
:
1299 if (channel
->type
& WS_CHANNEL_TYPE_SESSION
)
1301 switch (channel
->session_state
)
1303 case SESSION_STATE_UNINITIALIZED
:
1304 if ((hr
= send_preamble( channel
)) != S_OK
) return hr
;
1305 if ((hr
= receive_preamble_ack( channel
)) != S_OK
) return hr
;
1308 case SESSION_STATE_SETUP_COMPLETE
:
1309 return send_sized_envelope( channel
, buf
.bytes
, buf
.length
);
1312 ERR( "unhandled session state %u\n", channel
->session_state
);
1318 case WS_UDP_CHANNEL_BINDING
:
1319 return WsFlushWriter( writer
, 0, NULL
, NULL
);
1322 ERR( "unhandled binding %u\n", channel
->binding
);
1327 HRESULT
channel_send_message( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
)
1329 struct channel
*channel
= (struct channel
*)handle
;
1332 EnterCriticalSection( &channel
->cs
);
1334 if (channel
->magic
!= CHANNEL_MAGIC
)
1336 LeaveCriticalSection( &channel
->cs
);
1337 return E_INVALIDARG
;
1340 if ((hr
= connect_channel( channel
)) == S_OK
) hr
= send_message( channel
, msg
);
1342 LeaveCriticalSection( &channel
->cs
);
1346 static HRESULT CALLBACK
dict_cb( void *state
, const WS_XML_STRING
*str
, BOOL
*found
, ULONG
*id
, WS_ERROR
*error
)
1348 struct dictionary
*dict
= state
;
1353 if ((index
= find_string( dict
, str
->bytes
, str
->length
, id
)) == -1)
1359 if (!(bytes
= heap_alloc( str
->length
))) return E_OUTOFMEMORY
;
1360 memcpy( bytes
, str
->bytes
, str
->length
);
1361 if ((hr
= insert_string( dict
, bytes
, str
->length
, index
, id
)) == S_OK
)
1372 static CALLBACK HRESULT
write_callback( void *state
, const WS_BYTES
*buf
, ULONG count
,
1373 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
1375 SOCKET socket
= *(SOCKET
*)state
;
1376 if (send( socket
, (const char *)buf
->bytes
, buf
->length
, 0 ) < 0)
1378 TRACE( "send failed %u\n", WSAGetLastError() );
1383 static HRESULT
init_writer( struct channel
*channel
)
1385 WS_XML_WRITER_BUFFER_OUTPUT buf
= {{WS_XML_WRITER_OUTPUT_TYPE_BUFFER
}};
1386 WS_XML_WRITER_STREAM_OUTPUT stream
= {{WS_XML_WRITER_OUTPUT_TYPE_STREAM
}};
1387 WS_XML_WRITER_TEXT_ENCODING text
= {{WS_XML_WRITER_ENCODING_TYPE_TEXT
}, WS_CHARSET_UTF8
};
1388 WS_XML_WRITER_BINARY_ENCODING bin
= {{WS_XML_WRITER_ENCODING_TYPE_BINARY
}};
1389 const WS_XML_WRITER_ENCODING
*encoding
;
1390 const WS_XML_WRITER_OUTPUT
*output
;
1391 WS_XML_WRITER_PROPERTY prop
;
1392 ULONG max_size
= (1 << 17);
1395 prop
.id
= WS_XML_WRITER_PROPERTY_BUFFER_MAX_SIZE
;
1396 prop
.value
= &max_size
;
1397 prop
.valueSize
= sizeof(max_size
);
1398 if (!channel
->writer
&& (hr
= WsCreateWriter( &prop
, 1, &channel
->writer
, NULL
)) != S_OK
) return hr
;
1400 switch (channel
->encoding
)
1402 case WS_ENCODING_XML_UTF8
:
1403 encoding
= &text
.encoding
;
1404 if (channel
->binding
== WS_UDP_CHANNEL_BINDING
||
1405 (channel
->binding
== WS_TCP_CHANNEL_BINDING
&& !(channel
->type
& WS_CHANNEL_TYPE_SESSION
)))
1407 stream
.writeCallback
= write_callback
;
1408 stream
.writeCallbackState
= (channel
->binding
== WS_UDP_CHANNEL_BINDING
) ?
1409 &channel
->u
.udp
.socket
: &channel
->u
.tcp
.socket
;
1410 output
= &stream
.output
;
1412 else output
= &buf
.output
;
1415 case WS_ENCODING_XML_BINARY_SESSION_1
:
1416 bin
.staticDictionary
= (WS_XML_DICTIONARY
*)&dict_builtin_static
.dict
;
1419 case WS_ENCODING_XML_BINARY_1
:
1420 encoding
= &bin
.encoding
;
1421 output
= &buf
.output
;
1425 FIXME( "unhandled encoding %u\n", channel
->encoding
);
1426 return WS_E_NOT_SUPPORTED
;
1429 return WsSetOutput( channel
->writer
, encoding
, output
, NULL
, 0, NULL
);
1432 static HRESULT
write_message( struct channel
*channel
, WS_MESSAGE
*msg
, const WS_ELEMENT_DESCRIPTION
*desc
,
1433 WS_WRITE_OPTION option
, const void *body
, ULONG size
)
1436 if ((hr
= writer_set_lookup( channel
->writer
, TRUE
)) != S_OK
) return hr
;
1437 if ((hr
= WsWriteEnvelopeStart( msg
, channel
->writer
, NULL
, NULL
, NULL
)) != S_OK
) return hr
;
1438 if ((hr
= writer_set_lookup( channel
->writer
, FALSE
)) != S_OK
) return hr
;
1439 channel
->dict_send
.current_sequence
++;
1440 if ((hr
= writer_set_dict_callback( channel
->writer
, dict_cb
, &channel
->dict_send
)) != S_OK
) return hr
;
1441 if ((hr
= WsWriteBody( msg
, desc
, option
, body
, size
, NULL
)) != S_OK
) return hr
;
1442 return WsWriteEnvelopeEnd( msg
, NULL
);
1445 /**************************************************************************
1446 * WsSendMessage [webservices.@]
1448 HRESULT WINAPI
WsSendMessage( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
, const WS_MESSAGE_DESCRIPTION
*desc
,
1449 WS_WRITE_OPTION option
, const void *body
, ULONG size
, const WS_ASYNC_CONTEXT
*ctx
,
1452 struct channel
*channel
= (struct channel
*)handle
;
1455 TRACE( "%p %p %p %08x %p %u %p %p\n", handle
, msg
, desc
, option
, body
, size
, ctx
, error
);
1456 if (error
) FIXME( "ignoring error parameter\n" );
1457 if (ctx
) FIXME( "ignoring ctx parameter\n" );
1459 if (!channel
|| !msg
|| !desc
) return E_INVALIDARG
;
1461 EnterCriticalSection( &channel
->cs
);
1463 if (channel
->magic
!= CHANNEL_MAGIC
)
1465 LeaveCriticalSection( &channel
->cs
);
1466 return E_INVALIDARG
;
1469 if ((hr
= WsInitializeMessage( msg
, WS_REQUEST_MESSAGE
, NULL
, NULL
)) != S_OK
) goto done
;
1470 if ((hr
= WsAddressMessage( msg
, &channel
->addr
, NULL
)) != S_OK
) goto done
;
1471 if ((hr
= message_set_action( msg
, desc
->action
)) != S_OK
) goto done
;
1473 if ((hr
= connect_channel( channel
)) != S_OK
) goto done
;
1474 if ((hr
= init_writer( channel
)) != S_OK
) goto done
;
1475 if ((hr
= write_message( channel
, msg
, desc
->bodyElementDescription
, option
, body
, size
)) != S_OK
) goto done
;
1476 hr
= send_message( channel
, msg
);
1479 LeaveCriticalSection( &channel
->cs
);
1480 TRACE( "returning %08x\n", hr
);
1484 /**************************************************************************
1485 * WsSendReplyMessage [webservices.@]
1487 HRESULT WINAPI
WsSendReplyMessage( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
, const WS_MESSAGE_DESCRIPTION
*desc
,
1488 WS_WRITE_OPTION option
, const void *body
, ULONG size
, WS_MESSAGE
*request
,
1489 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
1491 struct channel
*channel
= (struct channel
*)handle
;
1495 TRACE( "%p %p %p %08x %p %u %p %p %p\n", handle
, msg
, desc
, option
, body
, size
, request
, ctx
, error
);
1496 if (error
) FIXME( "ignoring error parameter\n" );
1497 if (ctx
) FIXME( "ignoring ctx parameter\n" );
1499 if (!channel
|| !msg
|| !desc
|| !request
) return E_INVALIDARG
;
1501 EnterCriticalSection( &channel
->cs
);
1503 if (channel
->magic
!= CHANNEL_MAGIC
)
1505 LeaveCriticalSection( &channel
->cs
);
1506 return E_INVALIDARG
;
1509 if ((hr
= WsInitializeMessage( msg
, WS_REPLY_MESSAGE
, NULL
, NULL
)) != S_OK
) goto done
;
1510 if ((hr
= WsAddressMessage( msg
, &channel
->addr
, NULL
)) != S_OK
) goto done
;
1511 if ((hr
= message_set_action( msg
, desc
->action
)) != S_OK
) goto done
;
1512 if ((hr
= message_get_id( request
, &req_id
)) != S_OK
) goto done
;
1513 if ((hr
= message_set_request_id( msg
, &req_id
)) != S_OK
) goto done
;
1515 if ((hr
= connect_channel( channel
)) != S_OK
) goto done
;
1516 if ((hr
= init_writer( channel
)) != S_OK
) goto done
;
1517 if ((hr
= write_message( channel
, msg
, desc
->bodyElementDescription
, option
, body
, size
)) != S_OK
) goto done
;
1518 hr
= send_message( channel
, msg
);
1521 LeaveCriticalSection( &channel
->cs
);
1522 TRACE( "returning %08x\n", hr
);
1526 static HRESULT
resize_read_buffer( struct channel
*channel
, ULONG size
)
1528 if (!channel
->read_buf
)
1530 if (!(channel
->read_buf
= heap_alloc( size
))) return E_OUTOFMEMORY
;
1531 channel
->read_buflen
= size
;
1534 if (channel
->read_buflen
< size
)
1537 ULONG new_size
= max( size
, channel
->read_buflen
* 2 );
1538 if (!(tmp
= heap_realloc( channel
->read_buf
, new_size
))) return E_OUTOFMEMORY
;
1539 channel
->read_buf
= tmp
;
1540 channel
->read_buflen
= new_size
;
1545 static CALLBACK HRESULT
read_callback( void *state
, void *buf
, ULONG buflen
, ULONG
*retlen
,
1546 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
1548 SOCKET socket
= *(SOCKET
*)state
;
1551 if ((ret
= recv( socket
, buf
, buflen
, 0 )) >= 0) *retlen
= ret
;
1554 TRACE( "recv failed %u\n", WSAGetLastError() );
1560 static HRESULT
init_reader( struct channel
*channel
)
1562 WS_XML_READER_BUFFER_INPUT buf
= {{WS_XML_READER_INPUT_TYPE_BUFFER
}};
1563 WS_XML_READER_STREAM_INPUT stream
= {{WS_XML_READER_INPUT_TYPE_STREAM
}};
1564 WS_XML_READER_TEXT_ENCODING text
= {{WS_XML_READER_ENCODING_TYPE_TEXT
}};
1565 WS_XML_READER_BINARY_ENCODING bin
= {{WS_XML_READER_ENCODING_TYPE_BINARY
}};
1566 const WS_XML_READER_ENCODING
*encoding
;
1567 const WS_XML_READER_INPUT
*input
;
1570 if (!channel
->reader
&& (hr
= WsCreateReader( NULL
, 0, &channel
->reader
, NULL
)) != S_OK
) return hr
;
1572 switch (channel
->encoding
)
1574 case WS_ENCODING_XML_UTF8
:
1575 text
.charSet
= WS_CHARSET_UTF8
;
1576 encoding
= &text
.encoding
;
1578 if (channel
->binding
== WS_UDP_CHANNEL_BINDING
||
1579 (channel
->binding
== WS_TCP_CHANNEL_BINDING
&& !(channel
->type
& WS_CHANNEL_TYPE_SESSION
)))
1581 stream
.readCallback
= read_callback
;
1582 stream
.readCallbackState
= (channel
->binding
== WS_UDP_CHANNEL_BINDING
) ?
1583 &channel
->u
.udp
.socket
: &channel
->u
.tcp
.socket
;
1584 input
= &stream
.input
;
1588 buf
.encodedData
= channel
->read_buf
;
1589 buf
.encodedDataSize
= channel
->read_size
;
1594 case WS_ENCODING_XML_BINARY_SESSION_1
:
1595 bin
.staticDictionary
= (WS_XML_DICTIONARY
*)&dict_builtin_static
.dict
;
1596 bin
.dynamicDictionary
= &channel
->dict_recv
.dict
;
1599 case WS_ENCODING_XML_BINARY_1
:
1600 encoding
= &bin
.encoding
;
1602 buf
.encodedData
= channel
->read_buf
;
1603 buf
.encodedDataSize
= channel
->read_size
;
1608 FIXME( "unhandled encoding %u\n", channel
->encoding
);
1609 return WS_E_NOT_SUPPORTED
;
1612 return WsSetInput( channel
->reader
, encoding
, input
, NULL
, 0, NULL
);
1615 static const WS_HTTP_MESSAGE_MAPPING
*get_http_message_mapping( struct channel
*channel
)
1617 const struct prop
*prop
= &channel
->prop
[WS_CHANNEL_PROPERTY_HTTP_MESSAGE_MAPPING
];
1618 return (const WS_HTTP_MESSAGE_MAPPING
*)prop
->value
;
1621 static HRESULT
map_http_response_headers( struct channel
*channel
, WS_MESSAGE
*msg
)
1623 const WS_HTTP_MESSAGE_MAPPING
*mapping
= get_http_message_mapping( channel
);
1624 return message_map_http_response_headers( msg
, channel
->u
.http
.request
, mapping
);
1627 #define INITIAL_READ_BUFFER_SIZE 4096
1628 static HRESULT
receive_message_http( struct channel
*channel
, WS_MESSAGE
*msg
)
1630 DWORD len
, bytes_read
, offset
= 0, size
= INITIAL_READ_BUFFER_SIZE
;
1634 if ((hr
= map_http_response_headers( channel
, msg
)) != S_OK
) return hr
;
1636 prop_get( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE
,
1637 &max_len
, sizeof(max_len
) );
1639 if ((hr
= resize_read_buffer( channel
, size
)) != S_OK
) return hr
;
1640 channel
->read_size
= 0;
1643 if (!WinHttpQueryDataAvailable( channel
->u
.http
.request
, &len
))
1645 return HRESULT_FROM_WIN32( GetLastError() );
1648 if (channel
->read_size
+ len
> max_len
) return WS_E_QUOTA_EXCEEDED
;
1649 if ((hr
= resize_read_buffer( channel
, channel
->read_size
+ len
)) != S_OK
) return hr
;
1651 if (!WinHttpReadData( channel
->u
.http
.request
, channel
->read_buf
+ offset
, len
, &bytes_read
))
1653 return HRESULT_FROM_WIN32( GetLastError() );
1655 if (!bytes_read
) break;
1656 channel
->read_size
+= bytes_read
;
1657 offset
+= bytes_read
;
1663 static HRESULT
receive_message_sized( struct channel
*channel
, unsigned int size
)
1665 unsigned int offset
= 0, to_read
= size
;
1669 if ((hr
= resize_read_buffer( channel
, size
)) != S_OK
) return hr
;
1671 channel
->read_size
= 0;
1672 while (channel
->read_size
< size
)
1674 if ((bytes_read
= recv( channel
->u
.tcp
.socket
, channel
->read_buf
+ offset
, to_read
, 0 )) < 0)
1676 return HRESULT_FROM_WIN32( WSAGetLastError() );
1678 if (!bytes_read
) break;
1679 channel
->read_size
+= bytes_read
;
1680 to_read
-= bytes_read
;
1681 offset
+= bytes_read
;
1683 if (channel
->read_size
!= size
) return WS_E_INVALID_FORMAT
;
1687 static HRESULT
receive_size( struct channel
*channel
, unsigned int *size
)
1692 if ((hr
= receive_bytes( channel
, &byte
, 1 )) != S_OK
) return hr
;
1693 *size
= byte
& 0x7f;
1694 if (!(byte
& 0x80)) return S_OK
;
1696 if ((hr
= receive_bytes( channel
, &byte
, 1 )) != S_OK
) return hr
;
1697 *size
+= (byte
& 0x7f) << 7;
1698 if (!(byte
& 0x80)) return S_OK
;
1700 if ((hr
= receive_bytes( channel
, &byte
, 1 )) != S_OK
) return hr
;
1701 *size
+= (byte
& 0x7f) << 14;
1702 if (!(byte
& 0x80)) return S_OK
;
1704 if ((hr
= receive_bytes( channel
, &byte
, 1 )) != S_OK
) return hr
;
1705 *size
+= (byte
& 0x7f) << 21;
1706 if (!(byte
& 0x80)) return S_OK
;
1708 if ((hr
= receive_bytes( channel
, &byte
, 1 )) != S_OK
) return hr
;
1709 if (byte
& ~0x0f) return WS_E_INVALID_FORMAT
;
1710 *size
+= byte
<< 28;
1714 static WS_ENCODING
map_known_encoding( enum known_encoding encoding
)
1718 case KNOWN_ENCODING_SOAP11_UTF8
:
1719 case KNOWN_ENCODING_SOAP12_UTF8
: return WS_ENCODING_XML_UTF8
;
1720 case KNOWN_ENCODING_SOAP11_UTF16
:
1721 case KNOWN_ENCODING_SOAP12_UTF16
: return WS_ENCODING_XML_UTF16BE
;
1722 case KNOWN_ENCODING_SOAP11_UTF16LE
:
1723 case KNOWN_ENCODING_SOAP12_UTF16LE
: return WS_ENCODING_XML_UTF16LE
;
1724 case KNOWN_ENCODING_SOAP12_BINARY
: return WS_ENCODING_XML_BINARY_1
;
1725 case KNOWN_ENCODING_SOAP12_BINARY_SESSION
: return WS_ENCODING_XML_BINARY_SESSION_1
;
1727 WARN( "unhandled encoding %u, assuming UTF8\n", encoding
);
1728 return WS_ENCODING_XML_UTF8
;
1732 static HRESULT
receive_preamble( struct channel
*channel
)
1739 if ((hr
= receive_bytes( channel
, &type
, 1 )) != S_OK
) return hr
;
1740 if (type
== FRAME_RECORD_TYPE_PREAMBLE_END
) break;
1743 case FRAME_RECORD_TYPE_VERSION
:
1745 unsigned char major
, minor
;
1746 if ((hr
= receive_bytes( channel
, &major
, 1 )) != S_OK
) return hr
;
1747 if ((hr
= receive_bytes( channel
, &minor
, 1 )) != S_OK
) return hr
;
1748 TRACE( "major %u minor %u\n", major
, major
);
1751 case FRAME_RECORD_TYPE_MODE
:
1754 if ((hr
= receive_bytes( channel
, &mode
, 1 )) != S_OK
) return hr
;
1755 TRACE( "mode %u\n", mode
);
1758 case FRAME_RECORD_TYPE_VIA
:
1763 if ((hr
= receive_size( channel
, &size
)) != S_OK
) return hr
;
1764 if (!(url
= heap_alloc( size
))) return E_OUTOFMEMORY
;
1765 if ((hr
= receive_bytes( channel
, url
, size
)) != S_OK
)
1770 TRACE( "transport URL %s\n", debugstr_an((char *)url
, size
) );
1771 heap_free( url
); /* FIXME: verify */
1774 case FRAME_RECORD_TYPE_KNOWN_ENCODING
:
1776 unsigned char encoding
;
1777 if ((hr
= receive_bytes( channel
, &encoding
, 1 )) != S_OK
) return hr
;
1778 TRACE( "encoding %u\n", encoding
);
1779 channel
->encoding
= map_known_encoding( encoding
);
1783 WARN( "unhandled record type %u\n", type
);
1784 return WS_E_INVALID_FORMAT
;
1791 static HRESULT
receive_sized_envelope( struct channel
*channel
)
1797 if ((hr
= receive_bytes( channel
, &type
, 1 )) != S_OK
) return hr
;
1798 if (type
!= FRAME_RECORD_TYPE_SIZED_ENVELOPE
) return WS_E_INVALID_FORMAT
;
1799 if ((hr
= receive_size( channel
, &size
)) != S_OK
) return hr
;
1800 if ((hr
= receive_message_sized( channel
, size
)) != S_OK
) return hr
;
1804 static HRESULT
read_size( const BYTE
**ptr
, ULONG len
, ULONG
*size
)
1806 const BYTE
*buf
= *ptr
;
1808 if (len
< 1) return WS_E_INVALID_FORMAT
;
1809 *size
= buf
[0] & 0x7f;
1810 if (!(buf
[0] & 0x80))
1815 if (len
< 2) return WS_E_INVALID_FORMAT
;
1816 *size
+= (buf
[1] & 0x7f) << 7;
1817 if (!(buf
[1] & 0x80))
1822 if (len
< 3) return WS_E_INVALID_FORMAT
;
1823 *size
+= (buf
[2] & 0x7f) << 14;
1824 if (!(buf
[2] & 0x80))
1829 if (len
< 4) return WS_E_INVALID_FORMAT
;
1830 *size
+= (buf
[3] & 0x7f) << 21;
1831 if (!(buf
[3] & 0x80))
1836 if (len
< 5 || (buf
[4] & ~0x07)) return WS_E_INVALID_FORMAT
;
1837 *size
+= buf
[4] << 28;
1842 static HRESULT
build_dict( const BYTE
*buf
, ULONG buflen
, struct dictionary
*dict
, ULONG
*used
)
1844 ULONG size
, strings_size
, strings_offset
;
1845 const BYTE
*ptr
= buf
;
1850 if ((hr
= read_size( &ptr
, buflen
, &strings_size
)) != S_OK
) return hr
;
1851 strings_offset
= ptr
- buf
;
1852 if (buflen
< strings_offset
+ strings_size
) return WS_E_INVALID_FORMAT
;
1853 *used
= strings_offset
+ strings_size
;
1854 if (!strings_size
) return S_OK
;
1856 UuidCreate( &dict
->dict
.guid
);
1857 dict
->dict
.isConst
= FALSE
;
1859 buflen
-= strings_offset
;
1860 ptr
= buf
+ strings_offset
;
1861 while (ptr
< buf
+ strings_size
)
1863 if ((hr
= read_size( &ptr
, buflen
, &size
)) != S_OK
)
1871 return WS_E_INVALID_FORMAT
;
1874 if (!(bytes
= heap_alloc( size
)))
1879 memcpy( bytes
, ptr
, size
);
1880 if ((index
= find_string( dict
, bytes
, size
, NULL
)) == -1) /* duplicate */
1886 if ((hr
= insert_string( dict
, bytes
, size
, index
, NULL
)) != S_OK
)
1901 static HRESULT
send_preamble_ack( struct channel
*channel
)
1904 if ((hr
= send_byte( channel
->u
.tcp
.socket
, FRAME_RECORD_TYPE_PREAMBLE_ACK
)) != S_OK
) return hr
;
1905 channel
->session_state
= SESSION_STATE_SETUP_COMPLETE
;
1909 static HRESULT
receive_message_session( struct channel
*channel
)
1913 if ((hr
= receive_sized_envelope( channel
)) != S_OK
) return hr
;
1914 if (channel
->encoding
== WS_ENCODING_XML_BINARY_SESSION_1
)
1917 if ((hr
= build_dict( (const BYTE
*)channel
->read_buf
, channel
->read_size
, &channel
->dict_recv
,
1918 &size
)) != S_OK
) return hr
;
1919 channel
->read_size
-= size
;
1920 memmove( channel
->read_buf
, channel
->read_buf
+ size
, channel
->read_size
);
1926 static HRESULT
receive_message_bytes( struct channel
*channel
, WS_MESSAGE
*msg
)
1929 if ((hr
= connect_channel( channel
)) != S_OK
) return hr
;
1931 switch (channel
->binding
)
1933 case WS_HTTP_CHANNEL_BINDING
:
1934 return receive_message_http( channel
, msg
);
1936 case WS_TCP_CHANNEL_BINDING
:
1937 if (channel
->type
& WS_CHANNEL_TYPE_SESSION
)
1939 switch (channel
->session_state
)
1941 case SESSION_STATE_UNINITIALIZED
:
1942 if ((hr
= receive_preamble( channel
)) != S_OK
) return hr
;
1943 if ((hr
= send_preamble_ack( channel
)) != S_OK
) return hr
;
1946 case SESSION_STATE_SETUP_COMPLETE
:
1947 return receive_message_session( channel
);
1950 ERR( "unhandled session state %u\n", channel
->session_state
);
1954 return S_OK
; /* nothing to do, data is read through stream callback */
1956 case WS_UDP_CHANNEL_BINDING
:
1960 ERR( "unhandled binding %u\n", channel
->binding
);
1965 HRESULT
channel_receive_message( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
)
1967 struct channel
*channel
= (struct channel
*)handle
;
1970 EnterCriticalSection( &channel
->cs
);
1972 if (channel
->magic
!= CHANNEL_MAGIC
)
1974 LeaveCriticalSection( &channel
->cs
);
1975 return E_INVALIDARG
;
1978 if ((hr
= receive_message_bytes( channel
, msg
)) == S_OK
) hr
= init_reader( channel
);
1980 LeaveCriticalSection( &channel
->cs
);
1984 HRESULT
channel_get_reader( WS_CHANNEL
*handle
, WS_XML_READER
**reader
)
1986 struct channel
*channel
= (struct channel
*)handle
;
1988 EnterCriticalSection( &channel
->cs
);
1990 if (channel
->magic
!= CHANNEL_MAGIC
)
1992 LeaveCriticalSection( &channel
->cs
);
1993 return E_INVALIDARG
;
1996 *reader
= channel
->reader
;
1998 LeaveCriticalSection( &channel
->cs
);
2002 static HRESULT
read_message( WS_MESSAGE
*handle
, WS_XML_READER
*reader
, const WS_ELEMENT_DESCRIPTION
*desc
,
2003 WS_READ_OPTION option
, WS_HEAP
*heap
, void *body
, ULONG size
)
2006 if ((hr
= WsReadEnvelopeStart( handle
, reader
, NULL
, NULL
, NULL
)) != S_OK
) return hr
;
2007 if ((hr
= WsReadBody( handle
, desc
, option
, heap
, body
, size
, NULL
)) != S_OK
) return hr
;
2008 return WsReadEnvelopeEnd( handle
, NULL
);
2011 static HRESULT
receive_message( struct channel
*channel
, WS_MESSAGE
*msg
, const WS_MESSAGE_DESCRIPTION
**desc
,
2012 ULONG count
, WS_RECEIVE_OPTION option
, WS_READ_OPTION read_option
, WS_HEAP
*heap
,
2013 void *value
, ULONG size
, ULONG
*index
)
2018 if ((hr
= receive_message_bytes( channel
, msg
)) != S_OK
) return hr
;
2019 if ((hr
= init_reader( channel
)) != S_OK
) return hr
;
2021 for (i
= 0; i
< count
; i
++)
2023 const WS_ELEMENT_DESCRIPTION
*body
= desc
[i
]->bodyElementDescription
;
2024 if ((hr
= read_message( msg
, channel
->reader
, body
, read_option
, heap
, value
, size
)) == S_OK
)
2026 if (index
) *index
= i
;
2029 if ((hr
= WsResetMessage( msg
, NULL
)) != S_OK
) return hr
;
2030 if ((hr
= init_reader( channel
)) != S_OK
) return hr
;
2032 return (i
== count
) ? WS_E_INVALID_FORMAT
: S_OK
;
2035 struct receive_message
2038 struct channel
*channel
;
2040 const WS_MESSAGE_DESCRIPTION
**desc
;
2042 WS_RECEIVE_OPTION option
;
2043 WS_READ_OPTION read_option
;
2048 WS_ASYNC_CONTEXT ctx
;
2051 static void receive_message_proc( struct task
*task
)
2053 struct receive_message
*r
= (struct receive_message
*)task
;
2056 hr
= receive_message( r
->channel
, r
->msg
, r
->desc
, r
->count
, r
->option
, r
->read_option
, r
->heap
, r
->value
,
2057 r
->size
, r
->index
);
2059 TRACE( "calling %p(%08x)\n", r
->ctx
.callback
, hr
);
2060 r
->ctx
.callback( hr
, WS_LONG_CALLBACK
, r
->ctx
.callbackState
);
2061 TRACE( "%p returned\n", r
->ctx
.callback
);
2064 static HRESULT
queue_receive_message( struct channel
*channel
, WS_MESSAGE
*msg
, const WS_MESSAGE_DESCRIPTION
**desc
,
2065 ULONG count
, WS_RECEIVE_OPTION option
, WS_READ_OPTION read_option
,
2066 WS_HEAP
*heap
, void *value
, ULONG size
, ULONG
*index
,
2067 const WS_ASYNC_CONTEXT
*ctx
)
2069 struct receive_message
*r
;
2071 if (!(r
= heap_alloc( sizeof(*r
) ))) return E_OUTOFMEMORY
;
2072 r
->task
.proc
= receive_message_proc
;
2073 r
->channel
= channel
;
2078 r
->read_option
= read_option
;
2084 return queue_task( &channel
->recv_q
, &r
->task
);
2087 /**************************************************************************
2088 * WsReceiveMessage [webservices.@]
2090 HRESULT WINAPI
WsReceiveMessage( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
, const WS_MESSAGE_DESCRIPTION
**desc
,
2091 ULONG count
, WS_RECEIVE_OPTION option
, WS_READ_OPTION read_option
, WS_HEAP
*heap
,
2092 void *value
, ULONG size
, ULONG
*index
, const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
2094 struct channel
*channel
= (struct channel
*)handle
;
2097 TRACE( "%p %p %p %u %08x %08x %p %p %u %p %p %p\n", handle
, msg
, desc
, count
, option
, read_option
, heap
,
2098 value
, size
, index
, ctx
, error
);
2099 if (error
) FIXME( "ignoring error parameter\n" );
2101 if (!channel
|| !msg
|| !desc
|| !count
) return E_INVALIDARG
;
2103 EnterCriticalSection( &channel
->cs
);
2105 if (channel
->magic
!= CHANNEL_MAGIC
)
2107 LeaveCriticalSection( &channel
->cs
);
2108 return E_INVALIDARG
;
2112 hr
= queue_receive_message( channel
, msg
, desc
, count
, option
, read_option
, heap
, value
, size
, index
, ctx
);
2114 hr
= receive_message( channel
, msg
, desc
, count
, option
, read_option
, heap
, value
, size
, index
);
2116 LeaveCriticalSection( &channel
->cs
);
2117 TRACE( "returning %08x\n", hr
);
2121 static HRESULT
request_reply( struct channel
*channel
, WS_MESSAGE
*request
,
2122 const WS_MESSAGE_DESCRIPTION
*request_desc
, WS_WRITE_OPTION write_option
,
2123 const void *request_body
, ULONG request_size
, WS_MESSAGE
*reply
,
2124 const WS_MESSAGE_DESCRIPTION
*reply_desc
, WS_READ_OPTION read_option
,
2125 WS_HEAP
*heap
, void *value
, ULONG size
)
2128 WsInitializeMessage( request
, WS_REQUEST_MESSAGE
, NULL
, NULL
);
2129 if ((hr
= WsAddressMessage( request
, &channel
->addr
, NULL
)) != S_OK
) return hr
;
2130 if ((hr
= message_set_action( request
, request_desc
->action
)) != S_OK
) return hr
;
2132 if ((hr
= connect_channel( channel
)) != S_OK
) return hr
;
2133 if ((hr
= init_writer( channel
)) != S_OK
) return hr
;
2134 if ((hr
= write_message( channel
, request
, request_desc
->bodyElementDescription
, write_option
, request_body
,
2135 request_size
)) != S_OK
) return hr
;
2136 if ((hr
= send_message( channel
, request
)) != S_OK
) return hr
;
2138 return receive_message( channel
, reply
, &reply_desc
, 1, WS_RECEIVE_OPTIONAL_MESSAGE
, read_option
, heap
,
2139 value
, size
, NULL
);
2142 struct request_reply
2145 struct channel
*channel
;
2146 WS_MESSAGE
*request
;
2147 const WS_MESSAGE_DESCRIPTION
*request_desc
;
2148 WS_WRITE_OPTION write_option
;
2149 const void *request_body
;
2152 const WS_MESSAGE_DESCRIPTION
*reply_desc
;
2153 WS_READ_OPTION read_option
;
2157 WS_ASYNC_CONTEXT ctx
;
2160 static void request_reply_proc( struct task
*task
)
2162 struct request_reply
*r
= (struct request_reply
*)task
;
2165 hr
= request_reply( r
->channel
, r
->request
, r
->request_desc
, r
->write_option
, r
->request_body
, r
->request_size
,
2166 r
->reply
, r
->reply_desc
, r
->read_option
, r
->heap
, r
->value
, r
->size
);
2168 TRACE( "calling %p(%08x)\n", r
->ctx
.callback
, hr
);
2169 r
->ctx
.callback( hr
, WS_LONG_CALLBACK
, r
->ctx
.callbackState
);
2170 TRACE( "%p returned\n", r
->ctx
.callback
);
2173 static HRESULT
queue_request_reply( struct channel
*channel
, WS_MESSAGE
*request
,
2174 const WS_MESSAGE_DESCRIPTION
*request_desc
, WS_WRITE_OPTION write_option
,
2175 const void *request_body
, ULONG request_size
, WS_MESSAGE
*reply
,
2176 const WS_MESSAGE_DESCRIPTION
*reply_desc
, WS_READ_OPTION read_option
,
2177 WS_HEAP
*heap
, void *value
, ULONG size
, const WS_ASYNC_CONTEXT
*ctx
)
2179 struct request_reply
*r
;
2181 if (!(r
= heap_alloc( sizeof(*r
) ))) return E_OUTOFMEMORY
;
2182 r
->task
.proc
= request_reply_proc
;
2183 r
->channel
= channel
;
2184 r
->request
= request
;
2185 r
->request_desc
= request_desc
;
2186 r
->write_option
= write_option
;
2187 r
->request_body
= request_body
;
2188 r
->request_size
= request_size
;
2190 r
->reply_desc
= reply_desc
;
2191 r
->read_option
= read_option
;
2196 return queue_task( &channel
->recv_q
, &r
->task
);
2199 /**************************************************************************
2200 * WsRequestReply [webservices.@]
2202 HRESULT WINAPI
WsRequestReply( WS_CHANNEL
*handle
, WS_MESSAGE
*request
, const WS_MESSAGE_DESCRIPTION
*request_desc
,
2203 WS_WRITE_OPTION write_option
, const void *request_body
, ULONG request_size
,
2204 WS_MESSAGE
*reply
, const WS_MESSAGE_DESCRIPTION
*reply_desc
, WS_READ_OPTION read_option
,
2205 WS_HEAP
*heap
, void *value
, ULONG size
, const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
2207 struct channel
*channel
= (struct channel
*)handle
;
2210 TRACE( "%p %p %p %08x %p %u %p %p %08x %p %p %u %p %p\n", handle
, request
, request_desc
, write_option
,
2211 request_body
, request_size
, reply
, reply_desc
, read_option
, heap
, value
, size
, ctx
, error
);
2212 if (error
) FIXME( "ignoring error parameter\n" );
2213 if (ctx
) FIXME( "ignoring ctx parameter\n" );
2215 if (!channel
|| !request
|| !reply
) return E_INVALIDARG
;
2217 EnterCriticalSection( &channel
->cs
);
2219 if (channel
->magic
!= CHANNEL_MAGIC
)
2221 LeaveCriticalSection( &channel
->cs
);
2222 return E_INVALIDARG
;
2226 hr
= queue_request_reply( channel
, request
, request_desc
, write_option
, request_body
, request_size
, reply
,
2227 reply_desc
, read_option
, heap
, value
, size
, ctx
);
2229 hr
= request_reply( channel
, request
, request_desc
, write_option
, request_body
, request_size
, reply
,
2230 reply_desc
, read_option
, heap
, value
, size
);
2232 LeaveCriticalSection( &channel
->cs
);
2233 TRACE( "returning %08x\n", hr
);
2237 /**************************************************************************
2238 * WsReadMessageStart [webservices.@]
2240 HRESULT WINAPI
WsReadMessageStart( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
, const WS_ASYNC_CONTEXT
*ctx
,
2243 struct channel
*channel
= (struct channel
*)handle
;
2246 TRACE( "%p %p %p %p\n", handle
, msg
, ctx
, error
);
2247 if (error
) FIXME( "ignoring error parameter\n" );
2248 if (ctx
) FIXME( "ignoring ctx parameter\n" );
2250 if (!channel
|| !msg
) return E_INVALIDARG
;
2252 EnterCriticalSection( &channel
->cs
);
2254 if (channel
->magic
!= CHANNEL_MAGIC
)
2256 LeaveCriticalSection( &channel
->cs
);
2257 return E_INVALIDARG
;
2260 if ((hr
= receive_message_bytes( channel
, msg
)) == S_OK
)
2262 if ((hr
= init_reader( channel
)) == S_OK
)
2263 hr
= WsReadEnvelopeStart( msg
, channel
->reader
, NULL
, NULL
, NULL
);
2266 LeaveCriticalSection( &channel
->cs
);
2267 TRACE( "returning %08x\n", hr
);
2271 /**************************************************************************
2272 * WsReadMessageEnd [webservices.@]
2274 HRESULT WINAPI
WsReadMessageEnd( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
, const WS_ASYNC_CONTEXT
*ctx
,
2277 struct channel
*channel
= (struct channel
*)handle
;
2280 TRACE( "%p %p %p %p\n", handle
, msg
, ctx
, error
);
2281 if (error
) FIXME( "ignoring error parameter\n" );
2282 if (ctx
) FIXME( "ignoring ctx parameter\n" );
2284 if (!channel
|| !msg
) return E_INVALIDARG
;
2286 EnterCriticalSection( &channel
->cs
);
2288 if (channel
->magic
!= CHANNEL_MAGIC
)
2290 LeaveCriticalSection( &channel
->cs
);
2291 return E_INVALIDARG
;
2294 hr
= WsReadEnvelopeEnd( msg
, NULL
);
2296 LeaveCriticalSection( &channel
->cs
);
2297 TRACE( "returning %08x\n", hr
);
2301 /**************************************************************************
2302 * WsWriteMessageStart [webservices.@]
2304 HRESULT WINAPI
WsWriteMessageStart( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
, const WS_ASYNC_CONTEXT
*ctx
,
2307 struct channel
*channel
= (struct channel
*)handle
;
2310 TRACE( "%p %p %p %p\n", handle
, msg
, ctx
, error
);
2311 if (error
) FIXME( "ignoring error parameter\n" );
2312 if (ctx
) FIXME( "ignoring ctx parameter\n" );
2314 if (!channel
|| !msg
) return E_INVALIDARG
;
2316 EnterCriticalSection( &channel
->cs
);
2318 if (channel
->magic
!= CHANNEL_MAGIC
)
2320 LeaveCriticalSection( &channel
->cs
);
2321 return E_INVALIDARG
;
2324 if ((hr
= connect_channel( channel
)) != S_OK
) goto done
;
2325 if ((hr
= init_writer( channel
)) != S_OK
) goto done
;
2326 if ((hr
= WsAddressMessage( msg
, &channel
->addr
, NULL
)) != S_OK
) goto done
;
2327 hr
= WsWriteEnvelopeStart( msg
, channel
->writer
, NULL
, NULL
, NULL
);
2330 LeaveCriticalSection( &channel
->cs
);
2331 TRACE( "returning %08x\n", hr
);
2335 /**************************************************************************
2336 * WsWriteMessageEnd [webservices.@]
2338 HRESULT WINAPI
WsWriteMessageEnd( WS_CHANNEL
*handle
, WS_MESSAGE
*msg
, const WS_ASYNC_CONTEXT
*ctx
,
2341 struct channel
*channel
= (struct channel
*)handle
;
2344 TRACE( "%p %p %p %p\n", handle
, msg
, ctx
, error
);
2345 if (error
) FIXME( "ignoring error parameter\n" );
2346 if (ctx
) FIXME( "ignoring ctx parameter\n" );
2348 if (!channel
|| !msg
) return E_INVALIDARG
;
2350 EnterCriticalSection( &channel
->cs
);
2352 if (channel
->magic
!= CHANNEL_MAGIC
)
2354 LeaveCriticalSection( &channel
->cs
);
2355 return E_INVALIDARG
;
2358 if ((hr
= WsWriteEnvelopeEnd( msg
, NULL
)) == S_OK
&& (hr
= connect_channel( channel
)) == S_OK
)
2359 hr
= send_message( channel
, msg
);
2361 LeaveCriticalSection( &channel
->cs
);
2362 TRACE( "returning %08x\n", hr
);
2366 static void set_blocking( SOCKET socket
, BOOL blocking
)
2368 ULONG state
= !blocking
;
2369 ioctlsocket( socket
, FIONBIO
, &state
);
2372 static HRESULT
sock_accept( SOCKET socket
, HANDLE wait
, HANDLE cancel
, SOCKET
*ret
)
2374 HANDLE handles
[] = { wait
, cancel
};
2377 if (WSAEventSelect( socket
, handles
[0], FD_ACCEPT
)) return HRESULT_FROM_WIN32( WSAGetLastError() );
2379 switch (WSAWaitForMultipleEvents( 2, handles
, FALSE
, WSA_INFINITE
, FALSE
))
2382 if ((*ret
= accept( socket
, NULL
, NULL
)) != -1)
2384 WSAEventSelect( *ret
, NULL
, 0 );
2385 set_blocking( *ret
, TRUE
);
2388 hr
= HRESULT_FROM_WIN32( WSAGetLastError() );
2392 hr
= WS_E_OPERATION_ABORTED
;
2396 hr
= HRESULT_FROM_WIN32( WSAGetLastError() );
2403 HRESULT
channel_accept_tcp( SOCKET socket
, HANDLE wait
, HANDLE cancel
, WS_CHANNEL
*handle
)
2405 struct channel
*channel
= (struct channel
*)handle
;
2408 EnterCriticalSection( &channel
->cs
);
2410 if (channel
->magic
!= CHANNEL_MAGIC
)
2412 LeaveCriticalSection( &channel
->cs
);
2413 return E_INVALIDARG
;
2416 if ((hr
= sock_accept( socket
, wait
, cancel
, &channel
->u
.tcp
.socket
)) == S_OK
)
2418 BOOL nodelay
= FALSE
;
2419 prop_get( channel
->prop
, channel
->prop_count
, WS_CHANNEL_PROPERTY_NO_DELAY
, &nodelay
, sizeof(nodelay
) );
2420 setsockopt( channel
->u
.tcp
.socket
, IPPROTO_TCP
, TCP_NODELAY
, (const char *)&nodelay
, sizeof(nodelay
) );
2423 LeaveCriticalSection( &channel
->cs
);
2427 static HRESULT
sock_wait( SOCKET socket
, HANDLE wait
, HANDLE cancel
)
2429 HANDLE handles
[] = { wait
, cancel
};
2432 if (WSAEventSelect( socket
, handles
[0], FD_READ
)) return HRESULT_FROM_WIN32( WSAGetLastError() );
2434 switch (WSAWaitForMultipleEvents( 2, handles
, FALSE
, WSA_INFINITE
, FALSE
))
2441 hr
= WS_E_OPERATION_ABORTED
;
2445 hr
= HRESULT_FROM_WIN32( WSAGetLastError() );
2449 WSAEventSelect( socket
, NULL
, 0 );
2450 set_blocking( socket
, TRUE
);
2454 HRESULT
channel_accept_udp( SOCKET socket
, HANDLE wait
, HANDLE cancel
, WS_CHANNEL
*handle
)
2456 struct channel
*channel
= (struct channel
*)handle
;
2459 EnterCriticalSection( &channel
->cs
);
2461 if (channel
->magic
!= CHANNEL_MAGIC
)
2463 LeaveCriticalSection( &channel
->cs
);
2464 return E_INVALIDARG
;
2467 if ((hr
= sock_wait( socket
, wait
, cancel
)) == S_OK
) channel
->u
.udp
.socket
= socket
;
2469 LeaveCriticalSection( &channel
->cs
);
2473 /**************************************************************************
2474 * WsAbortChannel [webservices.@]
2476 HRESULT WINAPI
WsAbortChannel( WS_CHANNEL
*handle
, WS_ERROR
*error
)
2478 FIXME( "%p %p: stub!\n", handle
, error
);