You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
File diff suppressed because it is too large
Load Diff
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.BasicProfileViolation.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez (lluis@novell.com)
|
||||
//
|
||||
// Copyright (C) Novell, Inc., 2004
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.Web.Services;
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
public class BasicProfileViolation
|
||||
{
|
||||
WsiProfiles _claims;
|
||||
StringCollection _elements;
|
||||
ConformanceRule _rule;
|
||||
|
||||
internal BasicProfileViolation (WsiProfiles claims, ConformanceRule rule)
|
||||
{
|
||||
_claims = claims;
|
||||
_rule = rule;
|
||||
_elements = new StringCollection ();
|
||||
}
|
||||
|
||||
public WsiProfiles Claims {
|
||||
get { return _claims; }
|
||||
}
|
||||
|
||||
public string Details {
|
||||
get { return _rule.Details; }
|
||||
}
|
||||
|
||||
public StringCollection Elements {
|
||||
get { return _elements; }
|
||||
}
|
||||
|
||||
public string NormativeStatement {
|
||||
get { return _rule.NormativeStatement ; }
|
||||
}
|
||||
|
||||
public string Recommendation {
|
||||
get { return _rule.Recommendation; }
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
string res = NormativeStatement + ": " + Details;
|
||||
foreach (string s in Elements)
|
||||
res += "\n - " + s;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.BasicProfileViolationCollection.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez (lluis@novell.com)
|
||||
//
|
||||
// Copyright (C) Novell, Inc., 2004
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
public class BasicProfileViolationCollection
|
||||
: CollectionBase, IEnumerable<BasicProfileViolation>
|
||||
{
|
||||
int generation;
|
||||
|
||||
public BasicProfileViolationCollection ()
|
||||
{
|
||||
}
|
||||
|
||||
IEnumerator<BasicProfileViolation> IEnumerable<BasicProfileViolation>.GetEnumerator ()
|
||||
{
|
||||
return new BasicProfileViolationEnumerator (this);
|
||||
}
|
||||
|
||||
internal int Generation {
|
||||
get { return generation; }
|
||||
}
|
||||
|
||||
public BasicProfileViolation this [int index] {
|
||||
get { return (BasicProfileViolation) List [index]; }
|
||||
set { List [index] = value; }
|
||||
}
|
||||
|
||||
internal int Add (BasicProfileViolation violation)
|
||||
{
|
||||
return List.Add (violation);
|
||||
}
|
||||
|
||||
public bool Contains (BasicProfileViolation violation)
|
||||
{
|
||||
return List.Contains (violation);
|
||||
}
|
||||
|
||||
public void CopyTo (BasicProfileViolation[] array, int index)
|
||||
{
|
||||
List.CopyTo (array, index);
|
||||
}
|
||||
|
||||
public int IndexOf (BasicProfileViolation violation)
|
||||
{
|
||||
return List.IndexOf (violation);
|
||||
}
|
||||
|
||||
public void Insert (int index, BasicProfileViolation violation)
|
||||
{
|
||||
generation++;
|
||||
List.Insert (index, violation);
|
||||
}
|
||||
|
||||
public void Remove (BasicProfileViolation violation)
|
||||
{
|
||||
List.Remove (violation);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string s = "";
|
||||
foreach (BasicProfileViolation violation in List)
|
||||
s += violation.ToString () + "\n";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// BasicProfileViolationEnumerator.cs
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <atsushi@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2006 Novell, Inc.
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
public class BasicProfileViolationEnumerator : IEnumerator<BasicProfileViolation>, IDisposable
|
||||
{
|
||||
BasicProfileViolationCollection collection;
|
||||
int current = -1;
|
||||
int generation;
|
||||
|
||||
public BasicProfileViolationEnumerator (BasicProfileViolationCollection collection)
|
||||
{
|
||||
if (collection == null)
|
||||
throw new ArgumentNullException ("collection");
|
||||
this.collection = collection;
|
||||
generation = collection.Generation;
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
collection = null;
|
||||
}
|
||||
|
||||
public bool MoveNext ()
|
||||
{
|
||||
if (generation != collection.Generation)
|
||||
throw new InvalidOperationException ("Collection has changed during the enumeration.");
|
||||
if (current + 1 == collection.Count)
|
||||
return false;
|
||||
current++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public BasicProfileViolation Current {
|
||||
get { return current < 0 ? null : collection [current]; }
|
||||
}
|
||||
|
||||
object IEnumerator.Current {
|
||||
get { return current < 0 ? null : collection [current]; }
|
||||
}
|
||||
|
||||
void IEnumerator.Reset ()
|
||||
{
|
||||
current = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.ConformanceChecker.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez (lluis@novell.com)
|
||||
//
|
||||
// Copyright (C) Novell, Inc., 2004
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
using System.Xml.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
internal abstract class ConformanceChecker
|
||||
{
|
||||
public abstract WsiProfiles Claims { get; }
|
||||
|
||||
public virtual void Check (ConformanceCheckContext ctx, Binding value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, BindingCollection value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, MessageBinding value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, Import value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, Message value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, MessagePart value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, Operation value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, OperationBinding value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, OperationMessage value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, Port value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, PortType value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, Service value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, ServiceDescription value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, Types value) { }
|
||||
public virtual void Check (ConformanceCheckContext ctx, ServiceDescriptionFormatExtension value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaObject value) {}
|
||||
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchema s) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaImport value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaAll value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaAnnotation value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaAttribute value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaAttributeGroup value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaAttributeGroupRef value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaComplexContentExtension value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaChoice value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaComplexContent value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaComplexContentRestriction value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaComplexType value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaElement value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaGroup value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaGroupRef value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaIdentityConstraint value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaKeyref value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaRedefine value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSequence value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleContent value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleContentExtension value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleContentRestriction value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleType value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeList value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeRestriction value) {}
|
||||
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeUnion value) {}
|
||||
}
|
||||
|
||||
internal class ConformanceRule
|
||||
{
|
||||
public string NormativeStatement;
|
||||
public string Details;
|
||||
public string Recommendation;
|
||||
|
||||
public ConformanceRule (string name, string desc, string rec)
|
||||
{
|
||||
NormativeStatement = name;
|
||||
Details = desc;
|
||||
Recommendation = rec;
|
||||
}
|
||||
}
|
||||
|
||||
internal class ConformanceCheckContext
|
||||
{
|
||||
BasicProfileViolationCollection violations;
|
||||
ServiceDescriptionCollection collection;
|
||||
WebReference webReference;
|
||||
ConformanceChecker checker;
|
||||
public ServiceDescription ServiceDescription;
|
||||
public XmlSchema CurrentSchema;
|
||||
XmlSchemas schemas = new XmlSchemas ();
|
||||
ServiceDescriptionCollection services;
|
||||
|
||||
public ConformanceCheckContext (ServiceDescriptionCollection collection, BasicProfileViolationCollection violations)
|
||||
{
|
||||
this.collection = collection;
|
||||
this.violations = violations;
|
||||
foreach (ServiceDescription sd in collection) {
|
||||
if (sd.Types != null && sd.Types.Schemas != null)
|
||||
schemas.Add (sd.Types.Schemas);
|
||||
}
|
||||
services = collection;
|
||||
}
|
||||
|
||||
public ConformanceCheckContext (WebReference webReference, BasicProfileViolationCollection violations)
|
||||
{
|
||||
this.webReference = webReference;
|
||||
this.violations = violations;
|
||||
services = new ServiceDescriptionCollection ();
|
||||
|
||||
foreach (object doc in webReference.Documents.Values)
|
||||
{
|
||||
if (doc is XmlSchema)
|
||||
schemas.Add ((XmlSchema)doc);
|
||||
else if (doc is ServiceDescription) {
|
||||
ServiceDescription sd = (ServiceDescription) doc;
|
||||
services.Add (sd);
|
||||
if (sd.Types != null && sd.Types.Schemas != null)
|
||||
schemas.Add (sd.Types.Schemas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConformanceChecker Checker {
|
||||
get { return checker; }
|
||||
set { checker = value; }
|
||||
}
|
||||
|
||||
public BasicProfileViolationCollection Violations {
|
||||
get { return violations; }
|
||||
}
|
||||
|
||||
public XmlSchemas Schemas {
|
||||
get { return schemas; }
|
||||
}
|
||||
|
||||
public ServiceDescriptionCollection Services {
|
||||
get { return services; }
|
||||
}
|
||||
|
||||
public object GetDocument (string url, string ns)
|
||||
{
|
||||
if (collection != null)
|
||||
return collection[ns];
|
||||
else
|
||||
return webReference.Documents [url];
|
||||
}
|
||||
|
||||
public void ReportError (object currentObject, string msg)
|
||||
{
|
||||
throw new InvalidOperationException (msg + " (" + GetDescription (currentObject) + ")");
|
||||
}
|
||||
|
||||
public void ReportRuleViolation (object currentObject, ConformanceRule rule)
|
||||
{
|
||||
BasicProfileViolation v = null;
|
||||
foreach (BasicProfileViolation bpv in violations) {
|
||||
if (bpv.NormativeStatement == rule.NormativeStatement) {
|
||||
v = bpv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (v == null) {
|
||||
v = new BasicProfileViolation (checker.Claims, rule);
|
||||
violations.Add (v);
|
||||
}
|
||||
|
||||
v.Elements.Add (GetDescription (currentObject));
|
||||
}
|
||||
|
||||
string GetDescription (object obj)
|
||||
{
|
||||
if (obj is ServiceDescription) {
|
||||
return "Service Description '" + ServiceDescription.TargetNamespace + "'";
|
||||
}
|
||||
else if (obj is Binding || obj is Message || obj is PortType || obj is Service) {
|
||||
return GetNamedItemDescription (obj, ServiceDescription);
|
||||
}
|
||||
else if (obj is Import) {
|
||||
return GetItemDescription (obj, ServiceDescription, ((Import)obj).Location);
|
||||
}
|
||||
else if (obj is MessageBinding) {
|
||||
return GetNamedItemDescription (obj, ((MessageBinding)obj).OperationBinding);
|
||||
}
|
||||
else if (obj is MessagePart) {
|
||||
return GetNamedItemDescription (obj, ((MessagePart)obj).Message);
|
||||
}
|
||||
else if (obj is Operation) {
|
||||
return GetNamedItemDescription (obj, ((Operation)obj).PortType);
|
||||
}
|
||||
else if (obj is OperationBinding) {
|
||||
return GetNamedItemDescription (obj, ((OperationBinding)obj).Binding);
|
||||
}
|
||||
else if (obj is OperationMessage) {
|
||||
return GetNamedItemDescription (obj, ((OperationMessage)obj).Operation);
|
||||
}
|
||||
else if (obj is Port) {
|
||||
return GetNamedItemDescription (obj, ((Port)obj).Service);
|
||||
}
|
||||
else if (obj is ServiceDescriptionFormatExtension) {
|
||||
ServiceDescriptionFormatExtension ext = (ServiceDescriptionFormatExtension) obj;
|
||||
return GetItemDescription (ext, ext.Parent, ext.GetType().Name);
|
||||
}
|
||||
else if (obj is XmlSchema) {
|
||||
if (ServiceDescription == null)
|
||||
return "Schema '" + ((XmlSchema)obj).TargetNamespace + "'";
|
||||
else
|
||||
return "Schema '" + ((XmlSchema)obj).TargetNamespace + "', in " + GetDescription (ServiceDescription);
|
||||
}
|
||||
else if (obj is XmlSchemaObject) {
|
||||
return obj.GetType().Name + " in Schema " + GetDescription (CurrentSchema);
|
||||
}
|
||||
return obj.GetType().Name;
|
||||
}
|
||||
|
||||
string GetNamedItemDescription (object item, object parent)
|
||||
{
|
||||
return item.GetType().Name + " '" + ((NamedItem)item).Name + "', in " + GetDescription (parent);
|
||||
}
|
||||
|
||||
string GetItemDescription (object item, object parent, string name)
|
||||
{
|
||||
return item.GetType().Name + " '" + name + "' in " + GetDescription (parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.HttpGetProtocolImporter.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// Copyright (C) 2003 Ximian, Inc.
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.Collections;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
internal class HttpGetProtocolImporter : HttpSimpleProtocolImporter
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public HttpGetProtocolImporter ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public override string ProtocolName {
|
||||
get { return "HttpGet"; }
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override CodeTypeDeclaration BeginClass ()
|
||||
{
|
||||
CodeTypeDeclaration codeClass = base.BeginClass ();
|
||||
CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.Protocols.HttpGetClientProtocol");
|
||||
codeClass.BaseTypes.Add (ctr);
|
||||
return codeClass;
|
||||
}
|
||||
|
||||
protected override Type GetInMimeFormatter ()
|
||||
{
|
||||
HttpUrlEncodedBinding bin = OperationBinding.Input.Extensions.Find (typeof(HttpUrlEncodedBinding)) as HttpUrlEncodedBinding;
|
||||
if (bin == null) throw new Exception ("Http urlEncoded binding not found");
|
||||
return typeof (UrlParameterWriter);
|
||||
}
|
||||
|
||||
protected override bool IsBindingSupported ()
|
||||
{
|
||||
HttpBinding bin = (HttpBinding) Binding.Extensions.Find (typeof(HttpBinding));
|
||||
if (bin == null) return false;
|
||||
return bin.Verb == "GET";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.HttpGetProtocolReflector.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// (C) 2003 Ximian, Inc.
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.Web.Services.Description {
|
||||
|
||||
internal class HttpGetProtocolReflector : HttpSimpleProtocolReflector
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public HttpGetProtocolReflector ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public override string ProtocolName {
|
||||
get { return "HttpGet"; }
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override void BeginClass ()
|
||||
{
|
||||
base.BeginClass ();
|
||||
|
||||
HttpBinding hb = new HttpBinding ();
|
||||
hb.Verb = "GET";
|
||||
Binding.Extensions.Add (hb);
|
||||
}
|
||||
|
||||
protected override bool ReflectMethod ()
|
||||
{
|
||||
if (!base.ReflectMethod ()) return false;
|
||||
|
||||
OperationBinding.Input.Extensions.Add (new HttpUrlEncodedBinding());
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.HttpPostProtocolImporter.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// Copyright (C) 2003 Ximian, Inc.
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.Collections;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
internal class HttpPostProtocolImporter : HttpSimpleProtocolImporter
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public HttpPostProtocolImporter ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public override string ProtocolName {
|
||||
get { return "HttpPost"; }
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override CodeTypeDeclaration BeginClass ()
|
||||
{
|
||||
CodeTypeDeclaration codeClass = base.BeginClass ();
|
||||
CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.Protocols.HttpPostClientProtocol");
|
||||
codeClass.BaseTypes.Add (ctr);
|
||||
return codeClass;
|
||||
}
|
||||
|
||||
protected override Type GetInMimeFormatter ()
|
||||
{
|
||||
MimeContentBinding bin = OperationBinding.Input.Extensions.Find (typeof(MimeContentBinding)) as MimeContentBinding;
|
||||
if (bin == null) throw new Exception ("Http mime:content binding not found");
|
||||
if (bin.Type != "application/x-www-form-urlencoded") throw new Exception ("Encoding of mime:content binding not supported");
|
||||
return typeof (HtmlFormParameterWriter);
|
||||
}
|
||||
|
||||
protected override bool IsBindingSupported ()
|
||||
{
|
||||
HttpBinding bin = (HttpBinding) Binding.Extensions.Find (typeof(HttpBinding));
|
||||
if (bin == null) return false;
|
||||
return bin.Verb == "POST";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.HttpPostProtocolReflector.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// (C) 2003 Ximian, Inc.
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.Web.Services.Description {
|
||||
|
||||
internal class HttpPostProtocolReflector : HttpSimpleProtocolReflector
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public HttpPostProtocolReflector ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public override string ProtocolName {
|
||||
get { return "HttpPost"; }
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override void BeginClass ()
|
||||
{
|
||||
base.BeginClass ();
|
||||
|
||||
HttpBinding hb = new HttpBinding ();
|
||||
hb.Verb = "POST";
|
||||
Binding.Extensions.Add (hb);
|
||||
}
|
||||
|
||||
protected override bool ReflectMethod ()
|
||||
{
|
||||
if (!base.ReflectMethod ()) return false;
|
||||
|
||||
MimeContentBinding mcb = new MimeContentBinding ();
|
||||
mcb.Type = "application/x-www-form-urlencoded";
|
||||
mcb.Part = null;
|
||||
OperationBinding.Input.Extensions.Add (mcb);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.HttpSimpleProtocolImporter.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// Copyright (C) 2003 Ximian, Inc.
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.CodeDom;
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Web.Services.Configuration;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
internal abstract class HttpSimpleProtocolImporter : ProtocolImporter
|
||||
{
|
||||
|
||||
#region Fields
|
||||
|
||||
HttpBinding httpBinding;
|
||||
|
||||
SoapCodeExporter soapExporter;
|
||||
SoapSchemaImporter soapImporter;
|
||||
XmlCodeExporter xmlExporter;
|
||||
XmlSchemaImporter xmlImporter;
|
||||
CodeIdentifiers memberIds;
|
||||
XmlReflectionImporter xmlReflectionImporter;
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Constructors
|
||||
|
||||
public HttpSimpleProtocolImporter ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override CodeTypeDeclaration BeginClass ()
|
||||
{
|
||||
httpBinding = (HttpBinding) Binding.Extensions.Find (typeof(HttpBinding));
|
||||
|
||||
CodeTypeDeclaration codeClass = new CodeTypeDeclaration (ClassName);
|
||||
codeClass.IsPartial = true;
|
||||
|
||||
string location = null;
|
||||
if (Port != null) {
|
||||
HttpAddressBinding sab = (HttpAddressBinding) Port.Extensions.Find (typeof(HttpAddressBinding));
|
||||
if (sab != null) location = sab.Location;
|
||||
}
|
||||
|
||||
CodeConstructor cc = new CodeConstructor ();
|
||||
cc.Attributes = MemberAttributes.Public;
|
||||
GenerateServiceUrl (location, cc.Statements);
|
||||
codeClass.Members.Add (cc);
|
||||
|
||||
memberIds = new CodeIdentifiers ();
|
||||
return codeClass;
|
||||
}
|
||||
|
||||
protected override void BeginNamespace ()
|
||||
{
|
||||
xmlImporter = new XmlSchemaImporter (LiteralSchemas, ClassNames);
|
||||
soapImporter = new SoapSchemaImporter (EncodedSchemas, ClassNames);
|
||||
xmlExporter = new XmlCodeExporter (CodeNamespace, null);
|
||||
xmlReflectionImporter = new XmlReflectionImporter ();
|
||||
}
|
||||
|
||||
protected override void EndClass ()
|
||||
{
|
||||
if (xmlExporter.IncludeMetadata.Count > 0)
|
||||
{
|
||||
if (CodeTypeDeclaration.CustomAttributes == null)
|
||||
CodeTypeDeclaration.CustomAttributes = new CodeAttributeDeclarationCollection ();
|
||||
CodeTypeDeclaration.CustomAttributes.AddRange (xmlExporter.IncludeMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void EndNamespace ()
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool IsBindingSupported ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected override bool IsOperationFlowSupported (OperationFlow flow)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
protected override CodeMemberMethod GenerateMethod ()
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpOperationBinding httpOper = OperationBinding.Extensions.Find (typeof (HttpOperationBinding)) as HttpOperationBinding;
|
||||
if (httpOper == null) throw new Exception ("Http operation binding not found");
|
||||
|
||||
XmlMembersMapping inputMembers = ImportInMembersMapping (InputMessage);
|
||||
XmlTypeMapping outputMember = ImportOutMembersMapping (OutputMessage);
|
||||
|
||||
CodeMemberMethod met = GenerateMethod (memberIds, httpOper, inputMembers, outputMember);
|
||||
|
||||
xmlExporter.ExportMembersMapping (inputMembers);
|
||||
if (outputMember != null)
|
||||
xmlExporter.ExportTypeMapping (outputMember);
|
||||
|
||||
return met;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UnsupportedOperationBindingWarning (ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
XmlMembersMapping ImportInMembersMapping (Message msg)
|
||||
{
|
||||
SoapSchemaMember[] mems = new SoapSchemaMember [msg.Parts.Count];
|
||||
for (int n=0; n<mems.Length; n++)
|
||||
{
|
||||
SoapSchemaMember mem = new SoapSchemaMember();
|
||||
mem.MemberName = msg.Parts[n].Name;
|
||||
mem.MemberType = msg.Parts[n].Type;
|
||||
mems[n] = mem;
|
||||
}
|
||||
return soapImporter.ImportMembersMapping (Operation.Name, "", mems);
|
||||
}
|
||||
|
||||
XmlTypeMapping ImportOutMembersMapping (Message msg)
|
||||
{
|
||||
if (msg.Parts.Count == 0) return null;
|
||||
|
||||
if (msg.Parts[0].Name == "Body" && msg.Parts[0].Element == XmlQualifiedName.Empty)
|
||||
return xmlReflectionImporter.ImportTypeMapping (typeof(XmlNode));
|
||||
else {
|
||||
// This is a bit hacky. The issue is that types such as string[] are to be imported
|
||||
// as such, not as ArrayOfString class. ImportTypeMapping will return a
|
||||
// class if the type has not been imported as an array before, hence the
|
||||
// call to ImportMembersMapping.
|
||||
xmlImporter.ImportMembersMapping (new XmlQualifiedName[] {msg.Parts[0].Element});
|
||||
return xmlImporter.ImportTypeMapping (msg.Parts[0].Element);
|
||||
}
|
||||
}
|
||||
|
||||
CodeMemberMethod GenerateMethod (CodeIdentifiers memberIds, HttpOperationBinding httpOper, XmlMembersMapping inputMembers, XmlTypeMapping outputMember)
|
||||
{
|
||||
CodeIdentifiers pids = new CodeIdentifiers ();
|
||||
CodeMemberMethod method = new CodeMemberMethod ();
|
||||
CodeMemberMethod methodBegin = new CodeMemberMethod ();
|
||||
CodeMemberMethod methodEnd = new CodeMemberMethod ();
|
||||
method.Attributes = MemberAttributes.Public;
|
||||
methodBegin.Attributes = MemberAttributes.Public;
|
||||
methodEnd.Attributes = MemberAttributes.Public;
|
||||
|
||||
// Find unique names for temporary variables
|
||||
|
||||
for (int n=0; n<inputMembers.Count; n++)
|
||||
pids.AddUnique (inputMembers[n].MemberName, inputMembers[n]);
|
||||
|
||||
string varAsyncResult = pids.AddUnique ("asyncResult","asyncResult");
|
||||
string varCallback = pids.AddUnique ("callback","callback");
|
||||
string varAsyncState = pids.AddUnique ("asyncState","asyncState");
|
||||
|
||||
string messageName = memberIds.AddUnique(CodeIdentifier.MakeValid(Operation.Name),method);
|
||||
|
||||
method.Name = Operation.Name;
|
||||
methodBegin.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("Begin" + Operation.Name),method);
|
||||
methodEnd.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("End" + Operation.Name),method);
|
||||
|
||||
method.ReturnType = new CodeTypeReference (typeof(void));
|
||||
methodEnd.ReturnType = new CodeTypeReference (typeof(void));
|
||||
methodEnd.Parameters.Add (new CodeParameterDeclarationExpression (typeof (IAsyncResult),varAsyncResult));
|
||||
|
||||
CodeExpression[] paramArray = new CodeExpression [inputMembers.Count];
|
||||
|
||||
for (int n=0; n<inputMembers.Count; n++)
|
||||
{
|
||||
string ptype = GetSimpleType (inputMembers[n]);
|
||||
CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (ptype, inputMembers[n].MemberName);
|
||||
|
||||
param.Direction = FieldDirection.In;
|
||||
method.Parameters.Add (param);
|
||||
methodBegin.Parameters.Add (param);
|
||||
paramArray [n] = new CodeVariableReferenceExpression (param.Name);
|
||||
}
|
||||
|
||||
bool isVoid = true;
|
||||
if (outputMember != null)
|
||||
{
|
||||
method.ReturnType = new CodeTypeReference (outputMember.TypeFullName);
|
||||
methodEnd.ReturnType = new CodeTypeReference (outputMember.TypeFullName);
|
||||
xmlExporter.AddMappingMetadata (method.ReturnTypeCustomAttributes, outputMember, "");
|
||||
isVoid = false;
|
||||
}
|
||||
|
||||
methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (AsyncCallback),varCallback));
|
||||
methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (object),varAsyncState));
|
||||
methodBegin.ReturnType = new CodeTypeReference (typeof(IAsyncResult));
|
||||
|
||||
// Array of input parameters
|
||||
|
||||
CodeArrayCreateExpression methodParams;
|
||||
if (paramArray.Length > 0)
|
||||
methodParams = new CodeArrayCreateExpression (typeof(object), paramArray);
|
||||
else
|
||||
methodParams = new CodeArrayCreateExpression (typeof(object), 0);
|
||||
|
||||
// Generate method url
|
||||
|
||||
CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
|
||||
|
||||
CodeExpression thisURlExp = new CodeFieldReferenceExpression (ethis, "Url");
|
||||
CodePrimitiveExpression metUrl = new CodePrimitiveExpression (httpOper.Location);
|
||||
CodeBinaryOperatorExpression expMethodLocation = new CodeBinaryOperatorExpression (thisURlExp, CodeBinaryOperatorType.Add, metUrl);
|
||||
|
||||
// Invoke call
|
||||
|
||||
CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
|
||||
CodeMethodInvokeExpression inv;
|
||||
|
||||
inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, expMethodLocation, methodParams);
|
||||
if (!isVoid)
|
||||
method.Statements.Add (new CodeMethodReturnStatement (new CodeCastExpression (method.ReturnType, inv)));
|
||||
else
|
||||
method.Statements.Add (inv);
|
||||
|
||||
// Begin Invoke Call
|
||||
|
||||
CodeExpression expCallb = new CodeVariableReferenceExpression (varCallback);
|
||||
CodeExpression expAsyncs = new CodeVariableReferenceExpression (varAsyncState);
|
||||
inv = new CodeMethodInvokeExpression (ethis, "BeginInvoke", varMsgName, expMethodLocation, methodParams, expCallb, expAsyncs);
|
||||
methodBegin.Statements.Add (new CodeMethodReturnStatement (inv));
|
||||
|
||||
// End Invoke call
|
||||
|
||||
CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
|
||||
inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
|
||||
if (!isVoid)
|
||||
methodEnd.Statements.Add (new CodeMethodReturnStatement (new CodeCastExpression (methodEnd.ReturnType, inv)));
|
||||
else
|
||||
methodEnd.Statements.Add (inv);
|
||||
|
||||
// Attributes
|
||||
|
||||
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.HttpMethodAttribute");
|
||||
att.Arguments.Add (new CodeAttributeArgument (new CodeTypeOfExpression(GetOutMimeFormatter ())));
|
||||
att.Arguments.Add (new CodeAttributeArgument (new CodeTypeOfExpression(GetInMimeFormatter ())));
|
||||
AddCustomAttribute (method, att, true);
|
||||
|
||||
CodeTypeDeclaration.Members.Add (method);
|
||||
CodeTypeDeclaration.Members.Add (methodBegin);
|
||||
CodeTypeDeclaration.Members.Add (methodEnd);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
internal override CodeExpression BuildInvokeAsync (string messageName, CodeArrayCreateExpression paramsArray, CodeExpression delegateField, CodeExpression userStateVar)
|
||||
{
|
||||
HttpOperationBinding httpOper = OperationBinding.Extensions.Find (typeof (HttpOperationBinding)) as HttpOperationBinding;
|
||||
|
||||
CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
|
||||
|
||||
CodeExpression thisURlExp = new CodeFieldReferenceExpression (ethis, "Url");
|
||||
CodePrimitiveExpression metUrl = new CodePrimitiveExpression (httpOper.Location);
|
||||
CodeBinaryOperatorExpression expMethodLocation = new CodeBinaryOperatorExpression (thisURlExp, CodeBinaryOperatorType.Add, metUrl);
|
||||
|
||||
CodeMethodInvokeExpression inv2 = new CodeMethodInvokeExpression (ethis, "InvokeAsync");
|
||||
inv2.Parameters.Add (new CodePrimitiveExpression (messageName));
|
||||
inv2.Parameters.Add (expMethodLocation);
|
||||
inv2.Parameters.Add (paramsArray);
|
||||
inv2.Parameters.Add (delegateField);
|
||||
inv2.Parameters.Add (userStateVar);
|
||||
return inv2;
|
||||
}
|
||||
|
||||
protected virtual Type GetInMimeFormatter ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual Type GetOutMimeFormatter ()
|
||||
{
|
||||
if (OperationBinding.Output.Extensions.Find (typeof(MimeXmlBinding)) != null)
|
||||
return typeof (XmlReturnReader);
|
||||
|
||||
MimeContentBinding bin = (MimeContentBinding) OperationBinding.Output.Extensions.Find (typeof(MimeContentBinding));
|
||||
if (bin != null && bin.Type == "text/xml")
|
||||
return typeof (XmlReturnReader);
|
||||
|
||||
return typeof(NopReturnReader);
|
||||
}
|
||||
|
||||
string GetSimpleType (XmlMemberMapping member)
|
||||
{
|
||||
// MS seems to always use System.String for input parameters, except for byte[]
|
||||
|
||||
switch (member.TypeName)
|
||||
{
|
||||
case "hexBinary":
|
||||
case "base64Binary":
|
||||
return "System.String";
|
||||
|
||||
default:
|
||||
string ptype = member.TypeFullName;
|
||||
int i = ptype.IndexOf ('[');
|
||||
if (i == -1)
|
||||
return "System.String";
|
||||
else
|
||||
return "System.String" + ptype.Substring (i);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.HttpSimpleProtocolReflector.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// (C) 2003 Ximian, Inc.
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Web.Services.Description {
|
||||
|
||||
internal abstract class HttpSimpleProtocolReflector : ProtocolReflector
|
||||
{
|
||||
#region Fields
|
||||
|
||||
SoapBinding soapBinding;
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Constructors
|
||||
|
||||
public HttpSimpleProtocolReflector ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override void BeginClass ()
|
||||
{
|
||||
HttpAddressBinding abind = new HttpAddressBinding ();
|
||||
abind.Location = ServiceUrl;
|
||||
Port.Extensions.Add (abind);
|
||||
}
|
||||
|
||||
protected override void EndClass ()
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool ReflectMethod ()
|
||||
{
|
||||
LogicalTypeInfo ti = TypeStubManager.GetLogicalTypeInfo (ServiceType);
|
||||
HttpOperationBinding sob = new HttpOperationBinding();
|
||||
sob.Location = "/" + MethodStubInfo.Name;
|
||||
OperationBinding.Extensions.Add (sob);
|
||||
|
||||
if (!Method.IsVoid)
|
||||
{
|
||||
MimeXmlBinding mxb = new MimeXmlBinding ();
|
||||
mxb.Part = "Body";
|
||||
OperationBinding.Output.Extensions.Add (mxb);
|
||||
|
||||
MessagePart part = new MessagePart ();
|
||||
part.Name = "Body";
|
||||
|
||||
XmlTypeMapping map = ReflectionImporter.ImportTypeMapping (Method.ReturnType, ti.GetWebServiceLiteralNamespace (ServiceDescription.TargetNamespace));
|
||||
XmlQualifiedName qname = new XmlQualifiedName (map.ElementName, map.Namespace);
|
||||
part.Element = qname;
|
||||
OutputMessage.Parts.Add (part);
|
||||
SchemaExporter.ExportTypeMapping (map);
|
||||
}
|
||||
|
||||
XmlReflectionMember[] mems = new XmlReflectionMember [Method.Parameters.Length];
|
||||
for (int n=0; n<Method.Parameters.Length; n++)
|
||||
{
|
||||
ParameterInfo param = Method.Parameters [n];
|
||||
XmlReflectionMember mem = new XmlReflectionMember ();
|
||||
mem.MemberName = param.Name;
|
||||
Type ptype = param.ParameterType;
|
||||
if (ptype.IsByRef) ptype = ptype.GetElementType ();
|
||||
mem.MemberType = ptype;
|
||||
mems [n] = mem;
|
||||
}
|
||||
|
||||
XmlMembersMapping memap = ReflectionImporter.ImportMembersMapping ("", ti.WebServiceAbstractNamespace, mems, false);
|
||||
bool allPrimitives = true;
|
||||
|
||||
for (int n=0; n<memap.Count; n++)
|
||||
{
|
||||
XmlMemberMapping mem = memap[n];
|
||||
MessagePart part = new MessagePart ();
|
||||
XmlQualifiedName pqname;
|
||||
|
||||
if (mem.TypeNamespace == "")
|
||||
pqname = new XmlQualifiedName (mem.TypeName, XmlSchema.Namespace);
|
||||
else {
|
||||
pqname = new XmlQualifiedName (mem.TypeName, mem.TypeNamespace);
|
||||
allPrimitives = false;
|
||||
}
|
||||
|
||||
part.Type = pqname;
|
||||
part.Name = mem.ElementName;
|
||||
InputMessage.Parts.Add (part);
|
||||
}
|
||||
|
||||
if (!allPrimitives)
|
||||
SoapSchemaExporter.ExportMembersMapping (memap);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
XmlQualifiedName GenerateStringArray ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override string ReflectMethodBinding ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,480 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.ProtocolReflector.cs
|
||||
//
|
||||
// Author:
|
||||
// Tim Coleman (tim@timcoleman.com)
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// Copyright (C) Tim Coleman, 2002
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Web.Services.Description {
|
||||
public abstract class ProtocolReflector {
|
||||
|
||||
#region Fields
|
||||
|
||||
Binding binding;
|
||||
string defaultNamespace;
|
||||
MessageCollection headerMessages;
|
||||
Message inputMessage;
|
||||
LogicalMethodInfo[] methods;
|
||||
Operation operation;
|
||||
OperationBinding operationBinding;
|
||||
Message outputMessage;
|
||||
Port port;
|
||||
PortType portType;
|
||||
string protocolName;
|
||||
XmlSchemaExporter schemaExporter;
|
||||
Service service;
|
||||
ServiceDescription serviceDescription;
|
||||
Type serviceType;
|
||||
string serviceUrl;
|
||||
SoapSchemaExporter soapSchemaExporter;
|
||||
MethodStubInfo methodStubInfo;
|
||||
TypeStubInfo typeInfo;
|
||||
ArrayList extensionReflectors;
|
||||
ServiceDescriptionReflector serviceReflector;
|
||||
|
||||
XmlReflectionImporter reflectionImporter;
|
||||
SoapReflectionImporter soapReflectionImporter;
|
||||
|
||||
CodeIdentifiers portNames;
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Constructors
|
||||
|
||||
protected ProtocolReflector ()
|
||||
{
|
||||
defaultNamespace = WebServiceAttribute.DefaultNamespace;
|
||||
extensionReflectors = ExtensionManager.BuildExtensionReflectors ();
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
internal ServiceDescriptionReflector Parent {
|
||||
get { return serviceReflector; }
|
||||
}
|
||||
|
||||
public Binding Binding {
|
||||
get { return binding; }
|
||||
}
|
||||
|
||||
public string DefaultNamespace {
|
||||
get { return defaultNamespace; }
|
||||
}
|
||||
|
||||
public MessageCollection HeaderMessages {
|
||||
get { return headerMessages; } // TODO: set
|
||||
}
|
||||
|
||||
public Message InputMessage {
|
||||
get { return inputMessage; }
|
||||
}
|
||||
|
||||
public LogicalMethodInfo Method {
|
||||
get { return methodStubInfo.MethodInfo; }
|
||||
}
|
||||
|
||||
public WebMethodAttribute MethodAttribute {
|
||||
get { return methodStubInfo.MethodAttribute; }
|
||||
}
|
||||
|
||||
public LogicalMethodInfo[] Methods {
|
||||
get { return typeInfo.LogicalType.LogicalMethods; }
|
||||
}
|
||||
|
||||
public Operation Operation {
|
||||
get { return operation; }
|
||||
}
|
||||
|
||||
public OperationBinding OperationBinding {
|
||||
get { return operationBinding; }
|
||||
}
|
||||
|
||||
public Message OutputMessage {
|
||||
get { return outputMessage; }
|
||||
}
|
||||
|
||||
public Port Port {
|
||||
get { return port; }
|
||||
}
|
||||
|
||||
public PortType PortType {
|
||||
get { return portType; }
|
||||
}
|
||||
|
||||
public abstract string ProtocolName {
|
||||
get;
|
||||
}
|
||||
|
||||
public XmlReflectionImporter ReflectionImporter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (reflectionImporter == null) {
|
||||
reflectionImporter = typeInfo.XmlImporter;
|
||||
if (reflectionImporter == null)
|
||||
reflectionImporter = new XmlReflectionImporter();
|
||||
}
|
||||
return reflectionImporter;
|
||||
}
|
||||
}
|
||||
|
||||
internal SoapReflectionImporter SoapReflectionImporter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (soapReflectionImporter == null) {
|
||||
soapReflectionImporter = typeInfo.SoapImporter;
|
||||
if (soapReflectionImporter == null)
|
||||
soapReflectionImporter = new SoapReflectionImporter();
|
||||
}
|
||||
return soapReflectionImporter;
|
||||
}
|
||||
}
|
||||
|
||||
public XmlSchemaExporter SchemaExporter {
|
||||
get { return schemaExporter; }
|
||||
}
|
||||
|
||||
internal SoapSchemaExporter SoapSchemaExporter {
|
||||
get { return soapSchemaExporter; }
|
||||
}
|
||||
|
||||
public XmlSchemas Schemas {
|
||||
get { return serviceReflector.Schemas; }
|
||||
}
|
||||
|
||||
public Service Service {
|
||||
get { return service; }
|
||||
}
|
||||
|
||||
public ServiceDescription ServiceDescription {
|
||||
get { return serviceDescription; }
|
||||
}
|
||||
|
||||
public ServiceDescriptionCollection ServiceDescriptions {
|
||||
get { return serviceReflector.ServiceDescriptions; }
|
||||
}
|
||||
|
||||
public Type ServiceType {
|
||||
get { return serviceType; }
|
||||
}
|
||||
|
||||
public string ServiceUrl {
|
||||
get { return serviceUrl; }
|
||||
}
|
||||
|
||||
internal MethodStubInfo MethodStubInfo {
|
||||
get { return methodStubInfo; }
|
||||
}
|
||||
|
||||
internal TypeStubInfo TypeInfo {
|
||||
get { return typeInfo; }
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
internal void Reflect (ServiceDescriptionReflector serviceReflector, Type type, string url, XmlSchemaExporter xxporter, SoapSchemaExporter sxporter)
|
||||
{
|
||||
portNames = new CodeIdentifiers ();
|
||||
this.serviceReflector = serviceReflector;
|
||||
serviceUrl = url;
|
||||
serviceType = type;
|
||||
|
||||
schemaExporter = xxporter;
|
||||
soapSchemaExporter = sxporter;
|
||||
|
||||
typeInfo = TypeStubManager.GetTypeStub (type, ProtocolName);
|
||||
|
||||
ServiceDescription desc = ServiceDescriptions [typeInfo.LogicalType.WebServiceNamespace];
|
||||
|
||||
if (desc == null)
|
||||
{
|
||||
desc = new ServiceDescription ();
|
||||
desc.TargetNamespace = typeInfo.LogicalType.WebServiceNamespace;
|
||||
desc.Name = typeInfo.LogicalType.WebServiceName;
|
||||
ServiceDescriptions.Add (desc);
|
||||
}
|
||||
|
||||
ImportService (desc, typeInfo, url);
|
||||
}
|
||||
|
||||
void ImportService (ServiceDescription desc, TypeStubInfo typeInfo, string url)
|
||||
{
|
||||
service = desc.Services [typeInfo.LogicalType.WebServiceName];
|
||||
if (service == null)
|
||||
{
|
||||
service = new Service ();
|
||||
service.Name = typeInfo.LogicalType.WebServiceName;
|
||||
service.Documentation = typeInfo.LogicalType.Description;
|
||||
desc.Services.Add (service);
|
||||
}
|
||||
|
||||
foreach (BindingInfo binfo in typeInfo.Bindings)
|
||||
ImportBinding (desc, service, typeInfo, url, binfo);
|
||||
}
|
||||
|
||||
void ImportBinding (ServiceDescription desc, Service service, TypeStubInfo typeInfo, string url, BindingInfo binfo)
|
||||
{
|
||||
port = new Port ();
|
||||
port.Name = portNames.AddUnique (binfo.Name, port);
|
||||
bool bindingFull = true;
|
||||
|
||||
if (binfo.Namespace != desc.TargetNamespace)
|
||||
{
|
||||
if (binfo.Location == null || binfo.Location == string.Empty)
|
||||
{
|
||||
ServiceDescription newDesc = new ServiceDescription();
|
||||
newDesc.TargetNamespace = binfo.Namespace;
|
||||
newDesc.Name = binfo.Name;
|
||||
bindingFull = ImportBindingContent (newDesc, typeInfo, url, binfo);
|
||||
if (bindingFull) {
|
||||
int id = ServiceDescriptions.Add (newDesc);
|
||||
AddImport (desc, binfo.Namespace, GetWsdlUrl (url,id));
|
||||
}
|
||||
}
|
||||
else {
|
||||
AddImport (desc, binfo.Namespace, binfo.Location);
|
||||
bindingFull = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
bindingFull = ImportBindingContent (desc, typeInfo, url, binfo);
|
||||
|
||||
if (bindingFull)
|
||||
{
|
||||
port.Binding = new XmlQualifiedName (binding.Name, binfo.Namespace);
|
||||
|
||||
int n = 0;
|
||||
string name = binfo.Name;
|
||||
bool found;
|
||||
do {
|
||||
|
||||
found = false;
|
||||
foreach (Port p in service.Ports)
|
||||
if (p.Name == name) { found = true; n++; name = binfo.Name + n; break; }
|
||||
}
|
||||
while (found);
|
||||
port.Name = name;
|
||||
service.Ports.Add (port);
|
||||
}
|
||||
|
||||
if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.ConformsTo != WsiProfiles.None && String.IsNullOrEmpty (binfo.WebServiceBindingAttribute.Name)) {
|
||||
BasicProfileViolationCollection violations = new BasicProfileViolationCollection ();
|
||||
desc.Types.Schemas.Add (Schemas);
|
||||
ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
|
||||
col.Add (desc);
|
||||
ConformanceCheckContext ctx = new ConformanceCheckContext (col, violations);
|
||||
ctx.ServiceDescription = desc;
|
||||
ConformanceChecker[] checkers = WebServicesInteroperability.GetCheckers (binfo.WebServiceBindingAttribute.ConformsTo);
|
||||
foreach (ConformanceChecker checker in checkers) {
|
||||
ctx.Checker = checker;
|
||||
WebServicesInteroperability.Check (ctx, checker, binding);
|
||||
if (violations.Count > 0)
|
||||
throw new InvalidOperationException (violations [0].ToString ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo)
|
||||
{
|
||||
serviceDescription = desc;
|
||||
|
||||
// Look for an unused name
|
||||
|
||||
int n=0;
|
||||
string name = binfo.Name;
|
||||
bool found;
|
||||
do
|
||||
{
|
||||
found = false;
|
||||
foreach (Binding bi in desc.Bindings)
|
||||
if (bi.Name == name) { found = true; n++; name = binfo.Name+n; break; }
|
||||
}
|
||||
while (found);
|
||||
|
||||
// Create the binding
|
||||
|
||||
binding = new Binding ();
|
||||
binding.Name = name;
|
||||
binding.Type = new XmlQualifiedName (binding.Name, binfo.Namespace);
|
||||
if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.EmitConformanceClaims) {
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
XmlElement docElement = doc.CreateElement ("wsdl", "documentation", "http://schemas.xmlsoap.org/wsdl/");
|
||||
XmlElement claimsElement = doc.CreateElement ("wsi", "Claim", "http://ws-i.org/schemas/conformanceClaim/");
|
||||
claimsElement.Attributes.Append (doc.CreateAttribute ("conformsTo")).Value = "http://ws-i.org/profiles/basic/1.1";
|
||||
docElement.AppendChild (claimsElement);
|
||||
binding.DocumentationElement = docElement;
|
||||
}
|
||||
|
||||
portType = new PortType ();
|
||||
portType.Name = binding.Name;
|
||||
|
||||
BeginClass ();
|
||||
|
||||
foreach (SoapExtensionReflector reflector in extensionReflectors)
|
||||
{
|
||||
reflector.ReflectionContext = this;
|
||||
reflector.ReflectDescription ();
|
||||
}
|
||||
|
||||
foreach (MethodStubInfo method in typeInfo.Methods)
|
||||
{
|
||||
methodStubInfo = method;
|
||||
|
||||
string metBinding = ReflectMethodBinding ();
|
||||
if (typeInfo.GetBinding (metBinding) != binfo) continue;
|
||||
|
||||
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);
|
||||
|
||||
outputMessage = new Message ();
|
||||
outputMessage.Name = method.Name + ProtocolName + "Out";
|
||||
ServiceDescription.Messages.Add (outputMessage);
|
||||
|
||||
OperationInput inOp = new OperationInput ();
|
||||
if (method.Name != method.OperationName) inOp.Name = method.Name;
|
||||
Operation.Messages.Add (inOp);
|
||||
inOp.Message = new XmlQualifiedName (inputMessage.Name, ServiceDescription.TargetNamespace);
|
||||
|
||||
OperationOutput outOp = new OperationOutput ();
|
||||
if (method.Name != method.OperationName) outOp.Name = method.Name;
|
||||
Operation.Messages.Add (outOp);
|
||||
outOp.Message = new XmlQualifiedName (outputMessage.Name, ServiceDescription.TargetNamespace);
|
||||
|
||||
portType.Operations.Add (operation);
|
||||
ImportOperationBinding ();
|
||||
|
||||
if (!ReflectMethod ()) {
|
||||
// (It is somewhat hacky) If we don't
|
||||
// add input/output Messages, update
|
||||
// portType/input/@message and
|
||||
// porttype/output/@message.
|
||||
Message dupIn = Parent.MappedMessagesIn [method.MethodInfo];
|
||||
ServiceDescription.Messages.Remove (inputMessage);
|
||||
inOp.Message = new XmlQualifiedName (dupIn.Name, ServiceDescription.TargetNamespace);
|
||||
Message dupOut = Parent.MappedMessagesOut [method.MethodInfo];
|
||||
ServiceDescription.Messages.Remove (outputMessage);
|
||||
outOp.Message = new XmlQualifiedName (dupOut.Name, ServiceDescription.TargetNamespace);
|
||||
}
|
||||
|
||||
foreach (SoapExtensionReflector reflector in extensionReflectors)
|
||||
{
|
||||
reflector.ReflectionContext = this;
|
||||
reflector.ReflectMethod ();
|
||||
}
|
||||
}
|
||||
|
||||
EndClass ();
|
||||
|
||||
if (portType.Operations.Count > 0)
|
||||
{
|
||||
desc.Bindings.Add (binding);
|
||||
desc.PortTypes.Add (portType);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void ImportOperationBinding ()
|
||||
{
|
||||
operationBinding = new OperationBinding ();
|
||||
operationBinding.Name = methodStubInfo.OperationName;
|
||||
|
||||
InputBinding inOp = new InputBinding ();
|
||||
operationBinding.Input = inOp;
|
||||
|
||||
OutputBinding outOp = new OutputBinding ();
|
||||
operationBinding.Output = outOp;
|
||||
|
||||
if (methodStubInfo.OperationName != methodStubInfo.Name)
|
||||
inOp.Name = outOp.Name = methodStubInfo.Name;
|
||||
|
||||
binding.Operations.Add (operationBinding);
|
||||
}
|
||||
|
||||
internal static void AddImport (ServiceDescription desc, string ns, string location)
|
||||
{
|
||||
Import im = new Import();
|
||||
im.Namespace = ns;
|
||||
im.Location = location;
|
||||
desc.Imports.Add (im);
|
||||
}
|
||||
|
||||
string GetWsdlUrl (string baseUrl, int id)
|
||||
{
|
||||
return baseUrl + "?wsdl=" + id;
|
||||
}
|
||||
|
||||
protected virtual void BeginClass ()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void EndClass ()
|
||||
{
|
||||
}
|
||||
|
||||
public ServiceDescription GetServiceDescription (string ns)
|
||||
{
|
||||
return ServiceDescriptions [ns];
|
||||
}
|
||||
|
||||
protected abstract bool ReflectMethod ();
|
||||
|
||||
protected virtual string ReflectMethodBinding ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[MonoNotSupported("Not Implemented")]
|
||||
protected virtual void ReflectDescription ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.ServiceDescriptionReflector.cs
|
||||
//
|
||||
// Author:
|
||||
// Tim Coleman (tim@timcoleman.com)
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// Copyright (C) Tim Coleman, 2002
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Web.Services;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Web.Services.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using WSConfig = System.Web.Services.Configuration.WebServicesSection;
|
||||
using WSProtocol = System.Web.Services.Configuration.WebServiceProtocols;
|
||||
|
||||
namespace System.Web.Services.Description {
|
||||
public class ServiceDescriptionReflector
|
||||
{
|
||||
ServiceDescriptionCollection serviceDescriptions;
|
||||
Types types;
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ServiceDescriptionReflector ()
|
||||
{
|
||||
types = new Types ();
|
||||
serviceDescriptions = new ServiceDescriptionCollection ();
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
internal Dictionary<LogicalMethodInfo,Message> MappedMessagesIn =
|
||||
new Dictionary<LogicalMethodInfo,Message> ();
|
||||
internal Dictionary<LogicalMethodInfo,Message> MappedMessagesOut =
|
||||
new Dictionary<LogicalMethodInfo,Message> ();
|
||||
|
||||
#region Properties
|
||||
|
||||
public XmlSchemas Schemas {
|
||||
get { return types.Schemas; }
|
||||
}
|
||||
|
||||
public ServiceDescriptionCollection ServiceDescriptions {
|
||||
get { return serviceDescriptions; }
|
||||
}
|
||||
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
public void Reflect (Type type, string url)
|
||||
{
|
||||
XmlSchemaExporter schemaExporter = new XmlSchemaExporter (Schemas);
|
||||
SoapSchemaExporter soapSchemaExporter = new SoapSchemaExporter (Schemas);
|
||||
|
||||
if (WSConfig.IsSupported (WSProtocol.HttpSoap))
|
||||
new Soap11ProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
|
||||
if (WSConfig.IsSupported (WSProtocol.HttpSoap12))
|
||||
new Soap12ProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
|
||||
if (WSConfig.IsSupported (WSProtocol.HttpGet))
|
||||
new HttpGetProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
|
||||
|
||||
if (WSConfig.IsSupported (WSProtocol.HttpPost))
|
||||
new HttpPostProtocolReflector ().Reflect (this, type, url, schemaExporter, soapSchemaExporter);
|
||||
|
||||
int i=0;
|
||||
while (i < types.Schemas.Count) {
|
||||
if (types.Schemas[i].Items.Count == 0) types.Schemas.RemoveAt (i);
|
||||
else i++;
|
||||
}
|
||||
|
||||
if (serviceDescriptions.Count == 1)
|
||||
serviceDescriptions[0].Types = types;
|
||||
else
|
||||
{
|
||||
foreach (ServiceDescription d in serviceDescriptions)
|
||||
{
|
||||
d.Types = new Types();
|
||||
for (int n=0; n<types.Schemas.Count; n++)
|
||||
ProtocolReflector.AddImport (d, types.Schemas[n].TargetNamespace, GetSchemaUrl (url, n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string GetSchemaUrl (string baseUrl, int id)
|
||||
{
|
||||
return baseUrl + "?schema=" + id;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.SoapExtensionImporter.cs
|
||||
//
|
||||
// Author:
|
||||
// Tim Coleman (tim@timcoleman.com)
|
||||
//
|
||||
// Copyright (C) Tim Coleman, 2002
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.CodeDom;
|
||||
|
||||
namespace System.Web.Services.Description {
|
||||
public abstract class SoapExtensionImporter {
|
||||
|
||||
#region Fields
|
||||
|
||||
SoapProtocolImporter importContext;
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Constructors
|
||||
|
||||
protected SoapExtensionImporter ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public SoapProtocolImporter ImportContext {
|
||||
get { return importContext; }
|
||||
set { importContext = value; }
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
public abstract void ImportMethod (CodeAttributeDeclarationCollection metadata);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.SoapExtensionReflector.cs
|
||||
//
|
||||
// Author:
|
||||
// Tim Coleman (tim@timcoleman.com)
|
||||
//
|
||||
// Copyright (C) Tim Coleman, 2002
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// 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 Fields
|
||||
|
||||
ProtocolReflector reflectionContext;
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Constructors
|
||||
|
||||
protected SoapExtensionReflector ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public ProtocolReflector ReflectionContext {
|
||||
get { return reflectionContext; }
|
||||
set { reflectionContext = value; }
|
||||
}
|
||||
|
||||
#endregion // Properties
|
||||
|
||||
#region Methods
|
||||
|
||||
public
|
||||
virtual void ReflectDescription ()
|
||||
{
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
public
|
||||
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/";
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.SoapHttpTransportImporter.cs
|
||||
//
|
||||
// Author:
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// Copyright (C) Ximian, Inc. 2003
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
namespace System.Web.Services.Description
|
||||
{
|
||||
internal class SoapHttpTransportImporter : SoapTransportImporter
|
||||
{
|
||||
public SoapHttpTransportImporter ()
|
||||
{
|
||||
}
|
||||
|
||||
public override void ImportClass ()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsSupportedTransport (string transport)
|
||||
{
|
||||
return (transport == SoapBinding.HttpTransport);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,227 +0,0 @@
|
||||
//
|
||||
// System.Web.Services.Description.SoapProtocolReflector.cs
|
||||
//
|
||||
// Author:
|
||||
// Tim Coleman (tim@timcoleman.com)
|
||||
// Lluis Sanchez Gual (lluis@ximian.com)
|
||||
//
|
||||
// Copyright (C) Tim Coleman, 2002
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml.Schema;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.Web.Services.Description {
|
||||
|
||||
internal abstract class SoapProtocolReflector : ProtocolReflector
|
||||
{
|
||||
#region Fields
|
||||
|
||||
SoapBinding soapBinding;
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Constructors
|
||||
|
||||
public SoapProtocolReflector ()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
public abstract SoapExtensionReflector ExtensionReflector { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override void BeginClass ()
|
||||
{
|
||||
ExtensionReflector.ReflectDescription ();
|
||||
}
|
||||
|
||||
protected override void EndClass ()
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool ReflectMethod ()
|
||||
{
|
||||
SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
|
||||
bool existing = false;
|
||||
if (Parent != null) {
|
||||
if (Parent.MappedMessagesIn.ContainsKey (method.MethodInfo))
|
||||
existing = true;
|
||||
else {
|
||||
Parent.MappedMessagesIn [method.MethodInfo] = InputMessage;
|
||||
Parent.MappedMessagesOut [method.MethodInfo] = OutputMessage;
|
||||
}
|
||||
}
|
||||
if (!existing)
|
||||
ImportMessageParts ();
|
||||
ExtensionReflector.ReflectMethod ();
|
||||
|
||||
return !existing;
|
||||
}
|
||||
|
||||
void ImportMessageParts ()
|
||||
{
|
||||
SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
|
||||
ImportMessage (method.InputMembersMapping, InputMessage);
|
||||
ImportMessage (method.OutputMembersMapping, OutputMessage);
|
||||
|
||||
|
||||
foreach (SoapHeaderMapping hf in method.Headers)
|
||||
{
|
||||
if (hf.Custom) continue;
|
||||
|
||||
Message msg = new Message ();
|
||||
msg.Name = Operation.Name + hf.HeaderType.Name;
|
||||
MessagePart part = new MessagePart ();
|
||||
part.Name = hf.HeaderType.Name;
|
||||
msg.Parts.Add (part);
|
||||
ServiceDescription.Messages.Add (msg);
|
||||
|
||||
if (method.Use == SoapBindingUse.Literal)
|
||||
{
|
||||
// MS.NET reflects header classes in a weird way. The root element
|
||||
// name is the CLR class name unless it is specified in an XmlRootAttribute.
|
||||
// The usual is to use the xml type name by default, but not in this case.
|
||||
|
||||
XmlRootAttribute root;
|
||||
XmlAttributes ats = new XmlAttributes (hf.HeaderType);
|
||||
if (ats.XmlRoot != null) root = ats.XmlRoot;
|
||||
else root = new XmlRootAttribute (hf.HeaderType.Name);
|
||||
|
||||
if (root.Namespace == null) root.Namespace = TypeInfo.LogicalType.GetWebServiceLiteralNamespace (ServiceDescription.TargetNamespace);
|
||||
if (root.ElementName == null) root.ElementName = hf.HeaderType.Name;
|
||||
|
||||
XmlTypeMapping mapping = ReflectionImporter.ImportTypeMapping (hf.HeaderType, root);
|
||||
part.Element = new XmlQualifiedName (mapping.ElementName, mapping.Namespace);
|
||||
SchemaExporter.ExportTypeMapping (mapping);
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlTypeMapping mapping = SoapReflectionImporter.ImportTypeMapping (hf.HeaderType, TypeInfo.LogicalType.GetWebServiceEncodedNamespace (ServiceDescription.TargetNamespace));
|
||||
part.Type = new XmlQualifiedName (mapping.ElementName, mapping.Namespace);
|
||||
SoapSchemaExporter.ExportTypeMapping (mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ImportMessage (XmlMembersMapping members, Message msg)
|
||||
{
|
||||
SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
|
||||
bool needsEnclosingElement = (method.ParameterStyle == SoapParameterStyle.Wrapped &&
|
||||
method.SoapBindingStyle == SoapBindingStyle.Document);
|
||||
|
||||
if (needsEnclosingElement)
|
||||
{
|
||||
MessagePart part = new MessagePart ();
|
||||
part.Name = "parameters";
|
||||
XmlQualifiedName qname = new XmlQualifiedName (members.ElementName, members.Namespace);
|
||||
if (method.Use == SoapBindingUse.Literal) part.Element = qname;
|
||||
else part.Type = qname;
|
||||
msg.Parts.Add (part);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int n=0; n<members.Count; n++)
|
||||
{
|
||||
MessagePart part = new MessagePart ();
|
||||
part.Name = members[n].MemberName;
|
||||
|
||||
if (method.Use == SoapBindingUse.Literal) {
|
||||
if (members[n].Any)
|
||||
part.Type = new XmlQualifiedName ("any", members[n].Namespace);
|
||||
else
|
||||
part.Element = new XmlQualifiedName (members[n].ElementName, members[n].Namespace);
|
||||
}
|
||||
else {
|
||||
string namesp = members[n].TypeNamespace;
|
||||
if (namesp == "") namesp = members[n].Namespace;
|
||||
part.Name = members[n].ElementName;
|
||||
part.Type = new XmlQualifiedName (members[n].TypeName, namesp);
|
||||
}
|
||||
msg.Parts.Add (part);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (method.Use == SoapBindingUse.Literal)
|
||||
SchemaExporter.ExportMembersMapping (members);
|
||||
else
|
||||
SoapSchemaExporter.ExportMembersMapping (members, needsEnclosingElement);
|
||||
}
|
||||
|
||||
protected override string ReflectMethodBinding ()
|
||||
{
|
||||
return ((SoapMethodStubInfo)MethodStubInfo).Binding;
|
||||
}
|
||||
|
||||
#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; }
|
||||
}
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user