+2006-11-30 Atsushi Enomoto <atsushi@ximian.com>
+
+ * HttpSimpleProtocolReflector.cs : LogicalTypeInfo -> ServerType.
+
2006-11-30 Atsushi Enomoto <atsushi@ximian.com>
* SoapHeaderFaultBinding.cs, NamedItem.cs, SoapBinding.cs,
protected override bool ReflectMethod ()
{
- LogicalTypeInfo ti = TypeStubManager.GetLogicalTypeInfo (ServiceType);
+ ServerType ti = TypeStubManager.GetLogicalTypeInfo (ServiceType);
HttpOperationBinding sob = new HttpOperationBinding();
sob.Location = "/" + MethodStubInfo.Name;
OperationBinding.Extensions.Add (sob);
+2006-11-30 Atsushi Enomoto <atsushi@ximian.com>
+
+ * ServerType.cs : Now LogicalTypeInfo became this type to implement
+ this class (and SoapTypeStubInfo to SoapServerType later).
+ * TypeStubManager.cs : so, split LogicalTypeInfo from here.
+ * XmlReturnReader.cs, XmlReturnWriter.cs, Methods.cs,
+ HttpSimpleTypeStubInfo.cs, HttpGetTypeStubInfo.cs,
+ HttpPostTypeStubInfo.cs : LogicalTypeInfo -> ServerType.
+
2006-11-30 Atsushi Enomoto <atsushi@ximian.com>
* SoapHttpClientProtocol.cs : looks like (only) the last Text is used
internal class HttpGetTypeStubInfo : HttpSimpleTypeStubInfo
{
- public HttpGetTypeStubInfo (LogicalTypeInfo logicalTypeInfo): base (logicalTypeInfo)
+ public HttpGetTypeStubInfo (ServerType logicalTypeInfo): base (logicalTypeInfo)
{
}
internal class HttpPostTypeStubInfo : HttpSimpleTypeStubInfo
{
- public HttpPostTypeStubInfo (LogicalTypeInfo logicalTypeInfo): base (logicalTypeInfo)
+ public HttpPostTypeStubInfo (ServerType logicalTypeInfo): base (logicalTypeInfo)
{
}
internal class HttpSimpleTypeStubInfo : TypeStubInfo
{
- public HttpSimpleTypeStubInfo (LogicalTypeInfo logicalTypeInfo): base (logicalTypeInfo)
+ public HttpSimpleTypeStubInfo (ServerType logicalTypeInfo): base (logicalTypeInfo)
{
}
internal XmlReflectionImporter xmlImporter;
internal SoapReflectionImporter soapImporter;
- public SoapTypeStubInfo (LogicalTypeInfo logicalTypeInfo)
+ public SoapTypeStubInfo (ServerType logicalTypeInfo)
: base (logicalTypeInfo)
{
xmlImporter = new XmlReflectionImporter ();
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-
-#if NET_2_0
+using System.Reflection;
+using System.Web.Services;
+using System.Web.Services.Description;
namespace System.Web.Services.Protocols
{
- public class ServerType
+ //
+ // This class has information abou a web service. Through providess
+ // access to the TypeStubInfo instances for each protocol.
+ //
+#if NET_2_0
+ public
+#else
+ internal
+#endif
+ class ServerType // It was LogicalTypeInfo until Mono 1.2.
{
- public ServerType (Type type)
+ LogicalMethodInfo[] logicalMethods;
+
+ internal string WebServiceName;
+ internal string WebServiceNamespace;
+ internal string WebServiceAbstractNamespace;
+ internal string Description;
+ internal Type Type;
+ bool useEncoded;
+
+ TypeStubInfo soapProtocol;
+ TypeStubInfo httpGetProtocol;
+ TypeStubInfo httpPostProtocol;
+
+ public ServerType (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);
+ }
+ else if (t.GetCustomAttributes (typeof(SoapRpcServiceAttribute), true).Length > 0)
+ useEncoded = true;
+
+ string sep = WebServiceNamespace.EndsWith ("/") ? "" : "/";
+
+ WebServiceAbstractNamespace = WebServiceNamespace + sep + "AbstractTypes";
+
+ MethodInfo [] type_methods = Type.GetMethods (BindingFlags.Instance | BindingFlags.Public);
+ logicalMethods = LogicalMethodInfo.Create (type_methods, LogicalMethodTypes.Sync);
+ }
+
+ internal LogicalMethodInfo[] LogicalMethods
+ {
+ get { return logicalMethods; }
+ }
+
+ internal 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;
+ }
+
+ internal string GetWebServiceLiteralNamespace (string baseNamespace)
+ {
+ if (useEncoded) {
+ string sep = baseNamespace.EndsWith ("/") ? "" : "/";
+ return baseNamespace + sep + "literalTypes";
+ }
+ else
+ return baseNamespace;
+ }
+
+ internal string GetWebServiceEncodedNamespace (string baseNamespace)
+ {
+ if (useEncoded)
+ return baseNamespace;
+ else {
+ string sep = baseNamespace.EndsWith ("/") ? "" : "/";
+ return baseNamespace + sep + "encodedTypes";
+ }
+ }
+
+ internal string GetWebServiceNamespace (string baseNamespace, SoapBindingUse use)
+ {
+ if (use == SoapBindingUse.Literal) return GetWebServiceLiteralNamespace (baseNamespace);
+ else return GetWebServiceEncodedNamespace (baseNamespace);
+ }
+
}
}
-
-#endif
Hashtable name_to_method = new Hashtable ();
MethodStubInfo[] methods;
ArrayList bindings = new ArrayList ();
- LogicalTypeInfo logicalType;
+ ServerType logicalType;
string defaultBinding;
ArrayList mappings;
XmlSerializer[] serializers;
- public TypeStubInfo (LogicalTypeInfo logicalTypeInfo)
+ public TypeStubInfo (ServerType logicalTypeInfo)
{
this.logicalType = logicalTypeInfo;
Bindings.Add (binfo);
}
- public LogicalTypeInfo LogicalType
+ public ServerType LogicalType
{
get { return logicalType; }
}
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);
- }
- 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";
- }
- }
-
- public string GetWebServiceNamespace (string baseNamespace, SoapBindingUse use)
- {
- if (use == SoapBindingUse.Literal) return GetWebServiceLiteralNamespace (baseNamespace);
- else return GetWebServiceEncodedNamespace (baseNamespace);
- }
-
- }
-
//
// Manages type stubs
//
static internal TypeStubInfo GetTypeStub (Type t, string protocolName)
{
- LogicalTypeInfo tm = GetLogicalTypeInfo (t);
+ ServerType tm = GetLogicalTypeInfo (t);
return tm.GetTypeStub (protocolName);
}
//
// This needs to be thread safe
//
- static internal LogicalTypeInfo GetLogicalTypeInfo (Type t)
+ static internal ServerType GetLogicalTypeInfo (Type t)
{
lock (type_to_manager)
{
- LogicalTypeInfo tm = (LogicalTypeInfo) type_to_manager [t];
+ ServerType tm = (ServerType) type_to_manager [t];
if (tm != null)
return tm;
- tm = new LogicalTypeInfo (t);
+ tm = new ServerType (t);
type_to_manager [t] = tm;
return tm;
public override object GetInitializer (LogicalMethodInfo methodInfo)
{
- LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo (methodInfo.DeclaringType);
+ ServerType sti = TypeStubManager.GetLogicalTypeInfo (methodInfo.DeclaringType);
object[] ats = methodInfo.ReturnTypeCustomAttributeProvider.GetCustomAttributes (typeof(XmlRootAttribute), true);
XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;
return new XmlSerializer (methodInfo.ReturnType, null, null, root, sti.GetWebServiceLiteralNamespace (sti.WebServiceNamespace));
sers[n] = null;
else
{
- LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo (metinfo.DeclaringType);
+ ServerType sti = TypeStubManager.GetLogicalTypeInfo (metinfo.DeclaringType);
object[] ats = methodInfos[n].ReturnTypeCustomAttributeProvider.GetCustomAttributes (typeof(XmlRootAttribute), true);
XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;
sers[n] = importer.ImportTypeMapping (methodInfos[n].ReturnType, root, sti.GetWebServiceLiteralNamespace (sti.WebServiceNamespace));
public override object GetInitializer (LogicalMethodInfo methodInfo)
{
- LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo (methodInfo.DeclaringType);
+ ServerType sti = TypeStubManager.GetLogicalTypeInfo (methodInfo.DeclaringType);
object[] ats = methodInfo.ReturnTypeCustomAttributeProvider.GetCustomAttributes (typeof(XmlRootAttribute), true);
XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;
else
{
importer.IncludeTypes (metinfo.CustomAttributeProvider);
- LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo (metinfo.DeclaringType);
+ ServerType sti = TypeStubManager.GetLogicalTypeInfo (metinfo.DeclaringType);
object[] ats = methodInfos[n].ReturnTypeCustomAttributeProvider.GetCustomAttributes (typeof(XmlRootAttribute), true);
XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;
sers[n] = importer.ImportTypeMapping (methodInfos[n].ReturnType, root, sti.GetWebServiceLiteralNamespace (sti.WebServiceNamespace));