Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Services/Web/Services
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv25743
Modified Files:
WebServiceProxyFactory.cs
Log Message:
Make WebServiceProxyFactory and WebServiceExporter easily customizable.
Index: WebServiceProxyFactory.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Services/Web/Services/WebServiceProxyFactory.cs,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** WebServiceProxyFactory.cs 22 Feb 2008 16:44:38 -0000 1.32
--- WebServiceProxyFactory.cs 24 Feb 2008 19:10:12 -0000 1.33
***************
*** 74,90 ****
#region Fields
! private IObjectDefinition productTemplate;
! private Type webServiceProxyBaseType = typeof(SoapHttpClientProtocol);
! private IResource serviceUri;
! private Type proxyType;
! private Type serviceInterface;
! private NetworkCredential credential;
! private string proxyUrl;
! private NetworkCredential proxyCredential;
! private string bindingName;
private IList _typeAttributes = new ArrayList();
private IDictionary _memberAttributes = new Hashtable();
! private ConstructorInfo proxyConstructor;
#endregion
--- 74,93 ----
#region Fields
! private IObjectDefinition _productTemplate;
! private Type _webServiceProxyBaseType = typeof(SoapHttpClientProtocol);
! private IResource _serviceUri;
! private Type _proxyType;
! private Type _serviceInterface;
! private NetworkCredential _credential;
! private string _proxyUrl;
! private NetworkCredential _proxyCredential;
! private string _bindingName;
private IList _typeAttributes = new ArrayList();
private IDictionary _memberAttributes = new Hashtable();
! /// <summary>
! /// The web service proxy default constructor.
! /// </summary>
! protected ConstructorInfo proxyConstructor;
#endregion
***************
*** 113,118 ****
public Type ClientProtocolType
{
! get { return webServiceProxyBaseType; }
! set { webServiceProxyBaseType = value; }
}
--- 116,121 ----
public Type ClientProtocolType
{
! get { return _webServiceProxyBaseType; }
! set { _webServiceProxyBaseType = value; }
}
***************
*** 125,130 ****
public Type WebServiceProxyBaseType
{
! get { return webServiceProxyBaseType; }
! set { webServiceProxyBaseType = value; }
}
--- 128,133 ----
public Type WebServiceProxyBaseType
{
! get { return _webServiceProxyBaseType; }
! set { _webServiceProxyBaseType = value; }
}
***************
*** 135,140 ****
public IResource ServiceUri
{
! get { return serviceUri; }
! set { serviceUri = value; }
}
--- 138,143 ----
public IResource ServiceUri
{
! get { return _serviceUri; }
! set { _serviceUri = value; }
}
***************
*** 144,149 ****
public Type ProxyType
{
! get { return proxyType; }
! set { proxyType = value; }
}
--- 147,152 ----
public Type ProxyType
{
! get { return _proxyType; }
! set { _proxyType = value; }
}
***************
*** 153,158 ****
public Type ServiceInterface
{
! get { return serviceInterface; }
! set { serviceInterface = value; }
}
--- 156,161 ----
public Type ServiceInterface
{
! get { return _serviceInterface; }
! set { _serviceInterface = value; }
}
***************
*** 163,168 ****
public NetworkCredential Credential
{
! get { return credential; }
! set { credential = value; }
}
--- 166,171 ----
public NetworkCredential Credential
{
! get { return _credential; }
! set { _credential = value; }
}
***************
*** 180,185 ****
public string ProxyUrl
{
! get { return proxyUrl; }
! set { proxyUrl = value; }
}
--- 183,188 ----
public string ProxyUrl
{
! get { return _proxyUrl; }
! set { _proxyUrl = value; }
}
***************
*** 195,200 ****
public NetworkCredential ProxyCredential
{
! get { return proxyCredential; }
! set { proxyCredential = value; }
}
--- 198,203 ----
public NetworkCredential ProxyCredential
{
! get { return _proxyCredential; }
! set { _proxyCredential = value; }
}
***************
*** 204,209 ****
public string BindingName
{
! get { return bindingName; }
! set { bindingName = value; }
}
--- 207,212 ----
public string BindingName
{
! get { return _bindingName; }
! set { _bindingName = value; }
}
***************
*** 273,278 ****
public virtual IObjectDefinition ProductTemplate
{
! get { return productTemplate; }
! set { productTemplate = value; }
}
--- 276,281 ----
public virtual IObjectDefinition ProductTemplate
{
! get { return _productTemplate; }
! set { _productTemplate = value; }
}
***************
*** 293,297 ****
#region Protected Methods
! protected void GenerateProxy()
{
IProxyTypeBuilder builder;
--- 296,326 ----
#region Protected Methods
! /// <summary>
! /// Validates the configuration.
! /// </summary>
! protected virtual void ValidateConfiguration()
! {
! if (ServiceUri == null && ProxyType == null)
! {
! throw new ArgumentException("ServiceUri or ProxyType property is required.");
! }
! if (ServiceInterface == null)
! {
! throw new ArgumentException("The ServiceInterface property is required.");
! }
! if (!ServiceInterface.IsInterface)
! {
! throw new ArgumentException("ServiceInterface must be an interface");
! }
! if (WebServiceProxyBaseType.IsSealed)
! {
! throw new ArgumentException("Web service client proxy cannot be created for a sealed class [" + WebServiceProxyBaseType.FullName + "]");
! }
! }
!
! /// <summary>
! /// Generates the web service proxy type.
! /// </summary>
! protected virtual void GenerateProxy()
{
IProxyTypeBuilder builder;
***************
*** 300,304 ****
// Wrap .NET generated proxy class or another
builder = new WebServiceProxyProxyTypeBuilder();
! builder.TargetType = proxyType;
}
else
--- 329,333 ----
// Wrap .NET generated proxy class or another
builder = new WebServiceProxyProxyTypeBuilder();
! builder.TargetType = ProxyType;
}
else
***************
*** 306,314 ****
// Dynamically generates proxy class from WSDL
builder = new SoapHttpClientProxyTypeBuilder(
! serviceUri, GetWsDocuments(serviceUri), bindingName);
! builder.BaseType = webServiceProxyBaseType;
}
! builder.Interfaces = ReflectionUtils.ToInterfaceArray(serviceInterface);
builder.TypeAttributes = TypeAttributes;
builder.MemberAttributes = MemberAttributes;
--- 335,343 ----
// Dynamically generates proxy class from WSDL
builder = new SoapHttpClientProxyTypeBuilder(
! ServiceUri, GetWsDocuments(ServiceUri), BindingName);
! builder.BaseType = WebServiceProxyBaseType;
}
! builder.Interfaces = ReflectionUtils.ToInterfaceArray(ServiceInterface);
builder.TypeAttributes = TypeAttributes;
builder.MemberAttributes = MemberAttributes;
***************
*** 322,336 ****
if (LOG.IsDebugEnabled)
{
! if (serviceUri != null)
{
LOG.Debug(
String.Format("Generated client proxy type [{0}] for web service [{1}]", wrapper.FullName,
! serviceUri.Description));
}
! else if (proxyType != null)
{
LOG.Debug(
String.Format("Generated client proxy type [{0}] for web service based on provided proxy type [{1}]", wrapper.FullName,
! proxyType.FullName));
}
}
--- 351,365 ----
if (LOG.IsDebugEnabled)
{
! if (ServiceUri != null)
{
LOG.Debug(
String.Format("Generated client proxy type [{0}] for web service [{1}]", wrapper.FullName,
! ServiceUri.Description));
}
! else if (ProxyType != null)
{
LOG.Debug(
String.Format("Generated client proxy type [{0}] for web service based on provided proxy type [{1}]", wrapper.FullName,
! ProxyType.FullName));
}
}
***************
*** 339,361 ****
}
! protected void ValidateConfiguration()
! {
! if (ServiceUri == null && ProxyType == null)
! {
! throw new ArgumentException("ServiceUri or ProxyType property is required.");
! }
! if (ServiceInterface == null)
! {
! throw new ArgumentException("The ServiceInterface property is required.");
! }
! if (!ServiceInterface.IsInterface)
! {
! throw new ArgumentException("ServiceInterface must be an interface");
! }
! if (WebServiceProxyBaseType.IsSealed)
! {
! throw new ArgumentException("Web service client proxy cannot be created for a sealed class [" + WebServiceProxyBaseType.FullName + "]");
! }
! }
/// <summary>
--- 368,374 ----
}
! #endregion
!
! #region Private Methods
/// <summary>
***************
*** 366,371 ****
try
{
! if (serviceUri is UrlResource ||
! serviceUri is FileSystemResource)
{
DiscoveryClientProtocol dcProtocol = new DiscoveryClientProtocol();
--- 379,384 ----
try
{
! if (ServiceUri is UrlResource ||
! ServiceUri is FileSystemResource)
{
DiscoveryClientProtocol dcProtocol = new DiscoveryClientProtocol();
***************
*** 394,402 ****
{
IWebProxy webProxy = null;
! if (proxyUrl != null)
{
! webProxy = new WebProxy(proxyUrl);
}
! if (proxyCredential != null)
{
if (webProxy == null)
--- 407,415 ----
{
IWebProxy webProxy = null;
! if (ProxyUrl != null)
{
! webProxy = new WebProxy(ProxyUrl);
}
! if (ProxyCredential != null)
{
if (webProxy == null)
***************
*** 408,412 ****
#endif
}
! webProxy.Credentials = proxyCredential;
}
--- 421,425 ----
#endif
}
! webProxy.Credentials = ProxyCredential;
}
***************
*** 416,428 ****
private ICredentials CreateCredentials()
{
! if (credential != null)
{
CredentialCache credentialCache = new CredentialCache();
! Uri wsUri = new Uri(serviceUri.Uri.AbsoluteUri.Substring(0, serviceUri.Uri.AbsoluteUri.Length - serviceUri.Uri.AbsolutePath.Length));
IEnumerator enumerator = AuthenticationManager.RegisteredModules;
while (enumerator.MoveNext())
{
! credentialCache.Add(wsUri, ((IAuthenticationModule)enumerator.Current).AuthenticationType, credential);
}
--- 429,441 ----
private ICredentials CreateCredentials()
{
! if (Credential != null)
{
CredentialCache credentialCache = new CredentialCache();
! Uri wsUri = new Uri(ServiceUri.Uri.AbsoluteUri.Substring(0, ServiceUri.Uri.AbsoluteUri.Length - ServiceUri.Uri.AbsolutePath.Length));
IEnumerator enumerator = AuthenticationManager.RegisteredModules;
while (enumerator.MoveNext())
{
! credentialCache.Add(wsUri, ((IAuthenticationModule)enumerator.Current).AuthenticationType, Credential);
}
|