+2006-12-15 Atsushi Enomoto <atsushi@ximian.com>
+
+ * SoapExtensionReflector.cs, SoapProtocolReflector.cs :
+ Now SOAP bindings are reflected through extension reflectors.
+ Added implementations for SOAP 1.1 and SOAP 1.2 (2.0 only).
+ The common SoapBindingExtensionReflector implements reflector
+ methods which used to be in SoapProtocolReflector. Also
+ subclassed SoapProtocolReflector to switch SOAP 1.1 and 1.2.
+ * ServiceDescriptionReflector.cs : under 2.0, use
+ Soap12ProtocolReflector and export soap12 bindings as well.
+ * ProtocolImporter.cs : under 2.0 profile, handle SOAP 1.2 encoding
+ namespace (http://www.w3.org/2003/05/soap-encoding) as well.
+ * ProtocolReflector.cs : call ReflectDescription(). Added FIXME.
+
2006-12-15 Atsushi Enomoto <atsushi@ximian.com>
* ProtocolReflector.cs, SoapExtensionReflector.cs : added
foreach (XmlSchemaObject ob in sc.Includes)
{
XmlSchemaImport import = ob as XmlSchemaImport;
- if (import != null && import.Namespace == SoapProtocolReflector.EncodingNamespace) return true;
+ if (import == null)
+ continue;
+#if NET_2_0
+ if (import.Namespace == Soap11BindingExtensionReflector.EncodingNamespace
+ || import.Namespace == Soap12BindingExtensionReflector.EncodingNamespace)
+#else
+ if (import.Namespace == Soap11BindingExtensionReflector.EncodingNamespace)
+#endif
+ return true;
}
return false;
}
portType.Name = binding.Name;
BeginClass ();
-#if NET_2_0
+
foreach (SoapExtensionReflector reflector in extensionReflectors)
{
reflector.ReflectionContext = this;
reflector.ReflectDescription ();
}
-#endif
foreach (MethodStubInfo method in typeInfo.Methods)
{
operation = new Operation ();
operation.Name = method.OperationName;
operation.Documentation = method.MethodAttribute.Description;
-
+
+ // FIXME: SOAP 1.1 and SOAP 1.2 should share
+ // the same message definitions.
+
inputMessage = new Message ();
inputMessage.Name = method.Name + ProtocolName + "In";
ServiceDescription.Messages.Add (inputMessage);
XmlSchemaExporter schemaExporter = new XmlSchemaExporter (Schemas);
SoapSchemaExporter soapSchemaExporter = new SoapSchemaExporter (Schemas);
- new SoapProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
-
+ new Soap11ProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
+#if NET_2_0
+ new Soap12ProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
+#endif
if (WSConfig.IsSupported (WSProtocol.HttpGet))
new HttpGetProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Web.Services.Protocols;
+using System.Xml;
+
namespace System.Web.Services.Description {
public abstract class SoapExtensionReflector {
#region Methods
#if NET_2_0
- public virtual void ReflectDescription ()
+ public
+#else
+ internal
+#endif
+ virtual void ReflectDescription ()
{
}
-#endif
public abstract void ReflectMethod ();
#endregion
}
+
+ abstract class SoapBindingExtensionReflector : SoapExtensionReflector
+ {
+ public abstract SoapBinding CreateSoapBinding ();
+ public abstract SoapAddressBinding CreateSoapAddressBinding ();
+ public abstract SoapOperationBinding CreateSoapOperationBinding ();
+ public abstract SoapHeaderBinding CreateSoapHeaderBinding ();
+ public abstract SoapBodyBinding CreateSoapBodyBinding ();
+ public abstract string EncodingNS { get; }
+
+#if NET_2_0
+ public
+#else
+ internal
+#endif
+ override void ReflectDescription ()
+ {
+ SoapBinding sb = CreateSoapBinding ();
+ sb.Transport = SoapBinding.HttpTransport;
+ sb.Style = ((SoapTypeStubInfo) ReflectionContext.TypeInfo).SoapBindingStyle;
+ ReflectionContext.Binding.Extensions.Add (sb);
+
+ SoapAddressBinding abind = CreateSoapAddressBinding ();
+ abind.Location = ReflectionContext.ServiceUrl;
+ ReflectionContext.Port.Extensions.Add (abind);
+ }
+
+ public override void ReflectMethod ()
+ {
+ SoapMethodStubInfo method = (SoapMethodStubInfo) ReflectionContext.MethodStubInfo;
+
+ SoapOperationBinding sob = CreateSoapOperationBinding ();
+
+ sob.SoapAction = method.Action;
+ sob.Style = method.SoapBindingStyle;
+ ReflectionContext.OperationBinding.Extensions.Add (sob);
+
+ AddOperationMsgBindings (method, ReflectionContext.OperationBinding.Input);
+ AddOperationMsgBindings (method, ReflectionContext.OperationBinding.Output);
+
+ foreach (SoapHeaderMapping hf in method.Headers) {
+ if (hf.Custom) continue;
+
+ SoapHeaderBinding hb = CreateSoapHeaderBinding ();
+ hb.Message = new XmlQualifiedName (ReflectionContext.Operation.Name + hf.HeaderType.Name, ReflectionContext.ServiceDescription.TargetNamespace);
+ hb.Part = hf.HeaderType.Name;
+ hb.Use = method.Use;
+
+ if (method.Use != SoapBindingUse.Literal)
+ hb.Encoding = EncodingNS;
+
+ if ((hf.Direction & SoapHeaderDirection.Out) != 0)
+ ReflectionContext.OperationBinding.Output.Extensions.Add (hb);
+ if ((hf.Direction & SoapHeaderDirection.In) != 0)
+ ReflectionContext.OperationBinding.Input.Extensions.Add (hb);
+ }
+ }
+
+ void AddOperationMsgBindings (SoapMethodStubInfo method, MessageBinding msg)
+ {
+ SoapBodyBinding sbbo = CreateSoapBodyBinding ();
+ msg.Extensions.Add (sbbo);
+ sbbo.Use = method.Use;
+ if (method.Use == SoapBindingUse.Encoded) {
+ sbbo.Namespace = ReflectionContext.ServiceDescription.TargetNamespace;
+ sbbo.Encoding = EncodingNS;
+ }
+ }
+ }
+
+ class Soap11BindingExtensionReflector : SoapBindingExtensionReflector
+ {
+ public override SoapBinding CreateSoapBinding ()
+ {
+ return new SoapBinding ();
+ }
+ public override SoapAddressBinding CreateSoapAddressBinding ()
+ {
+ return new SoapAddressBinding ();
+ }
+ public override SoapOperationBinding CreateSoapOperationBinding ()
+ {
+ return new SoapOperationBinding ();
+ }
+ public override SoapHeaderBinding CreateSoapHeaderBinding ()
+ {
+ return new SoapHeaderBinding ();
+ }
+ public override SoapBodyBinding CreateSoapBodyBinding ()
+ {
+ return new SoapBodyBinding ();
+ }
+
+ public override string EncodingNS {
+ get { return EncodingNamespace; }
+ }
+
+ public const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
+ }
+
+#if NET_2_0
+ class Soap12BindingExtensionReflector : SoapBindingExtensionReflector
+ {
+ public override SoapBinding CreateSoapBinding ()
+ {
+ return new Soap12Binding ();
+ }
+ public override SoapAddressBinding CreateSoapAddressBinding ()
+ {
+ return new Soap12AddressBinding ();
+ }
+ public override SoapOperationBinding CreateSoapOperationBinding ()
+ {
+ return new Soap12OperationBinding ();
+ }
+ public override SoapHeaderBinding CreateSoapHeaderBinding ()
+ {
+ return new Soap12HeaderBinding ();
+ }
+ public override SoapBodyBinding CreateSoapBodyBinding ()
+ {
+ return new Soap12BodyBinding ();
+ }
+
+ public override string EncodingNS {
+ get { return EncodingNamespace; }
+ }
+
+ public const string EncodingNamespace = "http://www.w3.org/2003/05/soap-encoding";
+ }
+#endif
}
namespace System.Web.Services.Description {
- internal class SoapProtocolReflector : ProtocolReflector
+ internal abstract class SoapProtocolReflector : ProtocolReflector
{
#region Fields
- internal const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
SoapBinding soapBinding;
#endregion // Fields
#region Properties
- public override string ProtocolName {
- get { return "Soap"; }
- }
+ public abstract SoapExtensionReflector ExtensionReflector { get; }
- #endregion // Properties
+ #endregion
#region Methods
protected override void BeginClass ()
{
- SoapBinding sb = new SoapBinding ();
- sb.Transport = SoapBinding.HttpTransport;
- sb.Style = ((SoapTypeStubInfo)TypeInfo).SoapBindingStyle;
- Binding.Extensions.Add (sb);
-
- SoapAddressBinding abind = new SoapAddressBinding ();
- abind.Location = ServiceUrl;
- Port.Extensions.Add (abind);
+ ExtensionReflector.ReflectDescription ();
}
protected override void EndClass ()
protected override bool ReflectMethod ()
{
- SoapOperationBinding sob = new SoapOperationBinding();
SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
-
- sob.SoapAction = method.Action;
- sob.Style = method.SoapBindingStyle;
- OperationBinding.Extensions.Add (sob);
-
ImportMessage (method.InputMembersMapping, InputMessage);
ImportMessage (method.OutputMembersMapping, OutputMessage);
- AddOperationMsgBindings (method, OperationBinding.Input);
- AddOperationMsgBindings (method, OperationBinding.Output);
foreach (SoapHeaderMapping hf in method.Headers)
{
msg.Parts.Add (part);
ServiceDescription.Messages.Add (msg);
- SoapHeaderBinding hb = new SoapHeaderBinding ();
- hb.Message = new XmlQualifiedName (msg.Name, ServiceDescription.TargetNamespace);
- hb.Part = part.Name;
- hb.Use = method.Use;
-
if (method.Use == SoapBindingUse.Literal)
{
// MS.NET reflects header classes in a weird way. The root element
XmlTypeMapping mapping = SoapReflectionImporter.ImportTypeMapping (hf.HeaderType, TypeInfo.LogicalType.GetWebServiceEncodedNamespace (ServiceDescription.TargetNamespace));
part.Type = new XmlQualifiedName (mapping.ElementName, mapping.Namespace);
SoapSchemaExporter.ExportTypeMapping (mapping);
- hb.Encoding = EncodingNamespace;
}
-
- if ((hf.Direction & SoapHeaderDirection.Out) != 0)
- OperationBinding.Output.Extensions.Add (hb);
- if ((hf.Direction & SoapHeaderDirection.In) != 0)
- OperationBinding.Input.Extensions.Add (hb);
}
- return true;
- }
+ ExtensionReflector.ReflectMethod ();
- void AddOperationMsgBindings (SoapMethodStubInfo method, MessageBinding msg)
- {
- SoapBodyBinding sbbo = new SoapBodyBinding();
- msg.Extensions.Add (sbbo);
- sbbo.Use = method.Use;
- if (method.Use == SoapBindingUse.Encoded)
- {
- sbbo.Namespace = ServiceDescription.TargetNamespace;
- sbbo.Encoding = EncodingNamespace;
- }
+ return true;
}
void ImportMessage (XmlMembersMapping members, Message msg)
#endregion
}
+
+ internal class Soap11ProtocolReflector : SoapProtocolReflector
+ {
+ SoapExtensionReflector reflector;
+
+ public Soap11ProtocolReflector ()
+ {
+ reflector = new Soap11BindingExtensionReflector ();
+ reflector.ReflectionContext = this;
+ }
+
+ public override string ProtocolName {
+ get { return "Soap"; }
+ }
+
+ public override SoapExtensionReflector ExtensionReflector {
+ get { return reflector; }
+ }
+ }
+
+#if NET_2_0
+ internal class Soap12ProtocolReflector : SoapProtocolReflector
+ {
+ SoapExtensionReflector reflector;
+
+ public Soap12ProtocolReflector ()
+ {
+ reflector = new Soap12BindingExtensionReflector ();
+ reflector.ReflectionContext = this;
+ }
+
+ public override string ProtocolName {
+ get { return "Soap12"; }
+ }
+
+ public override SoapExtensionReflector ExtensionReflector {
+ get { return reflector; }
+ }
+ }
+#endif
}
+2006-12-15 Atsushi Enomoto <atsushi@ximian.com>
+
+ * ServerType.cs : added SOAP 1.2 protocol as a different one from
+ SOAP 1.1.
+ * Methods.cs : added Soap12TypeStubInfo.
+
2006-12-15 Atsushi Enomoto <atsushi@ximian.com>
* HttpSoapWebServiceHandler.cs,
return (SoapMethodStubInfo) methods_byaction [name.Trim ('"',' ')];
}
}
+
+ internal class Soap12TypeStubInfo : SoapTypeStubInfo
+ {
+ public Soap12TypeStubInfo (ServerType logicalTypeInfo)
+ : base (logicalTypeInfo)
+ {
+ }
+
+ public override string ProtocolName
+ {
+ get { return "Soap12"; }
+ }
+ }
}
bool useEncoded;
TypeStubInfo soapProtocol;
+#if NET_2_0
+ TypeStubInfo soap12Protocol;
+#endif
TypeStubInfo httpGetProtocol;
TypeStubInfo httpPostProtocol;
case "Soap":
if (soapProtocol == null) soapProtocol = CreateTypeStubInfo (typeof(SoapTypeStubInfo));
return soapProtocol;
+#if NET_2_0
+ case "Soap12":
+ if (soap12Protocol == null) soap12Protocol = CreateTypeStubInfo (typeof(Soap12TypeStubInfo));
+ return soap12Protocol;
+#endif
case "HttpGet":
if (httpGetProtocol == null) httpGetProtocol = CreateTypeStubInfo (typeof(HttpGetTypeStubInfo));
return httpGetProtocol;