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/list.h"
29 #include "webservices_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(webservices
);
33 static const struct prop_desc proxy_props
[] =
35 { sizeof(ULONG
), FALSE
, TRUE
}, /* WS_PROXY_PROPERTY_CALL_TIMEOUT */
36 { sizeof(WS_MESSAGE_PROPERTIES
), FALSE
}, /* WS_PROXY_PROPERTY_MESSAGE_PROPERTIES */
37 { sizeof(USHORT
), FALSE
, TRUE
}, /* WS_PROXY_PROPERTY_MAX_CALL_POOL_SIZE */
38 { sizeof(WS_SERVICE_PROXY_STATE
), TRUE
}, /* WS_PROXY_PROPERTY_STATE */
39 { sizeof(ULONG
), FALSE
, TRUE
}, /* WS_PROXY_PROPERTY_MAX_PENDING_CALLS */
40 { sizeof(ULONG
), FALSE
, TRUE
}, /* WS_PROXY_PROPERTY_MAX_CLOSE_TIMEOUT */
41 { sizeof(LANGID
), FALSE
, TRUE
}, /* WS_PROXY_FAULT_LANG_ID */
46 struct channel
*channel
;
48 struct prop prop
[sizeof(proxy_props
)/sizeof(proxy_props
[0])];
51 static struct proxy
*alloc_proxy(void)
53 static const ULONG count
= sizeof(proxy_props
)/sizeof(proxy_props
[0]);
55 ULONG size
= sizeof(*ret
) + prop_size( proxy_props
, count
);
57 if (!(ret
= heap_alloc_zero( size
))) return NULL
;
58 prop_init( proxy_props
, count
, ret
->prop
, &ret
[1] );
59 ret
->prop_count
= count
;
63 static void free_proxy( struct proxy
*proxy
)
65 free_channel( proxy
->channel
);
69 static HRESULT
create_proxy( struct channel
*channel
, const WS_PROXY_PROPERTY
*properties
, ULONG count
,
70 WS_SERVICE_PROXY
**handle
)
76 if (!(proxy
= alloc_proxy())) return E_OUTOFMEMORY
;
78 for (i
= 0; i
< count
; i
++)
80 hr
= prop_set( proxy
->prop
, proxy
->prop_count
, properties
[i
].id
, properties
[i
].value
,
81 properties
[i
].valueSize
);
89 proxy
->channel
= channel
;
91 *handle
= (WS_SERVICE_PROXY
*)proxy
;
95 /**************************************************************************
96 * WsCreateServiceProxy [webservices.@]
98 HRESULT WINAPI
WsCreateServiceProxy( const WS_CHANNEL_TYPE type
, const WS_CHANNEL_BINDING binding
,
99 const WS_SECURITY_DESCRIPTION
*desc
,
100 const WS_PROXY_PROPERTY
*proxy_props
, ULONG proxy_props_count
,
101 const WS_CHANNEL_PROPERTY
*channel_props
,
102 const ULONG channel_props_count
, WS_SERVICE_PROXY
**handle
,
105 struct channel
*channel
;
108 TRACE( "%u %u %p %p %u %p %u %p %p\n", type
, binding
, desc
, proxy_props
, proxy_props_count
,
109 channel_props
, channel_props_count
, handle
, error
);
110 if (error
) FIXME( "ignoring error parameter\n" );
111 if (desc
) FIXME( "ignoring security description\n" );
113 if (!handle
) return E_INVALIDARG
;
115 if ((hr
= create_channel( type
, binding
, channel_props
, channel_props_count
, &channel
)) != S_OK
)
118 if ((hr
= create_proxy( channel
, proxy_props
, proxy_props_count
, handle
)) != S_OK
)
119 free_channel( channel
);
124 /**************************************************************************
125 * WsCreateServiceProxyFromTemplate [webservices.@]
127 HRESULT WINAPI
WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE channel_type
,
128 const WS_PROXY_PROPERTY
*properties
, const ULONG count
,
129 WS_BINDING_TEMPLATE_TYPE type
, void *value
, ULONG size
,
130 const void *desc
, ULONG desc_size
, WS_SERVICE_PROXY
**handle
,
133 const WS_CHANNEL_PROPERTY
*channel_props
= NULL
;
134 ULONG channel_props_count
= 0;
135 WS_CHANNEL_BINDING binding
;
136 struct channel
*channel
;
139 TRACE( "%u %p %u %u %p %u %p %u %p %p\n", channel_type
, properties
, count
, type
, value
, size
, desc
,
140 desc_size
, handle
, error
);
141 if (error
) FIXME( "ignoring error parameter\n" );
143 if (!desc
|| !handle
) return E_INVALIDARG
;
144 FIXME( "ignoring description\n" );
148 case WS_HTTP_BINDING_TEMPLATE_TYPE
:
150 WS_HTTP_BINDING_TEMPLATE
*http
= value
;
153 channel_props
= http
->channelProperties
.properties
;
154 channel_props_count
= http
->channelProperties
.propertyCount
;
156 binding
= WS_HTTP_CHANNEL_BINDING
;
159 case WS_HTTP_SSL_BINDING_TEMPLATE_TYPE
:
161 WS_HTTP_SSL_BINDING_TEMPLATE
*https
= value
;
164 channel_props
= https
->channelProperties
.properties
;
165 channel_props_count
= https
->channelProperties
.propertyCount
;
167 binding
= WS_HTTP_CHANNEL_BINDING
;
171 FIXME( "template type %u not implemented\n", type
);
175 if ((hr
= create_channel( channel_type
, binding
, channel_props
, channel_props_count
, &channel
)) != S_OK
)
178 if ((hr
= create_proxy( channel
, properties
, count
, handle
)) != S_OK
)
179 free_channel( channel
);
184 /**************************************************************************
185 * WsFreeServiceProxy [webservices.@]
187 void WINAPI
WsFreeServiceProxy( WS_SERVICE_PROXY
*handle
)
189 struct proxy
*proxy
= (struct proxy
*)handle
;
191 TRACE( "%p\n", handle
);
195 /**************************************************************************
196 * WsGetServiceProxyProperty [webservices.@]
198 HRESULT WINAPI
WsGetServiceProxyProperty( WS_SERVICE_PROXY
*handle
, WS_PROXY_PROPERTY_ID id
,
199 void *buf
, ULONG size
, WS_ERROR
*error
)
201 struct proxy
*proxy
= (struct proxy
*)handle
;
203 TRACE( "%p %u %p %u %p\n", handle
, id
, buf
, size
, error
);
204 if (error
) FIXME( "ignoring error parameter\n" );
206 return prop_get( proxy
->prop
, proxy
->prop_count
, id
, buf
, size
);
209 /**************************************************************************
210 * WsOpenServiceProxy [webservices.@]
212 HRESULT WINAPI
WsOpenServiceProxy( WS_SERVICE_PROXY
*handle
, const WS_ENDPOINT_ADDRESS
*endpoint
,
213 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
215 struct proxy
*proxy
= (struct proxy
*)handle
;
217 TRACE( "%p %p %p %p\n", handle
, endpoint
, ctx
, error
);
218 if (error
) FIXME( "ignoring error parameter\n" );
219 if (ctx
) FIXME( "ignoring ctx parameter\n" );
221 return open_channel( proxy
->channel
, endpoint
);
224 /**************************************************************************
225 * WsCloseServiceProxy [webservices.@]
227 HRESULT WINAPI
WsCloseServiceProxy( WS_SERVICE_PROXY
*handle
, const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
229 struct proxy
*proxy
= (struct proxy
*)handle
;
231 TRACE( "%p %p %p\n", handle
, ctx
, error
);
232 if (error
) FIXME( "ignoring error parameter\n" );
233 if (ctx
) FIXME( "ignoring ctx parameter\n" );
235 return close_channel( proxy
->channel
);
238 /**************************************************************************
239 * WsCall [webservices.@]
241 HRESULT WINAPI
WsCall( WS_SERVICE_PROXY
*handle
, const WS_OPERATION_DESCRIPTION
*desc
, const void **args
,
242 WS_HEAP
*heap
, const WS_CALL_PROPERTY
*properties
, const ULONG count
,
243 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
245 FIXME( "%p %p %p %p %p %u %p %p\n", handle
, desc
, args
, heap
, properties
, count
, ctx
, error
);