Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
9.8 KiB

  1. using System;
  2. using System.IO;
  3. using System.Web;
  4. using System.Xml;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Collections;
  8. using System.Web.Services;
  9. using System.Xml.Serialization;
  10. using System.Web.Services.Protocols;
  11. using UDDI.API;
  12. using UDDI;
  13. using UDDI.Diagnostics;
  14. using UDDI.API.Authentication;
  15. using UDDI.API.Binding;
  16. using UDDI.API.Service;
  17. using UDDI.API.Business;
  18. using UDDI.API.ServiceType;
  19. namespace UDDI.API
  20. {
  21. /// ****************************************************************
  22. /// class InquireMessages
  23. /// ----------------------------------------------------------------
  24. /// <summary>
  25. /// This is the web service class that contains the UDDI inquire
  26. /// methods.
  27. /// </summary>
  28. /// ****************************************************************
  29. ///
  30. [SoapDocumentService( ParameterStyle=SoapParameterStyle.Bare, RoutingStyle=SoapServiceRoutingStyle.RequestElement )]
  31. [WebService( Namespace=UDDI.API.Constants.Namespace )]
  32. public class InquireMessages
  33. {
  34. /// ****************************************************************
  35. /// public FindBinding
  36. /// ----------------------------------------------------------------
  37. /// <summary>
  38. /// Locates qualified bindingTemplates based on the criteria
  39. /// specified in the message content.
  40. /// </summary>
  41. /// ----------------------------------------------------------------
  42. /// <param name="fbind">
  43. /// A properly formed instance of the find_binding message.
  44. /// </param>
  45. /// ----------------------------------------------------------------
  46. /// <returns>
  47. /// Returns a list of bindingTemplates contained in a BindingDetail element.
  48. /// </returns>
  49. /// ****************************************************************
  50. ///
  51. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="find_binding")]
  52. [UDDIExtension(messageType="find_binding")]
  53. public BindingDetail FindBinding( FindBinding fbind )
  54. {
  55. Debug.Enter();
  56. BindingDetail bd = null;
  57. try
  58. {
  59. bd = fbind.Find();
  60. }
  61. catch( Exception e )
  62. {
  63. DispositionReport.Throw( e );
  64. }
  65. return bd;
  66. }
  67. /// ****************************************************************
  68. /// public FindBusiness
  69. /// ----------------------------------------------------------------
  70. /// <summary>
  71. /// Locates qualified businessEntities based on the criteria
  72. /// specified in the message content.
  73. /// </summary>
  74. /// ----------------------------------------------------------------
  75. /// <param name="fbind">
  76. /// A properly formed instance of the find_business message.
  77. /// </param>
  78. /// ----------------------------------------------------------------
  79. /// <returns>
  80. /// Returns a list of businessInfo structures contained in a BusinessList.
  81. /// </returns>
  82. /// ****************************************************************
  83. ///
  84. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="find_business")]
  85. [UDDIExtension(messageType="find_business")]
  86. //public BusinessList FindBusiness( FindBusiness fbus, [XmlAnyElement] XmlElement[] trash )
  87. public BusinessList FindBusiness( FindBusiness fbus )
  88. {
  89. Debug.Enter();
  90. BusinessList bl = null;
  91. try
  92. {
  93. bl = fbus.Find();
  94. //
  95. // If this request came from a v1 message, filter out any service projections in our list of
  96. // businesses
  97. //
  98. if( 1 == Context.ApiVersionMajor )
  99. {
  100. foreach( BusinessInfo businessInfo in bl.BusinessInfos )
  101. {
  102. businessInfo.ServiceInfos = FilterServiceProjections( businessInfo.ServiceInfos, businessInfo.BusinessKey );
  103. }
  104. }
  105. }
  106. catch( Exception e )
  107. {
  108. DispositionReport.Throw( e );
  109. }
  110. return bl;
  111. }
  112. /// ****************************************************************
  113. /// public FindRelatedBusinesses
  114. /// ----------------------------------------------------------------
  115. /// <summary>
  116. /// Locates qualified businessEntities based on the criteria
  117. /// specified in the message content.
  118. /// </summary>
  119. /// ----------------------------------------------------------------
  120. /// <param name="fbind">
  121. /// A properly formed instance of the find_business message.
  122. /// </param>
  123. /// ----------------------------------------------------------------
  124. /// <returns>
  125. /// Returns a list of businessInfo structures contained in a BusinessList.
  126. /// </returns>
  127. /// ****************************************************************
  128. ///
  129. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="find_relatedBusinesses")]
  130. [UDDIExtension(messageType="find_relatedBusinesses")]
  131. public RelatedBusinessList FindRelatedBusinesses( FindRelatedBusinesses frelbus )
  132. {
  133. Debug.Enter();
  134. RelatedBusinessList rbl = null;
  135. try
  136. {
  137. rbl = frelbus.Find();
  138. }
  139. catch( Exception e )
  140. {
  141. DispositionReport.Throw( e );
  142. }
  143. return rbl;
  144. }
  145. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="find_service")]
  146. [UDDIExtension(messageType="find_service")]
  147. public ServiceList FindService( FindService fs )
  148. {
  149. Debug.Enter();
  150. ServiceList sl = null;
  151. try
  152. {
  153. sl = fs.Find();
  154. //
  155. // Maybe we could filter service projections out earlier, but this seems to be the
  156. // most readable place to do it.
  157. //
  158. if( 1 == Context.ApiVersionMajor )
  159. {
  160. sl.ServiceInfos = FilterServiceProjections( sl.ServiceInfos, fs.BusinessKey );
  161. }
  162. }
  163. catch( Exception e )
  164. {
  165. DispositionReport.Throw( e );
  166. }
  167. return sl;
  168. }
  169. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="find_tModel")]
  170. [UDDIExtension(messageType="find_tModel")]
  171. public TModelList FindTModel( UDDI.API.ServiceType.FindTModel ftm )
  172. {
  173. Debug.Enter();
  174. TModelList tml = null;
  175. try
  176. {
  177. tml = ftm.Find();
  178. }
  179. catch( Exception e )
  180. {
  181. DispositionReport.Throw( e );
  182. }
  183. Debug.Leave();
  184. return tml;
  185. }
  186. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="get_bindingDetail")]
  187. [UDDIExtension(messageType="get_bindingDetail")]
  188. public BindingDetail GetBindingDetail( GetBindingDetail gbd )
  189. {
  190. Debug.Enter();
  191. BindingDetail bd = new BindingDetail();
  192. try
  193. {
  194. bd.Get( gbd.BindingKeys );
  195. }
  196. catch( Exception e )
  197. {
  198. DispositionReport.Throw( e );
  199. }
  200. return bd;
  201. }
  202. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="get_businessDetail")]
  203. [UDDIExtension(messageType="get_businessDetail")]
  204. public BusinessDetail GetBusinessDetail( GetBusinessDetail gbd )
  205. {
  206. Debug.Enter();
  207. BusinessDetail bd = new BusinessDetail();
  208. try
  209. {
  210. bd.Get( gbd.BusinessKeys );
  211. }
  212. catch( Exception e )
  213. {
  214. DispositionReport.Throw( e );
  215. }
  216. return bd;
  217. }
  218. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="get_businessDetailExt")]
  219. [UDDIExtension(messageType="get_businessDetailExt")]
  220. public BusinessDetailExt GetBusinessDetailExt( GetBusinessDetailExt gbde )
  221. {
  222. Debug.Enter();
  223. BusinessDetailExt bde = new BusinessDetailExt();
  224. try
  225. {
  226. bde.Get( gbde.BusinessKeys );
  227. }
  228. catch( Exception e )
  229. {
  230. DispositionReport.Throw( e );
  231. }
  232. return bde;
  233. }
  234. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="get_serviceDetail")]
  235. [UDDIExtension(messageType="get_serviceDetail")]
  236. public ServiceDetail GetServiceDetail( GetServiceDetail gsd )
  237. {
  238. Debug.Enter();
  239. ServiceDetail sd = new ServiceDetail();
  240. try
  241. {
  242. sd.Get( gsd.ServiceKeys );
  243. }
  244. catch( Exception e )
  245. {
  246. DispositionReport.Throw( e );
  247. }
  248. return sd;
  249. }
  250. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="get_tModelDetail")]
  251. [UDDIExtension(messageType="get_tModelDetail")]
  252. public TModelDetail GetTModelDetail( GetTModelDetail gtmd )
  253. {
  254. Debug.Enter();
  255. TModelDetail tmd = new TModelDetail();
  256. try
  257. {
  258. tmd.Get( gtmd.TModelKeys );
  259. }
  260. catch( Exception e )
  261. {
  262. DispositionReport.Throw( e );
  263. }
  264. return tmd;
  265. }
  266. [WebMethod, SoapDocumentMethod(Action="\"\"", RequestElementName="validate_categorization")]
  267. [UDDIExtension(messageType="validate_categorization")]
  268. public DispositionReport ValidateCategorization( ValidateCategorization vc )
  269. {
  270. Debug.Enter();
  271. try
  272. {
  273. vc.Validate();
  274. }
  275. catch( Exception e )
  276. {
  277. DispositionReport.Throw( e );
  278. }
  279. return new DispositionReport();
  280. }
  281. private ServiceInfoCollection FilterServiceProjections( ServiceInfoCollection serviceInfos, string businessKey )
  282. {
  283. //
  284. // If we are given an empty businessKey, just return the original collection. Without a businessKey, there is
  285. // no way to determine if these services are service projections or not.
  286. //
  287. if( null == businessKey || 0 == businessKey.Length )
  288. {
  289. return serviceInfos;
  290. }
  291. //
  292. // Make a copy because manipulating the collection as you iterate over it is not a good idea. Accessing
  293. // a collection by index and removing items is probably very slow. Since we don't know how this collection
  294. // is implemented, making a copy and populating it is probably the safest thing to do from a performance standpoint.
  295. //
  296. ServiceInfoCollection filteredCollection = new ServiceInfoCollection();
  297. foreach( ServiceInfo serviceInfo in serviceInfos )
  298. {
  299. //
  300. // If these business keys are equal, it is not a service projection, so
  301. // add it to our filtered list, otherwise, don't add it.
  302. //
  303. if( true == serviceInfo.BusinessKey.Equals( businessKey ) )
  304. {
  305. filteredCollection.Add( serviceInfo );
  306. }
  307. }
  308. return filteredCollection;
  309. }
  310. }
  311. }