public string GenerateMessage(Port port, OperationBinding obin, Operation oper, string protocol, bool generateInput) { OperationMessage msg = null; foreach (OperationMessage opm in oper.Messages) { if (opm is OperationInput && generateInput) { msg = opm; } else if (opm is OperationOutput && !generateInput) { msg = opm; } } if (msg == null) { return(null); } switch (protocol) { case "Soap": return(GenerateHttpSoapMessage(port, obin, oper, msg)); case "HttpGet": return(GenerateHttpGetMessage(port, obin, oper, msg)); case "HttpPost": return(GenerateHttpPostMessage(port, obin, oper, msg)); } return("Unknown protocol"); }
static void Main() { // <Snippet1> // <Snippet2> // <Snippet3> ServiceDescription myServiceDescription = ServiceDescription.Read("MimeContentSample_cs.wsdl"); // Get the Binding. Binding myBinding = myServiceDescription.Bindings["b1"]; // Get the first OperationBinding. OperationBinding myOperationBinding = myBinding.Operations[0]; OutputBinding myOutputBinding = myOperationBinding.Output; ServiceDescriptionFormatExtensionCollection myServiceDescriptionFormatExtensionCollection = myOutputBinding.Extensions; // Find all MimeContentBinding objects in extensions. MimeContentBinding[] myMimeContentBindings = (MimeContentBinding[]) myServiceDescriptionFormatExtensionCollection.FindAll( typeof(MimeContentBinding)); // Enumerate the array and display MimeContentBinding properties. foreach (MimeContentBinding myMimeContentBinding in myMimeContentBindings) { Console.WriteLine("Type: " + myMimeContentBinding.Type); Console.WriteLine("Part: " + myMimeContentBinding.Part); } // </Snippet1> // </Snippet2> Console.WriteLine("Namespace: " + MimeContentBinding.Namespace); // </Snippet3> }
public string GenerateHttpSoapMessage(Port port, OperationBinding obin, Operation oper, OperationMessage msg) { string req = ""; if (msg is OperationInput) { SoapAddressBinding sab = port.Extensions.Find(typeof(SoapAddressBinding)) as SoapAddressBinding; SoapOperationBinding sob = obin.Extensions.Find(typeof(SoapOperationBinding)) as SoapOperationBinding; req += "POST " + GetAbsolutePath(sab.Location) + "\n"; req += "SOAPAction: " + sob.SoapAction + "\n"; req += "Content-Type: text/xml; charset=utf-8\n"; req += "Content-Length: " + GetLiteral("string") + "\n"; req += "Host: " + GetLiteral("string") + "\n\n"; } else { req += "HTTP/1.0 200 OK\n"; req += "Content-Type: text/xml; charset=utf-8\n"; req += "Content-Length: " + GetLiteral("string") + "\n\n"; } req += GenerateSoapMessage(obin, oper, msg); return(req); }
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; }
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 !NET_2_0 if (soapOperationBinding.Style == SoapBindingStyle.Rpc && inputSoapBodyBinding.Use == SoapBindingUse.Literal) { throw new NotSupportedException("rpc-literal SOAP messages are not supported on .NET Framework 1.1"); } #endif 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); } }
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; } } } } }
// <Snippet8> // Used to create OperationBinding instances within 'Binding'. public static OperationBinding CreateOperationBinding(string operation, string targetNamespace) { // Create OperationBinding instance for operation. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = operation; // Create InputBinding for operation. InputBinding myInputBinding = new InputBinding(); SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding(); mySoapBodyBinding.Use = SoapBindingUse.Literal; myInputBinding.Extensions.Add(mySoapBodyBinding); // Create OutputBinding for operation. OutputBinding myOutputBinding = new OutputBinding(); myOutputBinding.Extensions.Add(mySoapBodyBinding); // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; myOperationBinding.Output = myOutputBinding; // Create extensibility element for 'SoapOperationBinding'. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.Style = SoapBindingStyle.Document; mySoapOperationBinding.SoapAction = targetNamespace + operation; // Add extensibility element 'SoapOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(mySoapOperationBinding); return(myOperationBinding); }
// Used to create OperationBinding instances within Binding. public static OperationBinding CreateOperationBinding( string myOperation, string targetNamespace) { // Create OperationBinding for Operation. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = myOperation; // Create InputBinding for operation. InputBinding myInputBinding = (InputBinding)CreateInputOutputBinding(null, true); // Create OutputBinding for operation. OutputBinding myOutputBinding = (OutputBinding)CreateInputOutputBinding(null, false); // Add InputBinding and OutputBinding to OperationBinding. myOperationBinding.Input = myInputBinding; myOperationBinding.Output = myOutputBinding; // Create an extensibility element for SoapOperationBinding. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.Style = SoapBindingStyle.Document; mySoapOperationBinding.SoapAction = targetNamespace + myOperation; // Add the extensibility element SoapOperationBinding to OperationBinding. myOperationBinding.Extensions.Add(mySoapOperationBinding); return(myOperationBinding); }
public static void Main() { // <Snippet1> // Read from an existing wsdl file. ServiceDescription myServiceDescription = ServiceDescription.Read("MapToProperty_cs.wsdl"); // Get the existing binding Binding myBinding = myServiceDescription.Bindings["MyWebServiceSoap"]; OperationBinding myOperationBinding = (OperationBinding)myBinding.Operations[0]; InputBinding myInputBinding = myOperationBinding.Input; // Get the 'SoapHeaderBinding' instance from 'myInputBinding'. SoapHeaderBinding mySoapHeaderBinding = (SoapHeaderBinding)myInputBinding.Extensions[1]; if (mySoapHeaderBinding.MapToProperty) { Console.WriteLine("'SoapHeaderBinding' instance is mapped to a " + "specific property in proxy generated class"); } else { Console.WriteLine("'SoapHeaderBinding' instance is not mapped to " + "a specific property in proxy generated class"); } // </Snippet1> }
internal void AddOperationBinding(string bindingName, OperationBinding operation) { if (operation != null && !serviceDescription.Bindings[bindingName].Operations.Contains(operation)) { serviceDescription.Bindings[bindingName].Operations.Add(operation); } }
internal void RemoveOperationBinding(string bindingName, OperationBinding operation) { if (operation != null && serviceDescription.Bindings[bindingName].Operations.Contains(operation)) { serviceDescription.Bindings[bindingName].Operations.Remove(operation); } }
public static void Main() { // Read the 'StockQuote.wsdl' file as input. ServiceDescription myServiceDescription = ServiceDescription.Read("StockQuote.wsdl"); // Get the operation fault collection and remove the operation fault with the name 'ErrorString'. PortTypeCollection myPortTypeCollection = myServiceDescription.PortTypes; PortType myPortType = myPortTypeCollection[0]; OperationCollection myOperationCollection = myPortType.Operations; Operation myOperation = myOperationCollection[0]; OperationFaultCollection myOperationFaultCollection = myOperation.Faults; if (myOperationFaultCollection.Contains(myOperationFaultCollection["ErrorString"])) { myOperationFaultCollection.Remove(myOperationFaultCollection["ErrorString"]); } // Get the fault binding collection and remove the fault binding with the name 'ErrorString'. // <Snippet1> BindingCollection myBindingCollection = myServiceDescription.Bindings; Binding myBinding = myBindingCollection[0]; OperationBindingCollection myOperationBindingCollection = myBinding.Operations; OperationBinding myOperationBinding = myOperationBindingCollection[0]; FaultBindingCollection myFaultBindingCollection = myOperationBinding.Faults; if (myFaultBindingCollection.Contains(myFaultBindingCollection["ErrorString"])) { myFaultBindingCollection.Remove(myFaultBindingCollection["ErrorString"]); } // </Snippet1> myServiceDescription.Write(Console.Out); }
void CreateOutputBinding(ServiceEndpoint endpoint, OperationBinding op_binding, MessageDescription sm_md) { var out_binding = new OutputBinding(); op_binding.Output = out_binding; var message_version = endpoint.Binding.MessageVersion ?? MessageVersion.None; if (message_version == MessageVersion.None) { return; } SoapBodyBinding soap_body_binding; if (message_version.Envelope == EnvelopeVersion.Soap11) { soap_body_binding = new SoapBodyBinding(); } else if (message_version.Envelope == EnvelopeVersion.Soap12) { soap_body_binding = new Soap12BodyBinding(); } else { throw new InvalidOperationException(); } soap_body_binding.Use = SoapBindingUse.Literal; out_binding.Extensions.Add(soap_body_binding); }
public static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("MimeXmlBinding_Part_3_Input_CS.wsdl"); // Create the 'Binding' object. Binding myBinding = new Binding(); // Initialize 'Name' property of 'Binding' class. myBinding.Name = "MimeXmlBinding_Part_3_ServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:MimeXmlBinding_Part_3_ServiceHttpPost"); myBinding.Type = myXmlQualifiedName; // Create the 'HttpBinding' object. HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; // Add the 'HttpBinding' to the 'Binding'. myBinding.Extensions.Add(myHttpBinding); // Create the 'OperationBinding' object. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding(); myHttpOperationBinding.Location = "/AddNumbers"; // Add the 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myHttpOperationBinding); // Create the 'InputBinding' object. InputBinding myInputBinding = new InputBinding(); MimeContentBinding myMimeContentBinding = new MimeContentBinding(); myMimeContentBinding.Type = "application/x-www-form-urlencoded"; myInputBinding.Extensions.Add(myMimeContentBinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; // Create an OutputBinding. OutputBinding myOutputBinding = new OutputBinding(); MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding(); // Initialize the Part property of the MimeXmlBinding. myMimeXmlBinding.Part = "Body"; // Add the MimeXmlBinding to the OutputBinding. myOutputBinding.Extensions.Add(myMimeXmlBinding); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutputBinding; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("MimeXmlBinding_Part_3_Output_CS.wsdl"); Console.WriteLine("WSDL file with name 'MimeXmlBinding_Part_3_Output_CS.wsdl' is" + " created successfully."); } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }
public static void Main() { ServiceDescription myServiceDescription = ServiceDescription.Read("MimePartCollection_1_Input_cs.wsdl"); ServiceDescriptionCollection myServiceDescriptionCol = new ServiceDescriptionCollection(); myServiceDescriptionCol.Add(myServiceDescription); XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/"); // Create a 'Binding' object. Binding myBinding = myServiceDescriptionCol.GetBinding(myXmlQualifiedName); OperationBinding myOperationBinding = null; for (int i = 0; i < myBinding.Operations.Count; i++) { if (myBinding.Operations[i].Name.Equals("AddNumbers")) { myOperationBinding = myBinding.Operations[i]; } } OutputBinding myOutputBinding = myOperationBinding.Output; MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null; IEnumerator myIEnumerator = myOutputBinding.Extensions.GetEnumerator(); while (myIEnumerator.MoveNext()) { myMimeMultipartRelatedBinding = (MimeMultipartRelatedBinding)myIEnumerator.Current; } // Create an instances of 'MimePartCollection'. MimePartCollection myMimePartCollection = new MimePartCollection(); myMimePartCollection = myMimeMultipartRelatedBinding.Parts; Console.WriteLine("Total number of mimepart elements initially is: " + myMimePartCollection.Count); // Create an instance of 'MimePart'. MimePart myMimePart = new MimePart(); // Create an instance of 'MimeXmlBinding'. MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding(); myMimeXmlBinding.Part = "body"; myMimePart.Extensions.Add(myMimeXmlBinding); // Insert a mimepart at first position. myMimePartCollection.Insert(0, myMimePart); Console.WriteLine("Inserting a mimepart object..."); if (myMimePartCollection.Contains(myMimePart)) { Console.WriteLine("'MimePart' is succesffully added at position: " + myMimePartCollection.IndexOf(myMimePart)); Console.WriteLine("Total number of mimepart elements after inserting is: " + myMimePartCollection.Count); } myServiceDescription.Write("MimePartCollection_1_Output_CS.wsdl"); Console.WriteLine("MimePartCollection_1_Output_CS.wsdl has been generated successfully."); }
/// <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()); }
internal static string ReadSoapAction(OperationBinding wsdlOperationBinding) { SoapOperationBinding binding = (SoapOperationBinding)wsdlOperationBinding.Extensions.Find(typeof(SoapOperationBinding)); if (binding == null) { return(null); } return(binding.SoapAction); }
public static void Main() { ServiceDescription myServiceDescription = ServiceDescription.Read("SoapHeaderBindingInput_cs.wsdl"); Binding myBinding = new Binding(); myBinding.Name = "MyWebServiceSoap"; myBinding.Type = new XmlQualifiedName("s0:MyWebServiceSoap"); SoapBinding mySoapBinding = new SoapBinding(); mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"; mySoapBinding.Style = SoapBindingStyle.Document; myBinding.Extensions.Add(mySoapBinding); OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "Hello"; SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.SoapAction = "http://tempuri.org/Hello"; mySoapOperationBinding.Style = SoapBindingStyle.Document; myOperationBinding.Extensions.Add(mySoapOperationBinding); // Create InputBinding for operation for the 'SOAP' protocol. InputBinding myInputBinding = new InputBinding(); SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding(); mySoapBodyBinding.Use = SoapBindingUse.Literal; myInputBinding.Extensions.Add(mySoapBodyBinding); SoapHeaderBinding mySoapHeaderBinding = new SoapHeaderBinding(); mySoapHeaderBinding.Message = new XmlQualifiedName("s0:HelloMyHeader"); mySoapHeaderBinding.Part = "MyHeader"; mySoapHeaderBinding.Use = SoapBindingUse.Literal; // Add mySoapHeaderBinding to 'myInputBinding' object. myInputBinding.Extensions.Add(mySoapHeaderBinding); // Create OutputBinding for operation for the 'SOAP' protocol. OutputBinding myOutputBinding = new OutputBinding(); myOutputBinding.Extensions.Add(mySoapBodyBinding); // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; myOperationBinding.Output = myOutputBinding; myBinding.Operations.Add(myOperationBinding); myServiceDescription.Bindings.Add(myBinding); myServiceDescription.Write("SoapHeaderBindingOut_cs.wsdl"); Console.WriteLine("'SoapHeaderBindingOut_cs.wsdl' file is generated."); Console.WriteLine("Proxy could be created using " + "'wsdl SoapHeaderBindingOut_cs.wsdl'."); }
public void EmptyAction() { ServiceDescriptionReflector r = new ServiceDescriptionReflector(); r.Reflect(typeof(EmptyActionService), "urn:foo"); Binding b = r.ServiceDescriptions [0].Bindings ["EmptyActionServiceSoap"]; OperationBinding o = b.Operations [0]; SoapOperationBinding sob = o.Extensions [0] as SoapOperationBinding; Assert.AreEqual(String.Empty, sob.SoapAction); }
public static void Main() { try { // Read the 'StockQuote.wsdl' file as input. ServiceDescription myServiceDescription = ServiceDescription. Read("StockQuote_cs.wsdl"); // Remove the operation fault with the name 'ErrorString'. PortTypeCollection myPortTypeCollection = myServiceDescription. PortTypes; PortType myPortType = myPortTypeCollection[0]; OperationCollection myOperationCollection = myPortType.Operations; Operation myOperation = myOperationCollection[0]; // <Snippet1> OperationFaultCollection myOperationFaultCollection = myOperation.Faults; OperationFault myOperationFault = myOperationFaultCollection["ErrorString"]; if (myOperationFault != null) { myOperationFaultCollection.Remove(myOperationFault); } // </Snippet1> // Remove the fault binding with the name 'ErrorString'. BindingCollection myBindingCollection = myServiceDescription. Bindings; Binding myBinding = myBindingCollection[0]; OperationBindingCollection myOperationBindingCollection = myBinding.Operations; OperationBinding myOperationBinding = myOperationBindingCollection[0]; FaultBindingCollection myFaultBindingCollection = myOperationBinding.Faults; if (myFaultBindingCollection.Contains( myFaultBindingCollection["ErrorString"])) { myFaultBindingCollection.Remove( myFaultBindingCollection["ErrorString"]); } myServiceDescription.Write("OperationFaultCollection_out.wsdl"); Console.WriteLine("WSDL file with name 'OperationFaultCollection_out.wsdl'" + " created Successfully"); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
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); }
internal static SoapBindingStyle GetStyle(OperationBinding operationBinding, SoapBindingStyle defaultBindingStyle) { SoapBindingStyle style = defaultBindingStyle; if (operationBinding != null) { SoapOperationBinding binding = operationBinding.Extensions.Find(typeof(SoapOperationBinding)) as SoapOperationBinding; if ((binding != null) && (binding.Style != SoapBindingStyle.Default)) { style = binding.Style; } } return(style); }
public static void AddHeaderToOperation(OperationBinding operation, Message msg, string partName, bool needInput, bool requiredInput, bool needOutput, bool requiredOutput) { if (operation == null) { throw new ArgumentNullException("operation"); } if (needInput) { operation.Input.Extensions.Add(CreateHeaderBinding(msg, partName, requiredInput)); } if (needOutput) { operation.Output.Extensions.Add(CreateHeaderBinding(msg, partName, requiredOutput)); } }
internal static SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpointContext, OperationDescription operation, WsdlExporter exporter) { if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None) { return(null); } SoapOperationBinding soapOperationBinding = GetSoapOperationBinding(endpointContext, operation); OperationBinding operationBinding = endpointContext.GetOperationBinding(operation); EnvelopeVersion soapVersion = GetSoapVersion(endpointContext.WsdlBinding); if (soapOperationBinding != null) { return(soapOperationBinding); } return(CreateSoapOperationBinding(soapVersion, operationBinding)); }
private OperationBinding GetOperationBinding(WsdlTreeViewItem item) { Binding bind = wsdlIn.serviceDescription.Bindings[item.Parent.Name]; OperationBinding bindOperation = null; for (int i = 0; i < bind.Operations.Count; i++) { if (bind.Operations[i].Name == item.Name) { bindOperation = bind.Operations[i]; break; } } return(bindOperation); }
public static void Main() { ServiceDescription myServiceDescription = ServiceDescription.Read("MimePart_3_Input_cs.wsdl"); ServiceDescriptionCollection myServiceDescriptionCol = new ServiceDescriptionCollection(); myServiceDescriptionCol.Add(myServiceDescription); XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/"); // Create the Binding. Binding myBinding = myServiceDescriptionCol.GetBinding(myXmlQualifiedName); OperationBinding myOperationBinding = null; for (int i = 0; i < myBinding.Operations.Count; i++) { if (myBinding.Operations[i].Name.Equals("AddNumbers")) { myOperationBinding = myBinding.Operations[i]; } } // <Snippet2> // <Snippet3> // Create the OutputBinding. OutputBinding myOutputBinding = myOperationBinding.Output; MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding(); myMimeXmlBinding.Part = "body"; // Create the MimePart. MimePart myMimePart = new MimePart(); myMimePart.Extensions.Add(myMimeXmlBinding); MimeMultipartRelatedBinding myMimePartRelatedBinding = new MimeMultipartRelatedBinding(); // Add the MimePart to the MimePartRelatedBinding. myMimePartRelatedBinding.Parts.Add(myMimePart); myOutputBinding.Extensions.Add(myMimePartRelatedBinding); // </Snippet3> // </Snippet2> myServiceDescription.Write("MimePart_3_Output_CS.wsdl"); Console.WriteLine( "MimePart_3_Output_CS.wsdl has been generated successfully."); }
private void ParseOperationBinding(OperationBinding operationBinding, [CallerLineNumber] int callerLine = -1) { currentClass = ClassDeclaration(operationBinding.Name).WithModifiers(TokenList(new[] { Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.PartialKeyword) })) .WithLeadingTrivia(TriviaList(Comment(string.Format("//{0}:ParseOperationBinding:Sender", callerLine)))) .WithBaseList(BaseList(new SeparatedSyntaxList <BaseTypeSyntax>().Add(SimpleBaseType(ParseTypeName("SimpleSoapClient.Models.SimpleSoapClientBase"))))); ParseOperationBindingExtensions(operationBinding.Extensions); ns = ns.AddMembers(currentClass); currentClass = ClassDeclaration(operationBinding.Input.Name).WithModifiers(TokenList(new[] { Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.PartialKeyword) })) .WithLeadingTrivia(TriviaList(Comment(string.Format("//{0}:ParseOperationBinding:Input", callerLine)))); ParseOperationBindingExtensions(operationBinding.Input.Extensions); ns = ns.AddMembers(currentClass); currentClass = ClassDeclaration(operationBinding.Output.Name).WithModifiers(TokenList(new[] { Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.PartialKeyword) })) .WithLeadingTrivia(TriviaList(Comment(string.Format("//{0}:ParseOperationBinding:Output", callerLine)))); ParseOperationBindingExtensions(operationBinding.Output.Extensions); ns = ns.AddMembers(currentClass); }
void CheckBasicHttpBinding(WSServiceDescription wsd, string binding_name, XmlQualifiedName binding_type, string operation_name, string action, bool has_input, bool has_output, string label) { WSBinding b = GetBinding(wsd, binding_name, label); OperationBinding op = GetOperationBinding(b, operation_name, label + " CheckBasicHttpBinding"); Assert.AreEqual(binding_type, b.Type, label + " #cbh0"); if (has_input) { InputBinding inb = op.Input; Assert.IsNotNull(inb, label + " #cbh1"); Assert.AreEqual(1, inb.Extensions.Count, label + " #cbh2"); Assert.AreEqual(typeof(SoapBodyBinding), inb.Extensions [0].GetType(), label + " #cbh3"); SoapBodyBinding soap_binding = (SoapBodyBinding)inb.Extensions [0]; Assert.AreEqual(SoapBindingUse.Literal, soap_binding.Use, label + " #cbh4"); if (action != null) { Assert.AreEqual(1, op.Extensions.Count, label + " #chb5"); Assert.AreEqual(typeof(SoapOperationBinding), op.Extensions [0].GetType(), label + " #cbh6"); SoapOperationBinding sopb = (SoapOperationBinding)op.Extensions [0]; Assert.AreEqual(action, sopb.SoapAction, label + " #cbh7"); } } if (has_output) { OutputBinding outb = op.Output; Assert.IsNotNull(outb, label + " #cbh10"); Assert.AreEqual(1, outb.Extensions.Count, label + " #cbh11"); Assert.AreEqual(typeof(SoapBodyBinding), outb.Extensions [0].GetType(), label + " #cbh12"); SoapBodyBinding soap_binding = (SoapBodyBinding)outb.Extensions [0]; Assert.AreEqual(SoapBindingUse.Literal, soap_binding.Use, label + " #cbh13"); } Assert.AreEqual(1, b.Extensions.Count, label + " #cbh20"); Assert.AreEqual(typeof(SoapBinding), b.Extensions [0].GetType(), label + " #cbh21"); SoapBinding sb = (SoapBinding)b.Extensions [0]; Assert.AreEqual(SoapBinding.HttpTransport, sb.Transport, label + " #cbh22"); }
private static IEnumerable <IEditorScript> GetScripts(OperationBinding opBinding, XmlSchemaSet schemas) { var binding = opBinding.Binding; var service = binding.ServiceDescription; var operation = service.PortTypes[binding.Type.Name].Operations.OfType <Operation>() .FirstOrDefault(o => o.Name == opBinding.Name); var elem = service.Messages[operation.Messages.Input.Message.Name].Parts[0].Element; //var schemaElem = service.Types.Schemas // .SelectMany(s => s.Elements.Values.OfType<XmlSchemaElement>()) // .FirstOrDefault(e => e.Name == elem.Name); var settings = new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true, IndentChars = " " }; using (var writer = new StringWriter()) using (var xml = XmlTextWriter.Create(writer, settings)) { var generator = new Microsoft.Xml.XMLGen.XmlSampleGenerator(schemas, elem); xml.WriteStartElement("soapenv", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/"); xml.WriteAttributeString("xmlns", "soap", null, elem.Namespace); xml.WriteStartElement("soapenv", "Header", "http://schemas.xmlsoap.org/soap/envelope/"); xml.WriteEndElement(); xml.WriteStartElement("soapenv", "Body", "http://schemas.xmlsoap.org/soap/envelope/"); generator.WriteXml(xml); xml.WriteEndElement(); xml.WriteEndElement(); xml.Flush(); writer.Flush(); return(Enumerable.Repeat <IEditorScript>(new EditorScript() { Name = "Sample Request", Script = writer.ToString(), Action = opBinding.Name }, 1)); } }
static ExplorerItem CreateExplorerOperation(Type serviceType, OperationBinding operation) { var method = serviceType.GetMethod(operation.Name); var parameters = method.GetParameters(); var description = operation.DocumentationElement == null ? "" : operation.DocumentationElement.InnerText; var item = new ExplorerItem(operation.Name, ExplorerItemKind.QueryableObject, ExplorerIcon.StoredProc) { ToolTipText = description, DragText = GetMethodCallString(method.Name, from p in parameters select p.Name), Children = ( from p in parameters select new ExplorerItem(p.Name, ExplorerItemKind.Parameter, ExplorerIcon.Parameter) ).ToList() }; return(item); }
// Methods public bool IsBoundBy(OperationBinding operationBinding) {}
internal FaultBindingCollection (OperationBinding operationBinding) : base (operationBinding) { }
public void Insert(int index, OperationBinding bindingOperation) {}
// Methods public int Add(OperationBinding bindingOperation) {}
public bool Contains(OperationBinding bindingOperation) {}
public int IndexOf(OperationBinding bindingOperation) {}
public void Remove(OperationBinding bindingOperation) {}
public int Add (OperationBinding bindingOperation) { Insert (Count, bindingOperation); return (Count - 1); }
public bool Contains (OperationBinding bindingOperation) { return List.Contains (bindingOperation); }
public void CopyTo (OperationBinding[] array, int index) { List.CopyTo (array, index); }
public void Remove (OperationBinding bindingOperation) { List.Remove (bindingOperation); }
public void Insert (int index, OperationBinding bindingOperation) { List.Insert (index, bindingOperation); }
public int IndexOf (OperationBinding bindingOperation) { return List.IndexOf (bindingOperation); }