// returns true if src is an expected type; updates src in place; should handle null
            internal static bool ConvertSoapOperationBinding(ref object src, EnvelopeVersion version)
            {
                WsdlNS.SoapOperationBinding binding = src as WsdlNS.SoapOperationBinding;

                if (src != null)
                {
                    if (binding == null)
                    {
                        return(false); // no match
                    }
                    else if (GetBindingVersion <WsdlNS.Soap12OperationBinding>(src) == version)
                    {
                        return(true); // matched but same version
                    }
                }

                if (version == EnvelopeVersion.None)
                {
                    src = null;
                    return(true);
                }

                WsdlNS.SoapOperationBinding dest = version == EnvelopeVersion.Soap12 ? new WsdlNS.Soap12OperationBinding() : new WsdlNS.SoapOperationBinding();
                if (src != null)
                {
                    dest.Required   = binding.Required;
                    dest.Style      = binding.Style;
                    dest.SoapAction = binding.SoapAction;
                }

                src = dest;
                return(true);
            }
예제 #2
0
        static void TestSoap(WS.SoapOperationBinding soap, bool soap12, TestLabel label)
        {
            label.EnterScope("soap");
            var type = soap12 ? typeof(WS.Soap12OperationBinding) : typeof(WS.SoapOperationBinding);

            Assert.That(soap.GetType(), Is.EqualTo(type), label.Get());
            Assert.That(soap.Style, Is.EqualTo(WS.SoapBindingStyle.Document), label.Get());
            Assert.That(soap.SoapAction, Is.EqualTo("http://tempuri.org/IMyContract/Hello"), label.Get());
            Assert.That(soap.Required, Is.False, label.Get());
            label.LeaveScope();
        }
 internal static WsdlNS.SoapBindingStyle GetStyle(WsdlNS.OperationBinding operationBinding, WsdlNS.SoapBindingStyle defaultBindingStyle)
 {
     WsdlNS.SoapBindingStyle style = defaultBindingStyle;
     if (operationBinding != null)
     {
         WsdlNS.SoapOperationBinding soapOperationBinding = operationBinding.Extensions.Find(typeof(WsdlNS.SoapOperationBinding)) as WsdlNS.SoapOperationBinding;
         if (soapOperationBinding != null)
         {
             if (soapOperationBinding.Style != WsdlNS.SoapBindingStyle.Default)
             {
                 style = soapOperationBinding.Style;
             }
         }
     }
     return(style);
 }
        static WsdlNS.SoapOperationBinding CreateSoapOperationBinding(EnvelopeVersion version, WsdlNS.OperationBinding wsdlOperationBinding)
        {
            WsdlNS.SoapOperationBinding soapOperationBinding = null;

            if (version == EnvelopeVersion.Soap12)
            {
                soapOperationBinding = new WsdlNS.Soap12OperationBinding();
            }
            else if (version == EnvelopeVersion.Soap11)
            {
                soapOperationBinding = new WsdlNS.SoapOperationBinding();
            }
            Fx.Assert(soapOperationBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class");

            wsdlOperationBinding.Extensions.Add(soapOperationBinding);
            return(soapOperationBinding);
        }
        internal static WsdlNS.SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation, WsdlExporter exporter)
        {
            if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None)
            {
                return(null);
            }

            WsdlNS.SoapOperationBinding existingSoapOperationBinding = GetSoapOperationBinding(endpointContext, operation);
            WsdlNS.OperationBinding     wsdlOperationBinding         = endpointContext.GetOperationBinding(operation);
            EnvelopeVersion             version = GetSoapVersion(endpointContext.WsdlBinding);

            if (existingSoapOperationBinding != null)
            {
                return(existingSoapOperationBinding);
            }

            WsdlNS.SoapOperationBinding soapOperationBinding = CreateSoapOperationBinding(version, wsdlOperationBinding);
            return(soapOperationBinding);
        }
 protected virtual SoapOperationBinding CreateSoapOperationBinding(SoapBindingStyle style, string action) {
     SoapOperationBinding soapOperation = new SoapOperationBinding();
     soapOperation.SoapAction = action;
     soapOperation.Style = style;
     return soapOperation;
 }
예제 #7
0
		void CreateInputBinding (ServiceEndpoint endpoint, OperationBinding op_binding,
		                         MessageDescription sm_md)
		{
			var in_binding = new InputBinding ();
			op_binding.Input = in_binding;

			var message_version = endpoint.Binding.MessageVersion ?? MessageVersion.None;
			if (message_version == MessageVersion.None)
				return;

			SoapBodyBinding soap_body_binding;
			SoapOperationBinding soap_operation_binding;
			if (message_version.Envelope == EnvelopeVersion.Soap11) {
				soap_body_binding = new SoapBodyBinding ();
				soap_operation_binding = new SoapOperationBinding ();
			} else if (message_version.Envelope == EnvelopeVersion.Soap12) {
				soap_body_binding = new Soap12BodyBinding ();
				soap_operation_binding = new Soap12OperationBinding ();
			} else {
				throw new InvalidOperationException ();
			}

			soap_body_binding.Use = SoapBindingUse.Literal;
			in_binding.Extensions.Add (soap_body_binding);
				
			//Set Action
			//<operation > <soap:operation soapAction .. >
			soap_operation_binding.SoapAction = sm_md.Action;
			soap_operation_binding.Style = SoapBindingStyle.Document;
			op_binding.Extensions.Add (soap_operation_binding);
		}
		CodeMemberMethod GenerateMethod (CodeIdentifiers memberIds, SoapOperationBinding soapOper, SoapBodyBinding bodyBinding, XmlMembersMapping inputMembers, XmlMembersMapping outputMembers)
		{
			CodeIdentifiers pids = new CodeIdentifiers ();
			CodeMemberMethod method = new CodeMemberMethod ();
			CodeMemberMethod methodBegin = new CodeMemberMethod ();
			CodeMemberMethod methodEnd = new CodeMemberMethod ();
			method.Attributes = MemberAttributes.Public | MemberAttributes.Final;
			methodBegin.Attributes = MemberAttributes.Public | MemberAttributes.Final;
			methodEnd.Attributes = MemberAttributes.Public | MemberAttributes.Final;
			
			SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;
			
			// Find unique names for temporary variables
			
			for (int n=0; n<inputMembers.Count; n++)
				pids.AddUnique (inputMembers[n].MemberName, inputMembers[n]);

			if (outputMembers != null)
				for (int n=0; n<outputMembers.Count; n++)
					pids.AddUnique (outputMembers[n].MemberName, outputMembers[n]);
				
			string varAsyncResult = pids.AddUnique ("asyncResult","asyncResult");
			string varResults = pids.AddUnique ("results","results");
			string varCallback = pids.AddUnique ("callback","callback");
			string varAsyncState = pids.AddUnique ("asyncState","asyncState");

			string messageName = memberIds.AddUnique(CodeIdentifier.MakeValid(Operation.Name),method);

			method.Name = CodeIdentifier.MakeValid(Operation.Name);
			if (method.Name == ClassName) method.Name += "1";
			methodBegin.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("Begin" + method.Name),method);
			methodEnd.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("End" + method.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];
			CodeParameterDeclarationExpression[] outParams = new CodeParameterDeclarationExpression [outputMembers != null ? outputMembers.Count : 0];

			for (int n=0; n<inputMembers.Count; n++)
			{
				CodeParameterDeclarationExpression param = GenerateParameter (inputMembers[n], FieldDirection.In);
				method.Parameters.Add (param);
				GenerateMemberAttributes (inputMembers, inputMembers[n], bodyBinding.Use, param);
				methodBegin.Parameters.Add (GenerateParameter (inputMembers[n], FieldDirection.In));
				paramArray [n] = new CodeVariableReferenceExpression (param.Name);
			}

			if (outputMembers != null)
			{
				bool hasReturn = false;
				for (int n=0; n<outputMembers.Count; n++)
				{
					CodeParameterDeclarationExpression cpd = GenerateParameter (outputMembers[n], FieldDirection.Out);
					outParams [n] = cpd;
					
					bool found = false;
					foreach (CodeParameterDeclarationExpression ip in method.Parameters)
					{
						if (ip.Name == cpd.Name && ip.Type.BaseType == cpd.Type.BaseType) {
							ip.Direction = FieldDirection.Ref;
							methodEnd.Parameters.Add (GenerateParameter (outputMembers[n], FieldDirection.Out));
							found = true;
							break;
						}
					}
					
					if (found) continue;
	
					if (!hasReturn) 
					{
						hasReturn = true;
						method.ReturnType = cpd.Type;
						methodEnd.ReturnType = cpd.Type;
						GenerateReturnAttributes (outputMembers, outputMembers[n], bodyBinding.Use, method);
						outParams [n] = null;
						continue;
					}
					
					method.Parameters.Add (cpd);
					GenerateMemberAttributes (outputMembers, outputMembers[n], bodyBinding.Use, cpd);
					methodEnd.Parameters.Add (GenerateParameter (outputMembers[n], FieldDirection.Out));
				}
			}
			
			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);

			// Assignment of output parameters
			
			CodeStatementCollection outAssign = new CodeStatementCollection ();
			CodeVariableReferenceExpression arrVar = new CodeVariableReferenceExpression (varResults);
			for (int n=0; n<outParams.Length; n++)
			{
				CodeExpression index = new CodePrimitiveExpression (n);
				if (outParams[n] == null)
				{
					CodeExpression res = new CodeCastExpression (method.ReturnType, new CodeArrayIndexerExpression (arrVar, index));
					outAssign.Add (new CodeMethodReturnStatement (res));
				}
				else
				{
					CodeExpression res = new CodeCastExpression (outParams[n].Type, new CodeArrayIndexerExpression (arrVar, index));
					CodeExpression var = new CodeVariableReferenceExpression (outParams[n].Name);
					outAssign.Insert (0, new CodeAssignStatement (var, res));
				}
			}
			
			if (Style == ServiceDescriptionImportStyle.Client) 
			{
				// Invoke call
				
				CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
				CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
				CodeMethodInvokeExpression inv;
				CodeVariableDeclarationStatement dec;
	
				inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, methodParams);
				if (outputMembers != null && outputMembers.Count > 0)
				{
					dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
					method.Statements.Add (dec);
					method.Statements.AddRange (outAssign);
				}
				else
					method.Statements.Add (inv);
				
				// Begin Invoke Call
				
				CodeExpression expCallb = new CodeVariableReferenceExpression (varCallback);
				CodeExpression expAsyncs = new CodeVariableReferenceExpression (varAsyncState);
				inv = new CodeMethodInvokeExpression (ethis, "BeginInvoke", varMsgName, methodParams, expCallb, expAsyncs);
				methodBegin.Statements.Add (new CodeMethodReturnStatement (inv));
				
				// End Invoke call
				
				CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
				inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
				if (outputMembers != null && outputMembers.Count > 0)
				{
					dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
					methodEnd.Statements.Add (dec);
					methodEnd.Statements.AddRange (outAssign);
				}
				else
					methodEnd.Statements.Add (inv);
			}
			else {
				method.Attributes = MemberAttributes.Public | MemberAttributes.Abstract;
			}
			
			// Attributes
			
			ImportHeaders (method);
			
			CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.WebMethodAttribute");
			if (messageName != method.Name) att.Arguments.Add (GetArg ("MessageName",messageName));
			AddCustomAttribute (method, att, (Style == ServiceDescriptionImportStyle.Server));
			
			if (style == SoapBindingStyle.Rpc)
			{
				att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapRpcMethodAttribute");
				att.Arguments.Add (GetArg (soapOper.SoapAction));
				if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
				if (outputMembers != null && outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
				att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
				if (outputMembers != null) att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
				if (outputMembers == null) att.Arguments.Add (GetArg ("OneWay", true));
			}
			else
			{
				if (outputMembers != null && (inputMembers.ElementName == "" && outputMembers.ElementName != "" || 
					inputMembers.ElementName != "" && outputMembers.ElementName == ""))
					throw new InvalidOperationException ("Parameter style is not the same for the input message and output message");
	
				att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapDocumentMethodAttribute");
				att.Arguments.Add (GetArg (soapOper.SoapAction));
				if (inputMembers.ElementName != "") {
					if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
					if (outputMembers != null && outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
					att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
					if (outputMembers != null) att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
					att.Arguments.Add (GetEnumArg ("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Wrapped"));
				}
				else
					att.Arguments.Add (GetEnumArg ("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Bare"));
					
				if (outputMembers == null) att.Arguments.Add (GetArg ("OneWay", true));
					
				att.Arguments.Add (GetEnumArg ("Use", "System.Web.Services.Description.SoapBindingUse", bodyBinding.Use.ToString()));
			}
			
			AddCustomAttribute (method, att, true);
			
			CodeTypeDeclaration.Members.Add (method);
			
			if (Style == ServiceDescriptionImportStyle.Client) {
				CodeTypeDeclaration.Members.Add (methodBegin);
				CodeTypeDeclaration.Members.Add (methodEnd);
			}
			
			return method;
		}
 internal static string ReadSoapAction(WsdlNS.OperationBinding wsdlOperationBinding)
 {
     WsdlNS.SoapOperationBinding soapOperationBinding = (WsdlNS.SoapOperationBinding)wsdlOperationBinding.Extensions.Find(typeof(WsdlNS.SoapOperationBinding));
     return(soapOperationBinding != null ? soapOperationBinding.SoapAction : null);
 }
예제 #10
0
        internal static bool AnalyzeBinding(Binding binding, ServiceDescription description, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
        {
            bool        flag     = false;
            bool        flag2    = false;
            SoapBinding binding2 = (SoapBinding)binding.Extensions.Find(typeof(SoapBinding));

            if ((binding2 == null) || (binding2.GetType() != typeof(SoapBinding)))
            {
                return(false);
            }
            SoapBindingStyle style = (binding2.Style == SoapBindingStyle.Default) ? SoapBindingStyle.Document : binding2.Style;

            if (binding2.Transport.Length == 0)
            {
                violations.Add("R2701", System.Web.Services.Res.GetString("BindingMissingAttribute", new object[] { binding.Name, description.TargetNamespace, "transport" }));
            }
            else if (binding2.Transport != "http://schemas.xmlsoap.org/soap/http")
            {
                violations.Add("R2702", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "transport", binding2.Transport }));
            }
            PortType  portType  = descriptions.GetPortType(binding.Type);
            Hashtable hashtable = new Hashtable();

            if (portType != null)
            {
                foreach (Operation operation in portType.Operations)
                {
                    if (operation.Messages.Flow == OperationFlow.Notification)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowNotification", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (operation.Messages.Flow == OperationFlow.SolicitResponse)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowSolicitResponse", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (hashtable[operation.Name] != null)
                    {
                        violations.Add("R2304", System.Web.Services.Res.GetString("Operation", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                    }
                    else
                    {
                        OperationBinding binding3 = null;
                        foreach (OperationBinding binding4 in binding.Operations)
                        {
                            if (operation.IsBoundBy(binding4))
                            {
                                if (binding3 != null)
                                {
                                    violations.Add("R2304", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding3.Name, binding3.Parent.Name, description.TargetNamespace }));
                                }
                                binding3 = binding4;
                            }
                        }
                        if (binding3 == null)
                        {
                            violations.Add("R2718", System.Web.Services.Res.GetString("OperationMissingBinding", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                        }
                        else
                        {
                            hashtable.Add(operation.Name, operation);
                        }
                    }
                }
            }
            Hashtable        wireSignatures = new Hashtable();
            SoapBindingStyle style2         = SoapBindingStyle.Default;

            foreach (OperationBinding binding5 in binding.Operations)
            {
                SoapBindingStyle style3 = style;
                string           name   = binding5.Name;
                if (name != null)
                {
                    if (hashtable[name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                    Operation            operation2 = FindOperation(portType.Operations, binding5);
                    SoapOperationBinding binding6   = (SoapOperationBinding)binding5.Extensions.Find(typeof(SoapOperationBinding));
                    if (binding6 != null)
                    {
                        if (style2 == SoapBindingStyle.Default)
                        {
                            style2 = binding6.Style;
                        }
                        flag  |= style2 != binding6.Style;
                        style3 = (binding6.Style != SoapBindingStyle.Default) ? binding6.Style : style;
                    }
                    if (binding5.Input != null)
                    {
                        SoapBodyBinding binding7 = FindSoapBodyBinding(true, binding5.Input.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding7 != null) && (binding7.Use != SoapBindingUse.Encoded))
                        {
                            Message message = (operation2 == null) ? null : ((operation2.Messages.Input == null) ? null : descriptions.GetMessage(operation2.Messages.Input.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message, binding7.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding7.Parts != null) && (binding7.Parts.Length > 1));
                                int num = (binding7.Parts == null) ? 0 : binding7.Parts.Length;
                                CheckMessageParts(message, binding7.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                                if (((num == 0) && (message != null)) && (message.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    if (binding5.Output != null)
                    {
                        SoapBodyBinding binding8 = FindSoapBodyBinding(false, binding5.Output.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding8 != null) && (binding8.Use != SoapBindingUse.Encoded))
                        {
                            Message message2 = (operation2 == null) ? null : ((operation2.Messages.Output == null) ? null : descriptions.GetMessage(operation2.Messages.Output.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message2, binding8.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding8.Parts != null) && (binding8.Parts.Length > 1));
                                int num2 = (binding8.Parts == null) ? 0 : binding8.Parts.Length;
                                CheckMessageParts(message2, binding8.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                                if (((num2 == 0) && (message2 != null)) && (message2.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    foreach (FaultBinding binding9 in binding5.Faults)
                    {
                        foreach (ServiceDescriptionFormatExtension extension in binding9.Extensions)
                        {
                            if (extension is SoapFaultBinding)
                            {
                                SoapFaultBinding item = (SoapFaultBinding)extension;
                                if (item.Use == SoapBindingUse.Encoded)
                                {
                                    violations.Add("R2706", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                }
                                else
                                {
                                    if ((item.Name == null) || (item.Name.Length == 0))
                                    {
                                        violations.Add("R2721", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    else if (item.Name != binding9.Name)
                                    {
                                        violations.Add("R2754", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    if ((item.Namespace != null) && (item.Namespace.Length > 0))
                                    {
                                        violations.Add((style3 == SoapBindingStyle.Document) ? "R2716" : "R2726", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                    }
                                }
                            }
                        }
                    }
                    if (hashtable[binding5.Name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                }
            }
            if (flag2)
            {
                violations.Add("R2201", System.Web.Services.Res.GetString("BindingMultipleParts", new object[] { binding.Name, description.TargetNamespace, "parts" }));
            }
            if (flag)
            {
                violations.Add("R2705", System.Web.Services.Res.GetString("Binding", new object[] { binding.Name, description.TargetNamespace }));
            }
            return(true);
        }
 private void Write86_SoapOperationBinding(string n, string ns, SoapOperationBinding o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && !(o.GetType() == typeof(SoapOperationBinding)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.WriteStartElement(n, ns, o, false, null);
         if (needType)
         {
             base.WriteXsiType("SoapOperationBinding", "http://schemas.xmlsoap.org/wsdl/soap/");
         }
         if (o.Required)
         {
             base.WriteAttribute("required", "http://schemas.xmlsoap.org/wsdl/", XmlConvert.ToString(o.Required));
         }
         base.WriteAttribute("soapAction", "", o.SoapAction);
         if (o.Style != SoapBindingStyle.Default)
         {
             base.WriteAttribute("style", "", this.Write79_SoapBindingStyle(o.Style));
         }
         base.WriteEndElement(o);
     }
 }
예제 #12
0
        CodeMemberMethod GenerateMethod(CodeIdentifiers memberIds, SoapOperationBinding soapOper, SoapBodyBinding bodyBinding, XmlMembersMapping inputMembers, XmlMembersMapping outputMembers)
        {
            CodeIdentifiers  pids        = new CodeIdentifiers();
            CodeMemberMethod method      = new CodeMemberMethod();
            CodeMemberMethod methodBegin = new CodeMemberMethod();
            CodeMemberMethod methodEnd   = new CodeMemberMethod();

            method.Attributes      = MemberAttributes.Public | MemberAttributes.Final;
            methodBegin.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            methodEnd.Attributes   = MemberAttributes.Public | MemberAttributes.Final;

            SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;

            // Find unique names for temporary variables

            for (int n = 0; n < inputMembers.Count; n++)
            {
                pids.AddUnique(inputMembers[n].MemberName, inputMembers[n]);
            }

            if (outputMembers != null)
            {
                for (int n = 0; n < outputMembers.Count; n++)
                {
                    pids.AddUnique(outputMembers[n].MemberName, outputMembers[n]);
                }
            }

            string varAsyncResult = pids.AddUnique("asyncResult", "asyncResult");
            string varResults     = pids.AddUnique("results", "results");
            string varCallback    = pids.AddUnique("callback", "callback");
            string varAsyncState  = pids.AddUnique("asyncState", "asyncState");

            string messageName = memberIds.AddUnique(CodeIdentifier.MakeValid(Operation.Name), method);

            method.Name = CodeIdentifier.MakeValid(Operation.Name);
            if (method.Name == ClassName)
            {
                method.Name += "1";
            }
            methodBegin.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("Begin" + method.Name), method);
            methodEnd.Name   = memberIds.AddUnique(CodeIdentifier.MakeValid("End" + method.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];
            CodeParameterDeclarationExpression[] outParams = new CodeParameterDeclarationExpression [outputMembers != null ? outputMembers.Count : 0];

            for (int n = 0; n < inputMembers.Count; n++)
            {
                CodeParameterDeclarationExpression param = GenerateParameter(inputMembers[n], FieldDirection.In);
                method.Parameters.Add(param);
                GenerateMemberAttributes(inputMembers, inputMembers[n], bodyBinding.Use, param);
                methodBegin.Parameters.Add(GenerateParameter(inputMembers[n], FieldDirection.In));
                paramArray [n] = new CodeVariableReferenceExpression(param.Name);
            }

            if (outputMembers != null)
            {
                bool hasReturn = false;
                for (int n = 0; n < outputMembers.Count; n++)
                {
                    CodeParameterDeclarationExpression cpd = GenerateParameter(outputMembers[n], FieldDirection.Out);
                    outParams [n] = cpd;

                    bool found = false;
                    foreach (CodeParameterDeclarationExpression ip in method.Parameters)
                    {
                        if (ip.Name == cpd.Name && ip.Type.BaseType == cpd.Type.BaseType)
                        {
                            ip.Direction = FieldDirection.Ref;
                            methodEnd.Parameters.Add(GenerateParameter(outputMembers[n], FieldDirection.Out));
                            found = true;
                            break;
                        }
                    }

                    if (found)
                    {
                        continue;
                    }

                    if (!hasReturn)
                    {
                        hasReturn            = true;
                        method.ReturnType    = cpd.Type;
                        methodEnd.ReturnType = cpd.Type;
                        GenerateReturnAttributes(outputMembers, outputMembers[n], bodyBinding.Use, method);
                        outParams [n] = null;
                        continue;
                    }

                    method.Parameters.Add(cpd);
                    GenerateMemberAttributes(outputMembers, outputMembers[n], bodyBinding.Use, cpd);
                    methodEnd.Parameters.Add(GenerateParameter(outputMembers[n], FieldDirection.Out));
                }
            }

            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);
            }

            // Assignment of output parameters

            CodeStatementCollection         outAssign = new CodeStatementCollection();
            CodeVariableReferenceExpression arrVar    = new CodeVariableReferenceExpression(varResults);

            for (int n = 0; n < outParams.Length; n++)
            {
                CodeExpression index = new CodePrimitiveExpression(n);
                if (outParams[n] == null)
                {
                    CodeExpression res = new CodeCastExpression(method.ReturnType, new CodeArrayIndexerExpression(arrVar, index));
                    outAssign.Add(new CodeMethodReturnStatement(res));
                }
                else
                {
                    CodeExpression res = new CodeCastExpression(outParams[n].Type, new CodeArrayIndexerExpression(arrVar, index));
                    CodeExpression var = new CodeVariableReferenceExpression(outParams[n].Name);
                    outAssign.Insert(0, new CodeAssignStatement(var, res));
                }
            }

            if (Style == ServiceDescriptionImportStyle.Client)
            {
                // Invoke call

                CodeThisReferenceExpression      ethis      = new CodeThisReferenceExpression();
                CodePrimitiveExpression          varMsgName = new CodePrimitiveExpression(messageName);
                CodeMethodInvokeExpression       inv;
                CodeVariableDeclarationStatement dec;

                inv = new CodeMethodInvokeExpression(ethis, "Invoke", varMsgName, methodParams);
                if (outputMembers != null && outputMembers.Count > 0)
                {
                    dec = new CodeVariableDeclarationStatement(typeof(object[]), varResults, inv);
                    method.Statements.Add(dec);
                    method.Statements.AddRange(outAssign);
                }
                else
                {
                    method.Statements.Add(inv);
                }

                // Begin Invoke Call

                CodeExpression expCallb  = new CodeVariableReferenceExpression(varCallback);
                CodeExpression expAsyncs = new CodeVariableReferenceExpression(varAsyncState);
                inv = new CodeMethodInvokeExpression(ethis, "BeginInvoke", varMsgName, methodParams, expCallb, expAsyncs);
                methodBegin.Statements.Add(new CodeMethodReturnStatement(inv));

                // End Invoke call

                CodeExpression varAsyncr = new CodeVariableReferenceExpression(varAsyncResult);
                inv = new CodeMethodInvokeExpression(ethis, "EndInvoke", varAsyncr);
                if (outputMembers != null && outputMembers.Count > 0)
                {
                    dec = new CodeVariableDeclarationStatement(typeof(object[]), varResults, inv);
                    methodEnd.Statements.Add(dec);
                    methodEnd.Statements.AddRange(outAssign);
                }
                else
                {
                    methodEnd.Statements.Add(inv);
                }
            }
            else
            {
                method.Attributes = MemberAttributes.Public | MemberAttributes.Abstract;
            }

            // Attributes

            ImportHeaders(method);

            CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Web.Services.WebMethodAttribute");

            if (messageName != method.Name)
            {
                att.Arguments.Add(GetArg("MessageName", messageName));
            }
            AddCustomAttribute(method, att, (Style == ServiceDescriptionImportStyle.Server));

            if (style == SoapBindingStyle.Rpc)
            {
                att = new CodeAttributeDeclaration("System.Web.Services.Protocols.SoapRpcMethodAttribute");
                att.Arguments.Add(GetArg(soapOper.SoapAction));
                if (inputMembers.ElementName != method.Name)
                {
                    att.Arguments.Add(GetArg("RequestElementName", inputMembers.ElementName));
                }
                if (outputMembers != null && outputMembers.ElementName != (method.Name + "Response"))
                {
                    att.Arguments.Add(GetArg("ResponseElementName", outputMembers.ElementName));
                }
                att.Arguments.Add(GetArg("RequestNamespace", inputMembers.Namespace));
                if (outputMembers != null)
                {
                    att.Arguments.Add(GetArg("ResponseNamespace", outputMembers.Namespace));
                }
                if (outputMembers == null)
                {
                    att.Arguments.Add(GetArg("OneWay", true));
                }
            }
            else
            {
                if (outputMembers != null && (inputMembers.ElementName == "" && outputMembers.ElementName != "" ||
                                              inputMembers.ElementName != "" && outputMembers.ElementName == ""))
                {
                    throw new InvalidOperationException("Parameter style is not the same for the input message and output message");
                }

                att = new CodeAttributeDeclaration("System.Web.Services.Protocols.SoapDocumentMethodAttribute");
                att.Arguments.Add(GetArg(soapOper.SoapAction));
                if (inputMembers.ElementName != "")
                {
                    if (inputMembers.ElementName != method.Name)
                    {
                        att.Arguments.Add(GetArg("RequestElementName", inputMembers.ElementName));
                    }
                    if (outputMembers != null && outputMembers.ElementName != (method.Name + "Response"))
                    {
                        att.Arguments.Add(GetArg("ResponseElementName", outputMembers.ElementName));
                    }
                    att.Arguments.Add(GetArg("RequestNamespace", inputMembers.Namespace));
                    if (outputMembers != null)
                    {
                        att.Arguments.Add(GetArg("ResponseNamespace", outputMembers.Namespace));
                    }
                    att.Arguments.Add(GetEnumArg("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Wrapped"));
                }
                else
                {
                    att.Arguments.Add(GetEnumArg("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Bare"));
                }

                if (outputMembers == null)
                {
                    att.Arguments.Add(GetArg("OneWay", true));
                }

                att.Arguments.Add(GetEnumArg("Use", "System.Web.Services.Description.SoapBindingUse", bodyBinding.Use.ToString()));
            }

            AddCustomAttribute(method, att, true);

            CodeTypeDeclaration.Members.Add(method);

            if (Style == ServiceDescriptionImportStyle.Client)
            {
                CodeTypeDeclaration.Members.Add(methodBegin);
                CodeTypeDeclaration.Members.Add(methodEnd);
            }

            return(method);
        }
예제 #13
0
        protected override CodeMemberMethod GenerateMethod()
        {
            try
            {
                SoapOperationBinding soapOper = OperationBinding.Extensions.Find(typeof(SoapOperationBinding)) as SoapOperationBinding;
                if (soapOper == null)
                {
                    throw new InvalidOperationException("Soap operation binding not found");
                }

                SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;

                SoapBodyBinding   isbb         = null;
                XmlMembersMapping inputMembers = null;

                bool isWrapped = CheckIsWrapped();

                isbb = OperationBinding.Input.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding;
                if (isbb == null)
                {
                    throw new InvalidOperationException("Soap body binding not found");
                }

                inputMembers = ImportMembersMapping(InputMessage, isbb, style, false, isWrapped);
                if (inputMembers == null)
                {
                    throw new InvalidOperationException("Input message not declared");
                }

                // If OperationBinding.Output is null, it is an OneWay operation

                SoapBodyBinding   osbb          = null;
                XmlMembersMapping outputMembers = null;

                if (OperationBinding.Output != null)
                {
                    osbb = OperationBinding.Output.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding;
                    if (osbb == null)
                    {
                        throw new InvalidOperationException("Soap body binding not found");
                    }

                    outputMembers = ImportMembersMapping(OutputMessage, osbb, style, true, isWrapped);
                    if (outputMembers == null)
                    {
                        throw new InvalidOperationException("Output message not declared");
                    }
                }

                CodeMemberMethod met = GenerateMethod(memberIds, soapOper, isbb, inputMembers, outputMembers);

                if (isbb.Use == SoapBindingUse.Literal)
                {
                    xmlExporter.ExportMembersMapping(inputMembers);
                }
                else
                {
                    soapExporter.ExportMembersMapping(inputMembers);
                }

                if (osbb != null)
                {
                    if (osbb.Use == SoapBindingUse.Literal)
                    {
                        xmlExporter.ExportMembersMapping(outputMembers);
                    }
                    else
                    {
                        soapExporter.ExportMembersMapping(outputMembers);
                    }
                }

                foreach (SoapExtensionImporter eximporter in extensionImporters)
                {
                    eximporter.ImportContext = this;
                    eximporter.ImportMethod(met.CustomAttributes);
                }

                return(met);
            }
            catch (InvalidOperationException ex)
            {
                UnsupportedOperationBindingWarning(ex.Message);
                return(null);
            }
        }
        LiteralType GetLiteralBindingType(Binding b)
        {
            SoapBinding      sb    = (SoapBinding)b.Extensions.Find(typeof(SoapBinding));
            SoapBindingStyle style = (sb != null) ? sb.Style : SoapBindingStyle.Document;

            if (style == SoapBindingStyle.Default)
            {
                style = SoapBindingStyle.Document;
            }

            foreach (OperationBinding ob in b.Operations)
            {
                SoapOperationBinding sob = (SoapOperationBinding)ob.Extensions.Find(typeof(SoapOperationBinding));
                if (sob.Style != SoapBindingStyle.Default && sob.Style != style)
                {
                    return(LiteralType.Inconsistent);
                }
                if (ob.Input != null)
                {
                    SoapBodyBinding sbb = (SoapBodyBinding)ob.Input.Extensions.Find(typeof(SoapBodyBinding));
                    if (sbb != null && sbb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                    SoapFaultBinding sfb = (SoapFaultBinding)ob.Input.Extensions.Find(typeof(SoapFaultBinding));
                    if (sfb != null && sfb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                    SoapHeaderBinding shb = (SoapHeaderBinding)ob.Input.Extensions.Find(typeof(SoapHeaderBinding));
                    if (shb != null && shb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                    SoapHeaderFaultBinding shfb = (SoapHeaderFaultBinding)ob.Input.Extensions.Find(typeof(SoapHeaderFaultBinding));
                    if (shfb != null && shfb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                }
                if (ob.Output != null)
                {
                    SoapBodyBinding sbb = (SoapBodyBinding)ob.Output.Extensions.Find(typeof(SoapBodyBinding));
                    if (sbb != null && sbb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                    SoapFaultBinding sfb = (SoapFaultBinding)ob.Input.Extensions.Find(typeof(SoapFaultBinding));
                    if (sfb != null && sfb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                    SoapHeaderBinding shb = (SoapHeaderBinding)ob.Input.Extensions.Find(typeof(SoapHeaderBinding));
                    if (shb != null && shb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                    SoapHeaderFaultBinding shfb = (SoapHeaderFaultBinding)ob.Input.Extensions.Find(typeof(SoapHeaderFaultBinding));
                    if (shfb != null && shfb.Use != SoapBindingUse.Literal)
                    {
                        return(LiteralType.NotLiteral);
                    }
                }
            }
            if (style == SoapBindingStyle.Document)
            {
                return(LiteralType.Document);
            }
            else
            {
                return(LiteralType.Rpc);
            }
        }
예제 #15
0
            /// <summary>
            /// Creates a <see cref="SoapDocumentMethodAttribute"/> or a <see cref="SoapRpcMethodAttribute"/>
            /// that should be applied to proxy method.
            /// </summary>
            private static CustomAttributeBuilder CreateSoapMethodAttribute(Operation operation,
                OperationBinding operationBinding, SoapOperationBinding soapOperationBinding,
                XmlMembersMapping inputMembersMapping, XmlMembersMapping outputMembersMapping)
            {
                ReflectionUtils.CustomAttributeBuilderBuilder cabb;

                string inputMembersMappingElementName = inputMembersMapping.ElementName;
                string inputMembersMappingNamespace = inputMembersMapping.Namespace;

                if (soapOperationBinding.Style == SoapBindingStyle.Rpc)
                {
                    cabb = new ReflectionUtils.CustomAttributeBuilderBuilder(typeof(SoapRpcMethodAttribute));
                }
                else
                {
                    cabb = new ReflectionUtils.CustomAttributeBuilderBuilder(typeof(SoapDocumentMethodAttribute));
                    cabb.AddPropertyValue("ParameterStyle", SoapParameterStyle.Wrapped);
                }

                cabb.AddContructorArgument(soapOperationBinding.SoapAction);
                cabb.AddPropertyValue("Use", SoapBindingUse.Literal);

                if (inputMembersMappingElementName.Length > 0 &&
                    inputMembersMappingElementName != operation.Name)
                {
                    cabb.AddPropertyValue("RequestElementName", inputMembersMappingElementName);
                }

                if (inputMembersMappingNamespace != null)
                {
                    cabb.AddPropertyValue("RequestNamespace", inputMembersMappingNamespace);
                }

                if (outputMembersMapping == null)
                {
                    cabb.AddPropertyValue("OneWay", true);
                }
                else
                {
                    string outputMembersMappingElementName = outputMembersMapping.ElementName;
                    string outputMembersMappingNamespace = outputMembersMapping.Namespace;

                    if (outputMembersMappingElementName.Length > 0 &&
                        outputMembersMappingElementName != (operation.Name + "Response"))
                    {
                        cabb.AddPropertyValue("ResponseElementName", outputMembersMappingElementName);
                    }

                    if (outputMembersMappingNamespace != null)
                    {
                        cabb.AddPropertyValue("ResponseNamespace", outputMembersMappingNamespace);
                    }
                }

                return cabb.Build();
            }
예제 #16
0
            private void MoveToMethod(MethodInfo targetMethod)
            {
                operation = GetOperation(this.wsDescriptions, this.wsBinding, targetMethod);
                operationBinding = GetOperationBinding(operation, this.wsBinding);
                soapOperationBinding = (SoapOperationBinding)operationBinding.Extensions.Find(typeof(SoapOperationBinding));

                string inputMessageName = (!StringUtils.IsNullOrEmpty(operationBinding.Input.Name) && (soapOperationBinding.Style != SoapBindingStyle.Rpc)) ? operationBinding.Input.Name : operation.Name;
                SoapBodyBinding inputSoapBodyBinding = (SoapBodyBinding)operationBinding.Input.Extensions.Find(typeof(SoapBodyBinding));

                if (inputSoapBodyBinding.Use != SoapBindingUse.Literal)
                {
                    throw new NotSupportedException("WebServiceProxyFactory only supports document-literal and rpc-literal SOAP messages to conform to WS-I Basic Profiles.");
                }

                Message inputMessage = this.wsDescriptions.GetMessage(operation.Messages.Input.Message);
                inputMembersMapping = GetMembersMapping(inputMessageName, inputMessage.Parts, inputSoapBodyBinding, soapOperationBinding.Style);

                outputMembersMapping = null;
                if (operation.Messages.Output != null)
                {
                    string outputMessageName = (!StringUtils.IsNullOrEmpty(operationBinding.Output.Name) && (soapOperationBinding.Style != SoapBindingStyle.Rpc)) ? operationBinding.Output.Name : (operation.Name + "Response");
                    SoapBodyBinding outputSoapBodyBinding = (SoapBodyBinding)operationBinding.Output.Extensions.Find(typeof(SoapBodyBinding));
                    Message outputMessage = this.wsDescriptions.GetMessage(operation.Messages.Output.Message);
                    outputMembersMapping = GetMembersMapping(outputMessageName, outputMessage.Parts, outputSoapBodyBinding, soapOperationBinding.Style);
                }
            }
예제 #17
0
		public void InitializeSoapOperationBinding()
		{
			sob = new SoapOperationBinding();
		}
예제 #18
0
		public override void ExportEndpoint (ServiceEndpoint endpoint)
		{
			List<IWsdlExportExtension> extensions = ExportContractInternal (endpoint.Contract);
			
			//FIXME: Namespace
			WSServiceDescription sd = GetServiceDescription ("http://tempuri.org/");
			if (sd.TargetNamespace != endpoint.Contract.Namespace) {
				sd.Namespaces.Add ("i0", endpoint.Contract.Namespace);

				//Import
				Import import = new Import ();
				import.Namespace = endpoint.Contract.Namespace;

				sd.Imports.Add (import);
			}
			
			if (endpoint.Binding == null)
				throw new ArgumentException (String.Format (
					"Binding for ServiceEndpoint named '{0}' is null",
					endpoint.Name));

			bool msg_version_none =
				endpoint.Binding.MessageVersion != null &&
				endpoint.Binding.MessageVersion.Equals (MessageVersion.None);
			//ExportBinding
			WSBinding ws_binding = new WSBinding ();
			
			//<binding name = .. 
			ws_binding.Name = String.Concat (endpoint.Binding.Name, "_", endpoint.Contract.Name);

			//<binding type = ..
			ws_binding.Type = new QName (endpoint.Contract.Name, endpoint.Contract.Namespace);
			sd.Bindings.Add (ws_binding);

			if (!msg_version_none) {
				SoapBinding soap_binding = new SoapBinding ();
				soap_binding.Transport = SoapBinding.HttpTransport;
				soap_binding.Style = SoapBindingStyle.Document;
				ws_binding.Extensions.Add (soap_binding);
			}

			//	<operation
			foreach (OperationDescription sm_op in endpoint.Contract.Operations){
				OperationBinding op_binding = new OperationBinding ();
				op_binding.Name = sm_op.Name;

				//FIXME: Move to IWsdlExportExtension .. ?
				foreach (MessageDescription sm_md in sm_op.Messages) {
					if (sm_md.Direction == MessageDirection.Input) {
						//<input
						InputBinding in_binding = new InputBinding ();

						if (!msg_version_none) {
							SoapBodyBinding soap_body_binding = new SoapBodyBinding ();
							soap_body_binding.Use = SoapBindingUse.Literal;
							in_binding.Extensions.Add (soap_body_binding);

							//Set Action
							//<operation > <soap:operation soapAction .. >
							SoapOperationBinding soap_operation_binding = new SoapOperationBinding ();
							soap_operation_binding.SoapAction = sm_md.Action;
							soap_operation_binding.Style = SoapBindingStyle.Document;
							op_binding.Extensions.Add (soap_operation_binding);
						}

						op_binding.Input = in_binding;
					} else {
						//<output
						OutputBinding out_binding = new OutputBinding ();

						if (!msg_version_none) {
							SoapBodyBinding soap_body_binding = new SoapBodyBinding ();
							soap_body_binding.Use = SoapBindingUse.Literal;
							out_binding.Extensions.Add (soap_body_binding);
						}
						
						op_binding.Output = out_binding;
					}
				}

				ws_binding.Operations.Add (op_binding);
			}

			//Add <service
			Port ws_port = ExportService (sd, ws_binding, endpoint.Address, msg_version_none);

			//Call IWsdlExportExtension.ExportEndpoint
			WsdlContractConversionContext contract_context = new WsdlContractConversionContext (
				endpoint.Contract, sd.PortTypes [endpoint.Contract.Name]);
			WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext (
				contract_context, endpoint, ws_port, ws_binding);

			foreach (IWsdlExportExtension extn in extensions)
				extn.ExportEndpoint (this, endpoint_context);

				
		}
		protected override bool ReflectMethod ()
		{
			SoapOperationBinding sob = new SoapOperationBinding();
			SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
			
			sob.SoapAction = method.Action;
			sob.Style = method.SoapBindingStyle;
			OperationBinding.Extensions.Add (sob);
			
			ImportMessage (method.InputMembersMapping, InputMessage);
			ImportMessage (method.OutputMembersMapping, OutputMessage);
				
			AddOperationMsgBindings (method, OperationBinding.Input);
			AddOperationMsgBindings (method, OperationBinding.Output);

			foreach (HeaderInfo hf in method.Headers)
			{
				if (hf.IsUnknownHeader) 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);

				SoapHeaderBinding hb = new SoapHeaderBinding ();
				hb.Message = new XmlQualifiedName (msg.Name, ServiceDescription.TargetNamespace);
				hb.Part = part.Name;
				hb.Use = method.Use;
				
				if (method.Use == SoapBindingUse.Literal)
				{
					// MS.NET reflects header classes in a weird way. The root element
					// 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);
					hb.Encoding = EncodingNamespace;
				}

				if ((hf.Direction & SoapHeaderDirection.Out) != 0)
					OperationBinding.Output.Extensions.Add (hb);
				if ((hf.Direction & SoapHeaderDirection.In) != 0)
					OperationBinding.Input.Extensions.Add (hb);
			}
			
			return true;
		}
 private static object GetSoapOperationBinding(System.ServiceModel.Channels.Binding binding, string action)
 {
     if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap11)
     {
         SoapOperationBinding soapOperationBinding = new SoapOperationBinding();
         soapOperationBinding.SoapAction = action;
         soapOperationBinding.Style = SoapBindingStyle.Document;
         return soapOperationBinding;
     }
     else if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap12)
     {
         Soap12OperationBinding soapOperationBinding = new Soap12OperationBinding();
         soapOperationBinding.SoapAction = action;
         soapOperationBinding.Style = SoapBindingStyle.Document;
         return soapOperationBinding;
     }
     return null;
 }