// Holds the metadata loaded from the type stub, as well as
// the metadata for all the methods in the type
//
- internal class TypeStubInfo
+ internal abstract class TypeStubInfo
{
Hashtable name_to_method = new Hashtable ();
MethodStubInfo[] methods;
{
this.logicalType = logicalTypeInfo;
- defaultBinding = logicalType.WebServiceName + ProtocolName;
- BindingInfo binfo = new BindingInfo (defaultBinding, logicalType.WebServiceNamespace);
- Bindings.Add (binfo);
+ object [] o = Type.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);
+
+ bool isClientSide = typeof (SoapHttpClientProtocol).IsAssignableFrom (Type);
+ bool defaultAdded = false;
+
+ string defaultBindingName = logicalType.WebServiceName + ProtocolName;
+ if (o.Length > 0)
+ foreach (WebServiceBindingAttribute at in o) {
+ AddBinding (new BindingInfo (at, defaultBindingName, LogicalType.WebServiceNamespace));
+ if ((at.Name == null || at.Name.Length == 0) || (at.Name == defaultBindingName))
+ defaultAdded = true;
+ }
+
+ if (!defaultAdded && !isClientSide)
+ AddBindingAt (0, new BindingInfo (null, defaultBindingName, logicalType.WebServiceNamespace));
+
+ foreach (Type ifaceType in Type.GetInterfaces ()) {
+ o = ifaceType.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);
+ if (o.Length > 0) {
+ defaultBindingName = ifaceType.Name + ProtocolName;
+ foreach (WebServiceBindingAttribute at in o)
+ AddBinding (new BindingInfo (at, defaultBindingName, LogicalType.WebServiceNamespace));
+ }
+ }
+ }
+
+ public WsiProfiles WsiClaims {
+ get {
+ return (((BindingInfo) Bindings [0]).WebServiceBindingAttribute != null) ?
+ ((BindingInfo) Bindings [0]).WebServiceBindingAttribute.ConformsTo : WsiProfiles.None;
+ }
}
public LogicalTypeInfo LogicalType
methods = (MethodStubInfo[]) metStubs.ToArray (typeof (MethodStubInfo));
}
- protected virtual MethodStubInfo CreateMethodStubInfo (TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy)
- {
- return new MethodStubInfo (typeInfo, methodInfo);
- }
+ protected abstract MethodStubInfo CreateMethodStubInfo (TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy);
public MethodStubInfo GetMethod (string name)
{
{
bindings.Add (info);
}
+
+ internal void AddBindingAt (int pos, BindingInfo info)
+ {
+ bindings.Insert (pos, info);
+ }
internal BindingInfo GetBinding (string name)
{
if (name == null || name.Length == 0) return (BindingInfo) bindings[0];
- for (int n=1; n<bindings.Count; n++)
+ for (int n = 0; n < bindings.Count; n++)
if (((BindingInfo)bindings[n]).Name == name) return (BindingInfo)bindings[n];
return null;
}
internal class BindingInfo
{
- public BindingInfo (WebServiceBindingAttribute at, string ns)
+ public BindingInfo (WebServiceBindingAttribute at, string name, string ns)
{
- Name = at.Name;
- Namespace = at.Namespace;
- if (Namespace == "") Namespace = ns;
- Location = at.Location;
- }
-
- public BindingInfo (string name, string ns)
- {
- Name = name;
- Namespace = ns;
- }
-
- public string Name;
- public string Namespace;
- public string Location;
- }
-
-
- //
- // This class has information abou a web service. Through providess
- // access to the TypeStubInfo instances for each protocol.
- //
- internal class LogicalTypeInfo
- {
- LogicalMethodInfo[] logicalMethods;
-
- internal string WebServiceName;
- internal string WebServiceNamespace;
- string WebServiceLiteralNamespace;
- string WebServiceEncodedNamespace;
- internal string WebServiceAbstractNamespace;
- internal string Description;
- internal Type Type;
- bool useEncoded;
-
- TypeStubInfo soapProtocol;
- TypeStubInfo httpGetProtocol;
- TypeStubInfo httpPostProtocol;
-
- public LogicalTypeInfo (Type t)
- {
- this.Type = t;
-
- object [] o = Type.GetCustomAttributes (typeof (WebServiceAttribute), false);
- if (o.Length == 1){
- WebServiceAttribute a = (WebServiceAttribute) o [0];
- WebServiceName = (a.Name != string.Empty) ? a.Name : Type.Name;
- WebServiceNamespace = (a.Namespace != string.Empty) ? a.Namespace : WebServiceAttribute.DefaultNamespace;
- Description = a.Description;
- } else {
- WebServiceName = Type.Name;
- WebServiceNamespace = WebServiceAttribute.DefaultNamespace;
- }
-
- // Determine the namespaces for literal and encoded schema types
-
- useEncoded = false;
-
- o = t.GetCustomAttributes (typeof(SoapDocumentServiceAttribute), true);
- if (o.Length > 0) {
- SoapDocumentServiceAttribute at = (SoapDocumentServiceAttribute) o[0];
- useEncoded = (at.Use == SoapBindingUse.Encoded);
+ if (at != null) {
+ Name = at.Name;
+ Namespace = at.Namespace;
+ Location = at.Location;
+ WebServiceBindingAttribute = at;
}
- else if (t.GetCustomAttributes (typeof(SoapRpcServiceAttribute), true).Length > 0)
- useEncoded = true;
-
- string sep = WebServiceNamespace.EndsWith ("/") ? "" : "/";
-
- if (useEncoded) {
- WebServiceEncodedNamespace = WebServiceNamespace;
- WebServiceLiteralNamespace = WebServiceNamespace + sep + "literalTypes";
- }
- else {
- WebServiceEncodedNamespace = WebServiceNamespace + sep + "encodedTypes";
- WebServiceLiteralNamespace = WebServiceNamespace;
- }
-
- WebServiceAbstractNamespace = WebServiceNamespace + sep + "AbstractTypes";
-
- MethodInfo [] type_methods = Type.GetMethods (BindingFlags.Instance | BindingFlags.Public);
- logicalMethods = LogicalMethodInfo.Create (type_methods, LogicalMethodTypes.Sync);
- }
-
- public LogicalMethodInfo[] LogicalMethods
- {
- get { return logicalMethods; }
- }
-
- public TypeStubInfo GetTypeStub (string protocolName)
- {
- lock (this)
- {
- switch (protocolName)
- {
- case "Soap":
- if (soapProtocol == null) soapProtocol = CreateTypeStubInfo (typeof(SoapTypeStubInfo));
- return soapProtocol;
- case "HttpGet":
- if (httpGetProtocol == null) httpGetProtocol = CreateTypeStubInfo (typeof(HttpGetTypeStubInfo));
- return httpGetProtocol;
- case "HttpPost":
- if (httpPostProtocol == null) httpPostProtocol = CreateTypeStubInfo (typeof(HttpPostTypeStubInfo));
- return httpPostProtocol;
- }
- }
- throw new InvalidOperationException ("Protocol " + protocolName + " not supported");
- }
-
- TypeStubInfo CreateTypeStubInfo (Type type)
- {
- TypeStubInfo tsi = (TypeStubInfo) Activator.CreateInstance (type, new object[] {this});
- tsi.Initialize ();
- return tsi;
- }
-
- public string GetWebServiceLiteralNamespace (string baseNamespace)
- {
- if (useEncoded) {
- string sep = baseNamespace.EndsWith ("/") ? "" : "/";
- return baseNamespace + sep + "literalTypes";
- }
- else
- return baseNamespace;
- }
- public string GetWebServiceEncodedNamespace (string baseNamespace)
- {
- if (useEncoded)
- return baseNamespace;
- else {
- string sep = baseNamespace.EndsWith ("/") ? "" : "/";
- return baseNamespace + sep + "encodedTypes";
- }
- }
+ if (Name == null || Name.Length == 0)
+ Name = name;
- public string GetWebServiceNamespace (string baseNamespace, SoapBindingUse use)
- {
- if (use == SoapBindingUse.Literal) return GetWebServiceLiteralNamespace (baseNamespace);
- else return GetWebServiceEncodedNamespace (baseNamespace);
+ if (Namespace == null || Namespace.Length == 0)
+ Namespace = ns;
}
+ public readonly string Name;
+ public readonly string Namespace;
+ public readonly string Location;
+ public readonly WebServiceBindingAttribute WebServiceBindingAttribute;
}
//
//
internal class TypeStubManager
{
-#if !TARGET_JVM
static Hashtable type_to_manager;
-#else
- const string type_to_manager_key = "TypeStubManager.type_to_manager";
- static Hashtable type_to_manager {
- get {
- Hashtable hash = (Hashtable)AppDomain.CurrentDomain.GetData(type_to_manager_key);
-
- if (hash != null)
- return hash;
-
- lock(type_to_manager_key) {
- AppDomain.CurrentDomain.SetData(type_to_manager_key, new Hashtable());
- }
-
- return (Hashtable)AppDomain.CurrentDomain.GetData(type_to_manager_key);
- }
- set {
- //do nothing: we manage our type_to_manager per domain
- }
- }
-#endif
static TypeStubManager ()
{