**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Web.Services / System.Web.Services.Description / HttpSimpleProtocolReflector.cs
blob58c18913cf6945937d6d2dda23f140bdd23e3d54
1 //
2 // System.Web.Services.Description.HttpSimpleProtocolReflector.cs
3 //
4 // Author:
5 // Lluis Sanchez Gual (lluis@ximian.com)
6 //
7 // (C) 2003 Ximian, Inc.
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Web.Services;
32 using System.Web.Services.Protocols;
33 using System.Xml.Serialization;
34 using System.Xml;
35 using System.Xml.Schema;
36 using System.Reflection;
38 namespace System.Web.Services.Description {
40 internal abstract class HttpSimpleProtocolReflector : ProtocolReflector
42 #region Fields
44 SoapBinding soapBinding;
46 #endregion // Fields
48 #region Constructors
50 public HttpSimpleProtocolReflector ()
54 #endregion // Constructors
56 #region Methods
58 protected override void BeginClass ()
60 HttpAddressBinding abind = new HttpAddressBinding ();
61 abind.Location = ServiceUrl;
62 Port.Extensions.Add (abind);
65 protected override void EndClass ()
69 protected override bool ReflectMethod ()
71 LogicalTypeInfo ti = TypeStubManager.GetLogicalTypeInfo (ServiceType);
72 HttpOperationBinding sob = new HttpOperationBinding();
73 sob.Location = "/" + MethodStubInfo.Name;
74 OperationBinding.Extensions.Add (sob);
76 if (!Method.IsVoid)
78 MimeXmlBinding mxb = new MimeXmlBinding ();
79 mxb.Part = "Body";
80 OperationBinding.Output.Extensions.Add (mxb);
82 MessagePart part = new MessagePart ();
83 part.Name = "Body";
85 XmlTypeMapping map = ReflectionImporter.ImportTypeMapping (Method.ReturnType, ti.GetWebServiceLiteralNamespace (ServiceDescription.TargetNamespace));
86 XmlQualifiedName qname = new XmlQualifiedName (map.ElementName, map.Namespace);
87 part.Element = qname;
88 OutputMessage.Parts.Add (part);
89 SchemaExporter.ExportTypeMapping (map);
92 XmlReflectionMember[] mems = new XmlReflectionMember [Method.Parameters.Length];
93 for (int n=0; n<Method.Parameters.Length; n++)
95 ParameterInfo param = Method.Parameters [n];
96 XmlReflectionMember mem = new XmlReflectionMember ();
97 mem.MemberName = param.Name;
98 Type ptype = param.ParameterType;
99 if (ptype.IsByRef) ptype = ptype.GetElementType ();
100 mem.MemberType = ptype;
101 mems [n] = mem;
104 XmlMembersMapping memap = ReflectionImporter.ImportMembersMapping ("", ti.WebServiceAbstractNamespace, mems, false);
105 bool allPrimitives = true;
107 for (int n=0; n<memap.Count; n++)
109 XmlMemberMapping mem = memap[n];
110 MessagePart part = new MessagePart ();
111 XmlQualifiedName pqname;
113 if (mem.TypeNamespace == "")
114 pqname = new XmlQualifiedName (mem.TypeName, XmlSchema.Namespace);
115 else {
116 pqname = new XmlQualifiedName (mem.TypeName, mem.TypeNamespace);
117 allPrimitives = false;
120 part.Type = pqname;
121 part.Name = mem.ElementName;
122 InputMessage.Parts.Add (part);
125 if (!allPrimitives)
126 SoapSchemaExporter.ExportMembersMapping (memap);
128 return true;
131 XmlQualifiedName GenerateStringArray ()
133 return null;
136 protected override string ReflectMethodBinding ()
138 return null;
141 #endregion