Exemplo n.º 1
0
private TreeNode MessageToTreeNode(OperationMessage omsg, SoapBindingUse use)
{			
	Message msg=_services.GetMessage (omsg.Message);
	
	TreeNode node=new TreeNode() ;
	SchemaParser ngen=new SchemaParser(_schemas);
	ngen.BindingUse=use;

	foreach (MessagePart part in msg.Parts)
	{
		if (part.Element == XmlQualifiedName.Empty)
		    {
			TreeNode partNode=ngen.Translate(part.Type);
			partNode.ImageIndex=5;
			partNode.SelectedImageIndex=5;
			partNode.Text=part.Name;
			node.Nodes.Add(partNode);
		     }
		else
		{
		TreeNode partNode=ngen.Translate(part.Element);
		partNode.ImageIndex=5;
		  partNode.SelectedImageIndex=5;

		  partNode.Text=part.Name;
		  node.Nodes.Add(partNode);
		  }

		  }

		return node;			
		}
    void GetOperationFormat(OperationBinding obin, out SoapBindingStyle style, out SoapBindingUse inputUse, out SoapBindingUse outputUse)
    {
        style     = SoapBindingStyle.Document;
        inputUse  = SoapBindingUse.Literal;
        outputUse = SoapBindingUse.Literal;
        if (obin.Extensions != null)
        {
            SoapOperationBinding sob = obin.Extensions.Find(typeof(SoapOperationBinding)) as SoapOperationBinding;
            if (sob != null)
            {
                style = sob.Style;
                if (obin.Input != null)
                {
                    SoapBodyBinding sbb0 = obin.Input.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding;
                    if (sbb0 != null)
                    {
                        inputUse = sbb0.Use;
                    }
                }

                if (obin.Output != null)
                {
                    SoapBodyBinding sbb1 = obin.Output.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding;
                    if (sbb1 != null)
                    {
                        outputUse = sbb1.Use;
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
        void WriteHeader(XmlTextWriter xtw, SoapHeaderBinding header)
        {
            Message msg = descriptions.GetMessage(header.Message);

            if (msg == null)
            {
                throw new InvalidOperationException("Message " + header.Message + " not found");
            }
            MessagePart part = msg.Parts[header.Part];

            if (part == null)
            {
                throw new InvalidOperationException("Message part " + header.Part + " not found in message " + header.Message);
            }

            currentUse = header.Use;

            if (currentUse == SoapBindingUse.Literal)
            {
                WriteRootElementSample(xtw, part.Element);
            }
            else
            {
                WriteTypeSample(xtw, part.Type);
            }
        }
Exemplo n.º 4
0
        public static void WriteSoapMessage(XmlTextWriter xtw, SoapMethodStubInfo method, SoapHeaderDirection dir, object bodyContent, SoapHeaderCollection headers, bool soap12)
        {
            SoapBindingUse methodUse        = dir == SoapHeaderDirection.Fault ? SoapBindingUse.Literal : method.Use;
            XmlSerializer  bodySerializer   = method.GetBodySerializer(dir, soap12);
            XmlSerializer  headerSerializer = method.GetHeaderSerializer(dir);

            object[] headerArray = method.GetHeaderValueArray(dir, headers);
            WriteSoapMessage(xtw, methodUse, bodySerializer, headerSerializer, bodyContent, headerArray, soap12);
        }
Exemplo n.º 5
0
 private void ImportReflectedMethod(SoapReflectedMethod soapMethod)
 {
     this.action                = soapMethod.action;
     this.extensions            = soapMethod.extensions;
     this.extensionInitializers = SoapReflectedExtension.GetInitializers(this.methodInfo, soapMethod.extensions);
     this.oneWay                = soapMethod.oneWay;
     this.rpc        = soapMethod.rpc;
     this.use        = soapMethod.use;
     this.paramStyle = soapMethod.paramStyle;
     this.wsiClaims  = soapMethod.binding == null ? WsiProfiles.None : soapMethod.binding.ConformsTo;
 }
Exemplo n.º 6
0
 internal string GetWebServiceNamespace(string baseNamespace, SoapBindingUse use)
 {
     if (use == SoapBindingUse.Literal)
     {
         return(GetWebServiceLiteralNamespace(baseNamespace));
     }
     else
     {
         return(GetWebServiceEncodedNamespace(baseNamespace));
     }
 }
Exemplo n.º 7
0
        public string GenerateHttpGetMessage(Port port, OperationBinding obin, Operation oper, OperationMessage msg)
        {
            string req = "";

            if (msg is OperationInput)
            {
                HttpAddressBinding   sab = port.Extensions.Find(typeof(HttpAddressBinding)) as HttpAddressBinding;
                HttpOperationBinding sob = obin.Extensions.Find(typeof(HttpOperationBinding)) as HttpOperationBinding;
                string location          = new Uri(sab.Location).AbsolutePath + sob.Location + "?" + BuildQueryString(msg);
                req += "GET " + location + "\n";
                req += "Host: " + GetLiteral("string");
            }
            else
            {
                req += "HTTP/1.0 200 OK\n";
                req += "Content-Type: text/xml; charset=utf-8\n";
                req += "Content-Length: " + GetLiteral("string") + "\n\n";

                MimeXmlBinding mxb = (MimeXmlBinding)obin.Output.Extensions.Find(typeof(MimeXmlBinding)) as MimeXmlBinding;
                if (mxb == null)
                {
                    return(req);
                }

                Message          message = descriptions.GetMessage(msg.Message);
                XmlQualifiedName ename   = null;
                foreach (MessagePart part in message.Parts)
                {
                    if (part.Name == mxb.Part)
                    {
                        ename = part.Element;
                    }
                }

                if (ename == null)
                {
                    return(req + GetLiteral("string"));
                }

                StringWriter  sw  = new StringWriter();
                XmlTextWriter xtw = new XmlTextWriter(sw);
                xtw.Formatting = Formatting.Indented;
                currentUse     = SoapBindingUse.Literal;
                WriteRootElementSample(xtw, ename);
                xtw.Close();
                req += sw.ToString();
            }

            return(req);
        }
Exemplo n.º 8
0
        static void WriteSoapMessage(XmlTextWriter xtw, Object methodStubInfo, SoapHeaderDirection dir, object bodyContent, SoapHeaderCollection headers, bool soap12)
        {
            SoapBindingUse use              = (SoapBindingUse)ReflectionHelper.GetFieldValue(methodStubInfo, "Use");
            SoapBindingUse methodUse        = dir == SoapHeaderDirection.Fault ? SoapBindingUse.Literal : use;
            XmlSerializer  bodySerializer   = (XmlSerializer)ReflectionHelper.ExecuteMethod(methodStubInfo, "GetBodySerializer", null, dir, soap12);
            XmlSerializer  headerSerializer = (XmlSerializer)ReflectionHelper.ExecuteMethod(methodStubInfo, "GetHeaderSerializer", null, dir);

            object[] headerArray = (object[])ReflectionHelper.ExecuteMethod(methodStubInfo, "GetHeaderValueArray", null, dir, headers);



            string ns    = soap12 ? Soap12EnvelopeNamespace : SoapEnvelopeNamespace;
            string encNS = soap12 ? Soap12EncodingNamespace : SoapEncodingNamespace;

            xtw.WriteStartDocument();
            xtw.WriteStartElement("soap", "Envelope", ns);
            xtw.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
            xtw.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace);

            // Serialize headers
            if (headerArray != null)
            {
                xtw.WriteStartElement("soap", "Header", ns);
                headerSerializer.Serialize(xtw, headerArray);
                xtw.WriteEndElement();
            }

            // Serialize body
            xtw.WriteStartElement("soap", "Body", ns);

            if (methodUse == SoapBindingUse.Encoded)
            {
                xtw.WriteAttributeString("encodingStyle", ns, encNS);
            }

            bodySerializer.Serialize(xtw, bodyContent);

            xtw.WriteEndElement();
            xtw.WriteEndElement();
            xtw.Flush();
        }
Exemplo n.º 9
0
        public static void WriteSoapMessage(XmlTextWriter xtw, SoapBindingUse methodUse, XmlSerializer bodySerializer, XmlSerializer headerSerializer, object bodyContent, object[] headers, bool soap12)
        {
            string ns = soap12 ?
                        WebServiceHelper.Soap12EnvelopeNamespace :
                        WebServiceHelper.SoapEnvelopeNamespace;
            string encNS = soap12 ?
                           WebServiceHelper.Soap12EncodingNamespace :
                           WebServiceHelper.SoapEncodingNamespace;

            xtw.WriteStartDocument();
            xtw.WriteStartElement("soap", "Envelope", ns);
            xtw.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
            xtw.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace);

            // Serialize headers
            if (headers != null)
            {
                xtw.WriteStartElement("soap", "Header", ns);
                headerSerializer.Serialize(xtw, headers);
                xtw.WriteEndElement();
            }

            // Serialize body
            xtw.WriteStartElement("soap", "Body", ns);

            if (methodUse == SoapBindingUse.Encoded)
            {
                xtw.WriteAttributeString("encodingStyle", ns, encNS);
            }

            bodySerializer.Serialize(xtw, bodyContent);

            xtw.WriteEndElement();
            xtw.WriteEndElement();
            xtw.Flush();
        }
 public SoapDocumentServiceAttribute(SoapBindingUse use)
 {
     this.use = use;
 }
Exemplo n.º 11
0
        public string GenerateSoapMessage(OperationBinding obin, Operation oper, OperationMessage msg)
        {
            SoapOperationBinding sob   = obin.Extensions.Find(typeof(SoapOperationBinding)) as SoapOperationBinding;
            SoapBindingStyle     style = (sob != null) ? sob.Style : SoapBindingStyle.Document;

            MessageBinding  msgbin  = (msg is OperationInput) ? (MessageBinding)obin.Input : (MessageBinding)obin.Output;
            SoapBodyBinding sbb     = msgbin.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding;
            SoapBindingUse  bodyUse = (sbb != null) ? sbb.Use : SoapBindingUse.Literal;

            StringWriter  sw  = new StringWriter();
            XmlTextWriter xtw = new XmlTextWriter(sw);

            xtw.Formatting = Formatting.Indented;

            xtw.WriteStartDocument();
            xtw.WriteStartElement("soap", "Envelope", SoapEnvelopeNamespace);
            xtw.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
            xtw.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace);

            if (bodyUse == SoapBindingUse.Encoded)
            {
                xtw.WriteAttributeString("xmlns", "soapenc", null, SoapEncodingNamespace);
                xtw.WriteAttributeString("xmlns", "tns", null, msg.Message.Namespace);
            }

            // Serialize headers

            bool writtenHeader = false;

            foreach (object ob in msgbin.Extensions)
            {
                SoapHeaderBinding hb = ob as SoapHeaderBinding;
                if (hb == null)
                {
                    continue;
                }

                if (!writtenHeader)
                {
                    xtw.WriteStartElement("soap", "Header", SoapEnvelopeNamespace);
                    writtenHeader = true;
                }

                WriteHeader(xtw, hb);
            }

            if (writtenHeader)
            {
                xtw.WriteEndElement();
            }

            // Serialize body
            xtw.WriteStartElement("soap", "Body", SoapEnvelopeNamespace);

            currentUse = bodyUse;
            WriteBody(xtw, oper, msg, sbb, style);

            xtw.WriteEndElement();
            xtw.WriteEndElement();
            xtw.Close();
            return(sw.ToString());
        }
Exemplo n.º 12
0
 static XmlMembersMapping ImportMembersMapping(XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, bool serviceDefaultIsEncoded, bool rpc, SoapBindingUse use, SoapParameterStyle paramStyle,
                                               string elementName, string elementNamespace, bool nsIsDefault, XmlReflectionMember[] members, bool validate)
 {
     if (use == SoapBindingUse.Encoded)
     {
         string ns = (!rpc && paramStyle != SoapParameterStyle.Bare && nsIsDefault) ? GetEncodedNamespace(elementNamespace, serviceDefaultIsEncoded) : elementNamespace;
         return(soapImporter.ImportMembersMapping(elementName, ns, members, rpc || paramStyle != SoapParameterStyle.Bare, rpc, validate));
     }
     else
     {
         string ns = nsIsDefault ? GetLiteralNamespace(elementNamespace, serviceDefaultIsEncoded) : elementNamespace;
         return(xmlImporter.ImportMembersMapping(elementName, ns, members, paramStyle != SoapParameterStyle.Bare));
     }
 }
Exemplo n.º 13
0
        public LogicalTypeInfo(Type t)
        {
            this.Type = t;

            object [] o = Type.GetCustomAttributes(typeof(WebServiceAttribute), false);
            if (o.Length == 1)
            {
                WebServiceAttribute a = (WebServiceAttribute)o [0];
                WebServiceName      = (a.Name != string.Empty) ? a.Name : Type.Name;
                WebServiceNamespace = (a.Namespace != string.Empty) ? a.Namespace : WebServiceAttribute.DefaultNamespace;
                Description         = a.Description;
            }
            else
            {
                WebServiceName      = Type.Name;
                WebServiceNamespace = WebServiceAttribute.DefaultNamespace;
            }

            // Determine the namespaces for literal and encoded schema types

            bindingUse = SoapBindingUse.Literal;

            o = t.GetCustomAttributes(typeof(SoapDocumentServiceAttribute), true);
            if (o.Length > 0)
            {
                SoapDocumentServiceAttribute at = (SoapDocumentServiceAttribute)o[0];
                bindingUse = at.Use;
                if (bindingUse == SoapBindingUse.Default)
                {
                    bindingUse = SoapBindingUse.Literal;
                }
                routingStyle = at.RoutingStyle;
            }
            else if (t.GetCustomAttributes(typeof(SoapRpcServiceAttribute), true).Length > 0)
            {
                o = t.GetCustomAttributes(typeof(SoapRpcServiceAttribute), true);
                SoapRpcServiceAttribute at = (SoapRpcServiceAttribute)o[0];
#if NET_2_0
                bindingUse = at.Use;
#else
                bindingUse = SoapBindingUse.Encoded;
#endif
                routingStyle = at.RoutingStyle;
                if (bindingUse == SoapBindingUse.Default)
                {
                    bindingUse = SoapBindingUse.Encoded;
                }
            }
            else
            {
                routingStyle = SoapServiceRoutingStyle.SoapAction;
            }
            string sep = WebServiceNamespace.EndsWith("/") ? "" : "/";

            WebServiceAbstractNamespace = WebServiceNamespace + sep + "AbstractTypes";
#if NET_2_0
            MethodInfo [] type_methods;
            if (typeof(WebClientProtocol).IsAssignableFrom(Type))
            {
                type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public);
            }
            else
            {
                MethodInfo [] all_type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                ArrayList     list             = new ArrayList(all_type_methods.Length);
                foreach (MethodInfo mi in all_type_methods)
                {
                    if (mi.IsPublic && mi.GetCustomAttributes(typeof(WebMethodAttribute), false).Length > 0)
                    {
                        list.Add(mi);
                    }
                    else
                    {
                        foreach (Type ifaceType in Type.GetInterfaces())
                        {
                            if (ifaceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false).Length > 0)
                            {
                                MethodInfo found = FindInInterface(ifaceType, mi);
                                if (found != null)
                                {
                                    if (found.GetCustomAttributes(typeof(WebMethodAttribute), false).Length > 0)
                                    {
                                        list.Add(found);
                                    }

                                    break;
                                }
                            }
                        }
                    }
                }
                type_methods = (MethodInfo [])list.ToArray(typeof(MethodInfo));
            }
#else
            MethodInfo [] type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public);
#endif
            logicalMethods = LogicalMethodInfo.Create(type_methods, LogicalMethodTypes.Sync);
        }
Exemplo n.º 14
0
private void GetOperationFormat(OperationBinding obin, Operation oper, out SoapBindingStyle style,out SoapBindingUse inputUse, out SoapBindingUse outputUse, out string requestMessage, out string responseMessage, out TreeNode requestNode,out TreeNode responseNode)
{
	style=SoapBindingStyle.Document;
	outputUse=SoapBindingUse.Literal;
	inputUse=SoapBindingUse.Literal;
	requestMessage=string.Empty;
	responseMessage=string.Empty;
	requestNode=null;			
	responseNode=null;
	SoapBindingStyle pStyle;
	SoapBindingUse pInputUse, pOutputUse;

	GetOperationFormat (obin, out pStyle, out pInputUse, out pOutputUse  );
	if (oper.Messages.Input != null){
		requestNode=MessageToTreeNode(oper.Messages.Input,  pInputUse);
	}			
	if (oper.Messages.Output != null){
	responseNode=MessageToTreeNode(oper.Messages.Output, pOutputUse  );
	}
		style=pStyle;
		outputUse=pOutputUse;
		inputUse=pInputUse;
	}
Exemplo n.º 15
0
public TreeNode TranslateOperation(Port port, OperationBinding obin, Operation oper, string protocol)
{
	TreeNode tnOperation=new TreeNode (oper.Name, 13 , 13);
	SoapBindingStyle style=new SoapBindingStyle() ;
	SoapBindingUse inputUse=new SoapBindingUse() ;
	SoapBindingUse outputUse=new SoapBindingUse() ;

	string requestmsg=string.Empty;
	string responsemsg=string.Empty;
	TreeNode tnInput=new TreeNode ();
	TreeNode tnOutput=new TreeNode ();			
	TreeNode tnFault=new TreeNode ("Faults");								
	GetOperationFormat (obin, oper, out style,out inputUse,out outputUse, out requestmsg, out responsemsg,out tnInput, out tnOutput);
 
	string operDesc=string.Empty;
	operDesc +=oper.Documentation + "\n";
	operDesc +="Style: " + style.ToString() + "\n" ;
	tnOperation.Tag=operDesc;
	MessageCollection messages=_services[0].Messages;			
	if (oper.Messages.Input != null)
	{
	Message messageIn=messages[oper.Messages.Input.Message.Name] ;			if (messageIn != null )
	{					
	if (tnInput == null) tnInput=new TreeNode() ;			
	tnInput.Tag=requestmsg;	
	tnInput.ImageIndex=13;
	tnInput.SelectedImageIndex=13;
	if (oper.Messages.Input.Name != null && oper.Messages.Input.Name != string.Empty)
	{
		tnInput.Text="Input: " + oper.Messages.Input.Name ;
	}
	Else{
	tnInput.Text="Input: " + oper.Messages.Input.Message.Name ;
	if (tnInput != null) tnOperation.Nodes.Add  (tnInput );
	};
	};

	if (oper.Messages.Output != null)
	{
	Message messageOut=messages[oper.Messages.Output.Message.Name] ;
	if (messageOut != null )
	{				

	if (tnOutput == null) tnOutput=new TreeNode() ;	
	tnOutput.Tag=responsemsg;
	tnOutput.ImageIndex=13;
	tnOutput.SelectedImageIndex=13;

	if (oper.Messages.Output.Name != null &&     oper.Messages.Output.Name != string.Empty)
	{
	tnOutput.Text="Output: " + oper.Messages.Output.Name ;
	}
	else
	tnOutput.Text="Output: " + oper.Messages.Output.Message.Name ;
	if (tnOutput != null) tnOperation.Nodes.Add  (tnOutput );
	};

	};
		
	foreach (OperationFault faultOp in  oper.Faults)
	{				
	Message messageFault=messages[faultOp.Message.Name] ;
	if (messageFault != null )				
	{					

	TreeNode treeNode=new TreeNode() ;			

	tnFault.ImageIndex=14;
	tnFault.SelectedImageIndex=14;
	if (treeNode != null)
	tnFault.Nodes.Add (treeNode);
	};
 
	};

	if (tnFault.Nodes.Count > 0 ) tnOperation.Nodes.Add  (tnFault );

	return tnOperation;			
			
	}
Exemplo n.º 16
0
 public SoapDocumentServiceAttribute()
 {
     paramStyle   = SoapParameterStyle.Wrapped;
     routingStyle = SoapServiceRoutingStyle.SoapAction;
     use          = SoapBindingUse.Literal;
 }
 public SoapDocumentServiceAttribute(SoapBindingUse use, SoapParameterStyle paramStyle)
 {
     this.use        = use;
     this.paramStyle = paramStyle;
 }
 public SoapRpcMethodAttribute()
 {
     this.use = SoapBindingUse.Encoded;
 }
 public SoapRpcMethodAttribute(string action)
 {
     this.use    = SoapBindingUse.Encoded;
     this.action = action;
 }
Exemplo n.º 20
0
        //
        // Constructor
        //
        public SoapMethodStubInfo(TypeStubInfo typeStub, LogicalMethodInfo source, object kind, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter)
            : base(typeStub, source)
        {
            SoapTypeStubInfo    parent      = (SoapTypeStubInfo)typeStub;
            XmlElementAttribute optional_ns = null;

            if (kind == null)
            {
                Use               = parent.LogicalType.BindingUse;
                RequestName       = "";
                RequestNamespace  = "";
                ResponseName      = "";
                ResponseNamespace = "";
                ParameterStyle    = parent.ParameterStyle;
                SoapBindingStyle  = parent.SoapBindingStyle;
                OneWay            = false;
// disabled (see bug #332150)
//#if NET_2_0
//				if (parent.Type != source.DeclaringType)
//					Binding = source.DeclaringType.Name + parent.ProtocolName;
//#endif
            }
            else if (kind is SoapDocumentMethodAttribute)
            {
                SoapDocumentMethodAttribute dma = (SoapDocumentMethodAttribute)kind;

                Use = dma.Use;
                if (Use == SoapBindingUse.Default)
                {
                    if (parent.SoapBindingStyle == SoapBindingStyle.Document)
                    {
                        Use = parent.LogicalType.BindingUse;
                    }
                    else
                    {
                        Use = SoapBindingUse.Literal;
                    }
                }

                Action            = dma.Action;
                Binding           = dma.Binding;
                RequestName       = dma.RequestElementName;
                RequestNamespace  = dma.RequestNamespace;
                ResponseName      = dma.ResponseElementName;
                ResponseNamespace = dma.ResponseNamespace;
                ParameterStyle    = dma.ParameterStyle;
                if (ParameterStyle == SoapParameterStyle.Default)
                {
                    ParameterStyle = parent.ParameterStyle;
                }
                OneWay           = dma.OneWay;
                SoapBindingStyle = SoapBindingStyle.Document;
            }
            else
            {
                SoapRpcMethodAttribute rma = (SoapRpcMethodAttribute)kind;
                Use = SoapBindingUse.Encoded;                   // RPC always use encoded

                Action = rma.Action;
                if (Action != null && Action.Length == 0)
                {
                    Action = null;
                }
                Binding = rma.Binding;

                // When using RPC, MS.NET seems to ignore RequestElementName and
                // MessageName, and it always uses the method name
                RequestName  = source.Name;
                ResponseName = source.Name + "Response";
//				RequestName = rma.RequestElementName;
//				ResponseName = rma.ResponseElementName;
                RequestNamespace  = rma.RequestNamespace;
                ResponseNamespace = rma.ResponseNamespace;
                ParameterStyle    = SoapParameterStyle.Wrapped;
                OneWay            = rma.OneWay;
                SoapBindingStyle  = SoapBindingStyle.Rpc;

                // For RPC calls, make all arguments be part of the empty namespace
                optional_ns           = new XmlElementAttribute();
                optional_ns.Namespace = "";
            }

            if (OneWay)
            {
                if (source.ReturnType != typeof(void))
                {
                    throw new Exception("OneWay methods should not have a return value.");
                }
                if (source.OutParameters.Length != 0)
                {
                    throw new Exception("OneWay methods should not have out/ref parameters.");
                }
            }

            BindingInfo binfo = parent.GetBinding(Binding);

            if (binfo == null)
            {
                throw new InvalidOperationException("Type '" + parent.Type + "' is missing WebServiceBinding attribute that defines a binding named '" + Binding + "'.");
            }

            string serviceNamespace = binfo.Namespace;

            if (RequestNamespace == "")
            {
                RequestNamespace = parent.LogicalType.GetWebServiceNamespace(serviceNamespace, Use);
            }
            if (ResponseNamespace == "")
            {
                ResponseNamespace = parent.LogicalType.GetWebServiceNamespace(serviceNamespace, Use);
            }
            if (RequestName == "")
            {
                RequestName = Name;
            }
            if (ResponseName == "")
            {
                ResponseName = Name + "Response";
            }
            if (Action == null)
            {
                Action = serviceNamespace.EndsWith("/") ? (serviceNamespace + Name) : (serviceNamespace + "/" + Name);
            }

            bool hasWrappingElem = (ParameterStyle == SoapParameterStyle.Wrapped);
            bool writeAccessors  = (SoapBindingStyle == SoapBindingStyle.Rpc);

            XmlReflectionMember [] in_members  = BuildRequestReflectionMembers(optional_ns);
            XmlReflectionMember [] out_members = BuildResponseReflectionMembers(optional_ns);

            if (Use == SoapBindingUse.Literal)
            {
                xmlImporter.IncludeTypes(source.CustomAttributeProvider);
                InputMembersMapping  = xmlImporter.ImportMembersMapping(RequestName, RequestNamespace, in_members, hasWrappingElem);
                OutputMembersMapping = xmlImporter.ImportMembersMapping(ResponseName, ResponseNamespace, out_members, hasWrappingElem);
            }
            else
            {
                soapImporter.IncludeTypes(source.CustomAttributeProvider);
                InputMembersMapping  = soapImporter.ImportMembersMapping(RequestName, RequestNamespace, in_members, hasWrappingElem, writeAccessors);
                OutputMembersMapping = soapImporter.ImportMembersMapping(ResponseName, ResponseNamespace, out_members, hasWrappingElem, writeAccessors);
            }

            requestSerializerId  = parent.RegisterSerializer(InputMembersMapping);
            responseSerializerId = parent.RegisterSerializer(OutputMembersMapping);

            object[]  o               = source.GetCustomAttributes(typeof(SoapHeaderAttribute));
            ArrayList allHeaderList   = new ArrayList(o.Length);
            ArrayList inHeaderList    = new ArrayList(o.Length);
            ArrayList outHeaderList   = new ArrayList(o.Length);
            ArrayList faultHeaderList = new ArrayList();

            SoapHeaderDirection unknownHeaderDirections = (SoapHeaderDirection)0;

            for (int i = 0; i < o.Length; i++)
            {
                SoapHeaderAttribute att  = (SoapHeaderAttribute)o[i];
                MemberInfo[]        mems = source.DeclaringType.GetMember(att.MemberName);
                if (mems.Length == 0)
                {
                    throw new InvalidOperationException("Member " + att.MemberName + " not found in class " + source.DeclaringType.FullName + ".");
                }

                HeaderInfo header = new HeaderInfo(mems[0], att);
                allHeaderList.Add(header);
                if (!header.Custom)
                {
                    if ((header.Direction & SoapHeaderDirection.In) != 0)
                    {
                        inHeaderList.Add(header);
                    }
                    if ((header.Direction & SoapHeaderDirection.Out) != 0)
                    {
                        outHeaderList.Add(header);
                    }
                    if ((header.Direction & SoapHeaderDirection.Fault) != 0)
                    {
                        faultHeaderList.Add(header);
                    }
                }
                else
                {
                    unknownHeaderDirections |= header.Direction;
                }
            }

            Headers = (HeaderInfo[])allHeaderList.ToArray(typeof(HeaderInfo));

            if (inHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.In) != 0)
            {
                InHeaders = (HeaderInfo[])inHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(InHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    InputHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    InputHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                requestHeadersSerializerId = parent.RegisterSerializer(InputHeaderMembersMapping);
            }

            if (outHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Out) != 0)
            {
                OutHeaders = (HeaderInfo[])outHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(OutHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    OutputHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    OutputHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                responseHeadersSerializerId = parent.RegisterSerializer(OutputHeaderMembersMapping);
            }

            if (faultHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Fault) != 0)
            {
                FaultHeaders = (HeaderInfo[])faultHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(FaultHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    FaultHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    FaultHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                faultHeadersSerializerId = parent.RegisterSerializer(FaultHeaderMembersMapping);
            }

            SoapExtensions = SoapExtension.GetMethodExtensions(source);
        }
        private static XmlMembersMapping ImportMembersMapping(XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, bool serviceDefaultIsEncoded, bool rpc, SoapBindingUse use, SoapParameterStyle paramStyle, string elementName, string elementNamespace, bool nsIsDefault, XmlReflectionMember[] members, bool validate, bool openModel, string key, bool writeAccess)
        {
            XmlMembersMapping mapping = null;

            if (use == SoapBindingUse.Encoded)
            {
                string ns = ((!rpc && (paramStyle != SoapParameterStyle.Bare)) && nsIsDefault) ? GetEncodedNamespace(elementNamespace, serviceDefaultIsEncoded) : elementNamespace;
                mapping = soapImporter.ImportMembersMapping(elementName, ns, members, rpc || (paramStyle != SoapParameterStyle.Bare), rpc, validate, writeAccess ? XmlMappingAccess.Write : XmlMappingAccess.Read);
            }
            else
            {
                string str2 = nsIsDefault ? GetLiteralNamespace(elementNamespace, serviceDefaultIsEncoded) : elementNamespace;
                mapping = xmlImporter.ImportMembersMapping(elementName, str2, members, paramStyle != SoapParameterStyle.Bare, rpc, openModel, writeAccess ? XmlMappingAccess.Write : XmlMappingAccess.Read);
            }
            if (mapping != null)
            {
                mapping.SetKey(key);
            }
            return(mapping);
        }