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 */
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
)
66 WsFreeChannel( proxy
->channel
);
70 static HRESULT
create_proxy( WS_CHANNEL
*channel
, const WS_PROXY_PROPERTY
*properties
, ULONG count
,
71 WS_SERVICE_PROXY
**handle
)
77 if (!(proxy
= alloc_proxy())) return E_OUTOFMEMORY
;
79 for (i
= 0; i
< count
; i
++)
81 hr
= prop_set( proxy
->prop
, proxy
->prop_count
, properties
[i
].id
, properties
[i
].value
,
82 properties
[i
].valueSize
);
90 proxy
->channel
= channel
;
92 *handle
= (WS_SERVICE_PROXY
*)proxy
;
96 /**************************************************************************
97 * WsCreateServiceProxy [webservices.@]
99 HRESULT WINAPI
WsCreateServiceProxy( const WS_CHANNEL_TYPE type
, const WS_CHANNEL_BINDING binding
,
100 const WS_SECURITY_DESCRIPTION
*desc
,
101 const WS_PROXY_PROPERTY
*proxy_props
, ULONG proxy_props_count
,
102 const WS_CHANNEL_PROPERTY
*channel_props
,
103 const ULONG channel_props_count
, WS_SERVICE_PROXY
**handle
,
109 TRACE( "%u %u %p %p %u %p %u %p %p\n", type
, binding
, desc
, proxy_props
, proxy_props_count
,
110 channel_props
, channel_props_count
, handle
, error
);
111 if (error
) FIXME( "ignoring error parameter\n" );
112 if (desc
) FIXME( "ignoring security description\n" );
114 if (!handle
) return E_INVALIDARG
;
116 if ((hr
= WsCreateChannel( type
, binding
, channel_props
, channel_props_count
, NULL
, &channel
,
117 NULL
)) != S_OK
) return hr
;
119 if ((hr
= create_proxy( channel
, proxy_props
, proxy_props_count
, handle
)) != S_OK
)
120 WsFreeChannel( channel
);
125 /**************************************************************************
126 * WsCreateServiceProxyFromTemplate [webservices.@]
128 HRESULT WINAPI
WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE channel_type
,
129 const WS_PROXY_PROPERTY
*properties
, const ULONG count
,
130 WS_BINDING_TEMPLATE_TYPE type
, void *value
, ULONG size
,
131 const void *desc
, ULONG desc_size
, WS_SERVICE_PROXY
**handle
,
134 const WS_CHANNEL_PROPERTY
*channel_props
= NULL
;
135 ULONG channel_props_count
= 0;
136 WS_CHANNEL_BINDING binding
;
140 TRACE( "%u %p %u %u %p %u %p %u %p %p\n", channel_type
, properties
, count
, type
, value
, size
, desc
,
141 desc_size
, handle
, error
);
142 if (error
) FIXME( "ignoring error parameter\n" );
144 if (!desc
|| !handle
) return E_INVALIDARG
;
145 FIXME( "ignoring description\n" );
149 case WS_HTTP_BINDING_TEMPLATE_TYPE
:
151 WS_HTTP_BINDING_TEMPLATE
*http
= value
;
154 channel_props
= http
->channelProperties
.properties
;
155 channel_props_count
= http
->channelProperties
.propertyCount
;
157 binding
= WS_HTTP_CHANNEL_BINDING
;
160 case WS_HTTP_SSL_BINDING_TEMPLATE_TYPE
:
162 WS_HTTP_SSL_BINDING_TEMPLATE
*https
= value
;
165 channel_props
= https
->channelProperties
.properties
;
166 channel_props_count
= https
->channelProperties
.propertyCount
;
168 binding
= WS_HTTP_CHANNEL_BINDING
;
172 FIXME( "template type %u not implemented\n", type
);
176 if ((hr
= WsCreateChannel( channel_type
, binding
, channel_props
, channel_props_count
, NULL
,
177 &channel
, NULL
)) != S_OK
) return hr
;
179 if ((hr
= create_proxy( channel
, properties
, count
, handle
)) != S_OK
) WsFreeChannel( channel
);
183 /**************************************************************************
184 * WsFreeServiceProxy [webservices.@]
186 void WINAPI
WsFreeServiceProxy( WS_SERVICE_PROXY
*handle
)
188 struct proxy
*proxy
= (struct proxy
*)handle
;
190 TRACE( "%p\n", handle
);
194 /**************************************************************************
195 * WsGetServiceProxyProperty [webservices.@]
197 HRESULT WINAPI
WsGetServiceProxyProperty( WS_SERVICE_PROXY
*handle
, WS_PROXY_PROPERTY_ID id
,
198 void *buf
, ULONG size
, WS_ERROR
*error
)
200 struct proxy
*proxy
= (struct proxy
*)handle
;
202 TRACE( "%p %u %p %u %p\n", handle
, id
, buf
, size
, error
);
203 if (error
) FIXME( "ignoring error parameter\n" );
205 return prop_get( proxy
->prop
, proxy
->prop_count
, id
, buf
, size
);
208 /**************************************************************************
209 * WsOpenServiceProxy [webservices.@]
211 HRESULT WINAPI
WsOpenServiceProxy( WS_SERVICE_PROXY
*handle
, const WS_ENDPOINT_ADDRESS
*endpoint
,
212 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
214 struct proxy
*proxy
= (struct proxy
*)handle
;
216 TRACE( "%p %p %p %p\n", handle
, endpoint
, ctx
, error
);
217 if (error
) FIXME( "ignoring error parameter\n" );
218 if (ctx
) FIXME( "ignoring ctx parameter\n" );
220 if (!handle
|| !endpoint
) return E_INVALIDARG
;
221 return WsOpenChannel( proxy
->channel
, endpoint
, NULL
, NULL
);
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 if (!handle
) return E_INVALIDARG
;
236 return WsCloseChannel( proxy
->channel
, NULL
, NULL
);
239 /**************************************************************************
240 * WsAbortServiceProxy [webservices.@]
242 HRESULT WINAPI
WsAbortServiceProxy( WS_SERVICE_PROXY
*handle
, WS_ERROR
*error
)
244 FIXME( "%p %p\n", handle
, error
);
248 /**************************************************************************
249 * WsCall [webservices.@]
251 HRESULT WINAPI
WsCall( WS_SERVICE_PROXY
*handle
, const WS_OPERATION_DESCRIPTION
*desc
, const void **args
,
252 WS_HEAP
*heap
, const WS_CALL_PROPERTY
*properties
, const ULONG count
,
253 const WS_ASYNC_CONTEXT
*ctx
, WS_ERROR
*error
)
255 FIXME( "%p %p %p %p %p %u %p %p\n", handle
, desc
, args
, heap
, properties
, count
, ctx
, error
);