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