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 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); }
public string GenerateHttpPostMessage(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; req += "POST " + location + "\n"; req += "Content-Type: application/x-www-form-urlencoded\n"; req += "Content-Length: " + GetLiteral("string") + "\n"; req += "Host: " + GetLiteral("string") + "\n\n"; req += BuildQueryString(msg); } else { return(GenerateHttpGetMessage(port, obin, oper, msg)); } return(req); }
public static void Main() { try { ServiceDescription myServiceDescription = ServiceDescription.Read("MimeText_Binding_Match_8_Input_CS.wsdl"); // Create a Binding. Binding myBinding = new Binding(); // Initialize the Name property of the Binding. myBinding.Name = "MimeText_Binding_MatchServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:MimeText_Binding_MatchServiceHttpPost"); myBinding.Type = myXmlQualifiedName; // Create an HttpBinding. HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; // Add the HttpBinding to the Binding. myBinding.Extensions.Add(myHttpBinding); // Create an OperationBinding. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding(); myHttpOperationBinding.Location = "/AddNumbers"; // Add the HttpOperationBinding to the OperationBinding. myOperationBinding.Extensions.Add(myHttpOperationBinding); // Create an InputBinding. InputBinding myInputBinding = new InputBinding(); MimeContentBinding postMimeContentbinding = new MimeContentBinding(); postMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInputBinding.Extensions.Add(postMimeContentbinding); // Add the InputBinding to the OperationBinding. myOperationBinding.Input = myInputBinding; // <Snippet8> // <Snippet7> // <Snippet6> // <Snippet5> // <Snippet4> // <Snippet3> // <Snippet2> // Create an OutputBinding. OutputBinding myOutputBinding = new OutputBinding(); // Create a MimeTextBinding. MimeTextBinding myMimeTextBinding = new MimeTextBinding(); // Create a MimeTextMatch. MimeTextMatch myMimeTextMatch = new MimeTextMatch(); MimeTextMatchCollection myMimeTextMatchCollection; // Initialize properties of the MimeTextMatch. myMimeTextMatch.Name = "Title"; myMimeTextMatch.Type = "*/*"; myMimeTextMatch.Pattern = "'TITLE>(.*?)<"; myMimeTextMatch.IgnoreCase = true; // Initialize a MimeTextMatchCollection. myMimeTextMatchCollection = myMimeTextBinding.Matches; // Add the MimeTextMatch to the MimeTextMatchCollection. myMimeTextMatchCollection.Add(myMimeTextMatch); myOutputBinding.Extensions.Add(myMimeTextBinding); // Add the OutputBinding to the OperationBinding. myOperationBinding.Output = myOutputBinding; // </Snippet2> // </Snippet3> // </Snippet4> // </Snippet5> // </Snippet6> // </Snippet7> // </Snippet8> // Add the OutputBinding to the OperationBinding. myOperationBinding.Output = myOutputBinding; // Add the OperationBinding to the Binding. myBinding.Operations.Add(myOperationBinding); // Add the Binding to the BindingCollection of the ServiceDescription. myServiceDescription.Bindings.Add(myBinding); // Write the ServiceDescription as a WSDL file. myServiceDescription.Write("MimeText_Binding_Match_8_Output_CS.wsdl"); Console.WriteLine( "WSDL file named 'MimeText_Binding_Match_8_Output_CS.wsdl' was" + " created successfully."); } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }
public static void Main() { ServiceDescription myDescription = ServiceDescription.Read("AddNumbers1.wsdl"); // Create the 'Binding' object. Binding myBinding = new Binding(); myBinding.Name = "Service1HttpPost"; XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:Service1HttpPost"); myBinding.Type = qualifiedName; // <Snippet1> // <Snippet2> // Create the 'HttpBinding' object. HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; // Add the 'HttpBinding' to the 'Binding'. myBinding.Extensions.Add(myHttpBinding); // </Snippet2> // </Snippet1> // Create the 'OperationBinding' object. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myOperation = new HttpOperationBinding(); myOperation.Location = "/AddNumbers"; // Add the 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myOperation); // Create the 'InputBinding' object. InputBinding myInput = new InputBinding(); MimeContentBinding postMimeContentbinding = new MimeContentBinding(); postMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInput.Extensions.Add(postMimeContentbinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInput; // Create the 'OutputBinding' object. OutputBinding myOutput = new OutputBinding(); MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding(); postMimeXmlbinding.Part = "Body"; myOutput.Extensions.Add(postMimeXmlbinding); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); // Create a 'Port' object. Port postPort = new Port(); postPort.Name = "Service1HttpPost"; postPort.Binding = new XmlQualifiedName("s0:Service1HttpPost"); // <Snippet3> // <Snippet4> // Create the 'HttpAddressBinding' object. HttpAddressBinding postAddressBinding = new HttpAddressBinding(); postAddressBinding.Location = "http://localhost/Service1.asmx"; // Add the 'HttpAddressBinding' to the 'Port'. postPort.Extensions.Add(postAddressBinding); // </Snippet4> // </Snippet3> // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.Services[0].Ports.Add(postPort); // Create a 'PortType' object. PortType postPortType = new PortType(); postPortType.Name = "Service1HttpPost"; Operation postOperation = new Operation(); postOperation.Name = "AddNumbers"; OperationMessage postInput = (OperationMessage) new OperationInput(); postInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn"); OperationMessage postOutput = (OperationMessage) new OperationOutput(); postOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostOut"); postOperation.Messages.Add(postInput); postOperation.Messages.Add(postOutput); // Add the 'Operation' to 'PortType'. postPortType.Operations.Add(postOperation); // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. myDescription.PortTypes.Add(postPortType); // Create the 'Message' object. Message postMessage1 = new Message(); postMessage1.Name = "AddNumbersHttpPostIn"; // Create the 'MessageParts'. MessagePart postMessagePart1 = new MessagePart(); postMessagePart1.Name = "firstnumber"; postMessagePart1.Type = new XmlQualifiedName("s:string"); MessagePart postMessagePart2 = new MessagePart(); postMessagePart2.Name = "secondnumber"; postMessagePart2.Type = new XmlQualifiedName("s:string"); // Add the 'MessagePart' objects to 'Messages'. postMessage1.Parts.Add(postMessagePart1); postMessage1.Parts.Add(postMessagePart2); // Create another 'Message' object. Message postMessage2 = new Message(); postMessage2.Name = "AddNumbersHttpPostOut"; MessagePart postMessagePart3 = new MessagePart(); postMessagePart3.Name = "Body"; postMessagePart3.Element = new XmlQualifiedName("s0:int"); // Add the 'MessagePart' to 'Message' postMessage2.Parts.Add(postMessagePart3); // Add the 'Message' objects to 'ServiceDescription'. myDescription.Messages.Add(postMessage1); myDescription.Messages.Add(postMessage2); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("AddNumbers.wsdl"); Console.WriteLine("WSDL file with name 'AddNumber.Wsdl' file created Successfully"); }
public static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("AddNumbersIn_cs.wsdl"); // Add the ServiceHttpPost binding. Binding myBinding = new Binding(); myBinding.Name = "ServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:ServiceHttpPost"); myBinding.Type = myXmlQualifiedName; HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; myBinding.Extensions.Add(myHttpBinding); // Add the operation name AddNumbers. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myOperation = new HttpOperationBinding(); myOperation.Location = "/AddNumbers"; myOperationBinding.Extensions.Add(myOperation); // Add the input binding. InputBinding myInput = new InputBinding(); MimeContentBinding postMimeContentbinding = new MimeContentBinding(); postMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInput.Extensions.Add(postMimeContentbinding); // Add the InputBinding to the OperationBinding. myOperationBinding.Input = myInput; // Add the ouput binding. OutputBinding myOutput = new OutputBinding(); MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding(); postMimeXmlbinding.Part = "Body"; myOutput.Extensions.Add(postMimeXmlbinding); // Add the OutPutBinding to the OperationBinding. myOperationBinding.Output = myOutput; myBinding.Operations.Add(myOperationBinding); myDescription.Bindings.Add(myBinding); // Add the port definition. Port postPort = new Port(); postPort.Name = "ServiceHttpPost"; postPort.Binding = new XmlQualifiedName("s0:ServiceHttpPost"); HttpAddressBinding postAddressBinding = new HttpAddressBinding(); postAddressBinding.Location = "http://localhost/Service_cs.asmx"; postPort.Extensions.Add(postAddressBinding); myDescription.Services[0].Ports.Add(postPort); // Add the post port type definition. PortType postPortType = new PortType(); postPortType.Name = "ServiceHttpPost"; Operation postOperation = new Operation(); postOperation.Name = "AddNumbers"; OperationMessage postInput = (OperationMessage) new OperationInput(); postInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn"); // <Snippet2> OperationOutput postOutput = new OperationOutput(); postOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostOut"); postOperation.Messages.Add(postInput); postOperation.Messages.Add(postOutput); postPortType.Operations.Add(postOperation); // </Snippet2> myDescription.PortTypes.Add(postPortType); // Add the first message information. Message postMessage1 = new Message(); postMessage1.Name = "AddNumbersHttpPostIn"; MessagePart postMessagePart1 = new MessagePart(); postMessagePart1.Name = "firstnumber"; postMessagePart1.Type = new XmlQualifiedName("s:string"); // Add the second message information. MessagePart postMessagePart2 = new MessagePart(); postMessagePart2.Name = "secondnumber"; postMessagePart2.Type = new XmlQualifiedName("s:string"); postMessage1.Parts.Add(postMessagePart1); postMessage1.Parts.Add(postMessagePart2); Message postMessage2 = new Message(); postMessage2.Name = "AddNumbersHttpPostOut"; // Add the third message information. MessagePart postMessagePart3 = new MessagePart(); postMessagePart3.Name = "Body"; postMessagePart3.Element = new XmlQualifiedName("s0:int"); postMessage2.Parts.Add(postMessagePart3); myDescription.Messages.Add(postMessage1); myDescription.Messages.Add(postMessage2); // Write the ServiceDescription as a WSDL file. myDescription.Write("AddNumbersOut_cs.wsdl"); Console.WriteLine("WSDL file named AddNumbersOut_cs.Wsdl" + " created successfully."); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
public static void Main() { ServiceDescription myServiceDescription = ServiceDescription.Read("Operation_IsBoundBy_Input_CS.wsdl"); // Create the 'Binding' object. Binding myBinding = new Binding(); myBinding.Name = "MyOperationIsBoundByServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:OperationServiceHttpPost"); 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 myPostMimeContentBinding = new MimeContentBinding(); myPostMimeContentBinding.Type = "application/x-www-form-urlencoded"; myInputBinding.Extensions.Add(myPostMimeContentBinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; // Create the 'OutputBinding' object. OutputBinding myOutputBinding = new OutputBinding(); MimeXmlBinding myPostMimeXmlBinding = new MimeXmlBinding(); myPostMimeXmlBinding.Part = "Body"; myOutputBinding.Extensions.Add(myPostMimeXmlBinding); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutputBinding; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myServiceDescription.Bindings.Add(myBinding); // Create a 'PortType' object. PortType myPostPortType = new PortType(); myPostPortType.Name = "OperationServiceHttpPost"; // <Snippet1> Operation myPostOperation = new Operation(); myPostOperation.Name = myOperationBinding.Name; Console.WriteLine("'Operation' instance uses 'OperationBinding': " + myPostOperation.IsBoundBy(myOperationBinding)); // </Snippet1> OperationMessage myOperationMessage = (OperationMessage) new OperationInput(); myOperationMessage.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn"); OperationMessage myOperationMessage1 = (OperationMessage) new OperationOutput(); myOperationMessage1.Message = new XmlQualifiedName("s0:AddNumbersHttpPostOut"); myPostOperation.Messages.Add(myOperationMessage); myPostOperation.Messages.Add(myOperationMessage1); // Add the 'Operation' to 'PortType'. myPostPortType.Operations.Add(myPostOperation); // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. myServiceDescription.PortTypes.Add(myPostPortType); // Write the 'ServiceDescription' as a WSDL file. myServiceDescription.Write("Operation_IsBoundBy_Output_CS.wsdl"); Console.WriteLine("WSDL file with name 'Operation_IsBoundBy_Output_CS.wsdl' created Successfully"); }
public static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("Operation_2_Input_CS.wsdl"); Binding myBinding = new Binding(); myBinding.Name = "Operation_2_ServiceHttpPost"; XmlQualifiedName myQualifiedName = new XmlQualifiedName("s0:Operation_2_ServiceHttpPost"); myBinding.Type = myQualifiedName; HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; // Add the 'HttpBinding' to the 'Binding'. myBinding.Extensions.Add(myHttpBinding); OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding(); myHttpOperationBinding.Location = "/AddNumbers"; // Add the 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myHttpOperationBinding); InputBinding myInputBinding = new InputBinding(); MimeContentBinding myPostMimeContentbinding = new MimeContentBinding(); myPostMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInputBinding.Extensions.Add(myPostMimeContentbinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; OutputBinding myOutputBinding = new OutputBinding(); MimeXmlBinding myPostMimeXmlbinding = new MimeXmlBinding(); myPostMimeXmlbinding.Part = "Body"; myOutputBinding.Extensions.Add(myPostMimeXmlbinding); // 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); Port myPostPort = new Port(); myPostPort.Name = "Operation_2_ServiceHttpPost"; myPostPort.Binding = new XmlQualifiedName("s0:Operation_2_ServiceHttpPost"); HttpAddressBinding myPostAddressBinding = new HttpAddressBinding(); myPostAddressBinding.Location = "http://localhost/Operation_2/Operation_2_Service.cs.asmx"; // Add the 'HttpAddressBinding' to the 'Port'. myPostPort.Extensions.Add(myPostAddressBinding); // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.Services[0].Ports.Add(myPostPort); PortType myPostPortType = new PortType(); myPostPortType.Name = "Operation_2_ServiceHttpPost"; Operation myPostOperation = new Operation(); myPostOperation.Name = "AddNumbers"; OperationMessage myPostOperationInput = (OperationMessage) new OperationInput(); myPostOperationInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn"); OperationMessage myPostOperationOutput = (OperationMessage) new OperationOutput(); myPostOperationOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostout"); myPostOperation.Messages.Add(myPostOperationInput); myPostOperation.Messages.Add(myPostOperationOutput); // Add the 'Operation' to 'PortType'. myPostPortType.Operations.Add(myPostOperation); // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. myDescription.PortTypes.Add(myPostPortType); Message myPostMessage1 = new Message(); myPostMessage1.Name = "AddNumbersHttpPostIn"; MessagePart myPostMessagePart1 = new MessagePart(); myPostMessagePart1.Name = "firstnumber"; myPostMessagePart1.Type = new XmlQualifiedName("s:string"); MessagePart myPostMessagePart2 = new MessagePart(); myPostMessagePart2.Name = "secondnumber"; myPostMessagePart2.Type = new XmlQualifiedName("s:string"); // Add the 'MessagePart' objects to 'Messages'. myPostMessage1.Parts.Add(myPostMessagePart1); myPostMessage1.Parts.Add(myPostMessagePart2); Message myPostMessage2 = new Message(); myPostMessage2.Name = "AddNumbersHttpPostout"; MessagePart myPostMessagePart3 = new MessagePart(); myPostMessagePart3.Name = "Body"; myPostMessagePart3.Element = new XmlQualifiedName("s0:int"); // Add the 'MessagePart' to 'Message'. myPostMessage2.Parts.Add(myPostMessagePart3); // Add the 'Message' objects to 'ServiceDescription'. myDescription.Messages.Add(myPostMessage1); myDescription.Messages.Add(myPostMessage2); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("Operation_2_Output_CS.wsdl"); Console.WriteLine(" 'Operation_2_Output_CS.wsdl' file created Successfully"); // <Snippet1> // <Snippet2> string myString = null; Operation myOperation = new Operation(); myDescription = ServiceDescription.Read("Operation_2_Input_CS.wsdl"); Message[] myMessage = new Message[myDescription.Messages.Count]; // Copy the messages from the service description. myDescription.Messages.CopyTo(myMessage, 0); for (int i = 0; i < myDescription.Messages.Count; i++) { MessagePart[] myMessagePart = new MessagePart[myMessage[i].Parts.Count]; // Copy the message parts into a MessagePart. myMessage[i].Parts.CopyTo(myMessagePart, 0); for (int j = 0; j < myMessage[i].Parts.Count; j++) { myString += myMessagePart[j].Name; myString += " "; } } // Set the ParameterOrderString equal to the list of // message part names. myOperation.ParameterOrderString = myString; string[] myString1 = myOperation.ParameterOrder; int k = 0; Console.WriteLine("The list of message part names is as follows:"); while (k < 5) { Console.WriteLine(myString1[k]); k++; } // </Snippet2> // </Snippet1> } catch (Exception e) { Console.WriteLine("The following Exception is raised : " + e.Message); } }
public static void Main() { ServiceDescription myDescription = ServiceDescription.Read("HttpBinding_ctor_Input_CS.wsdl"); // <Snippet1> // <Snippet2> // Create 'Binding' object. Binding myBinding = new Binding(); myBinding.Name = "MyHttpBindingServiceHttpPost"; XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:MyHttpBindingServiceHttpPost"); myBinding.Type = qualifiedName; // Create 'HttpBinding' object. HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; Console.WriteLine("HttpBinding Namespace : " + HttpBinding.Namespace); // </Snippet2> // Add 'HttpBinding' to 'Binding'. myBinding.Extensions.Add(myHttpBinding); // </Snippet1> // Create 'OperationBinding' object. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myOperation = new HttpOperationBinding(); myOperation.Location = "/AddNumbers"; // Add 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myOperation); // Create 'InputBinding' object. InputBinding myInput = new InputBinding(); MimeContentBinding postMimeContentbinding = new MimeContentBinding(); postMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInput.Extensions.Add(postMimeContentbinding); // Add 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInput; // Create 'OutputBinding' object. OutputBinding myOutput = new OutputBinding(); MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding(); postMimeXmlbinding.Part = "Body"; myOutput.Extensions.Add(postMimeXmlbinding); // Add 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // Add 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); // <Snippet3> // Create a 'Port' object. Port postPort = new Port(); postPort.Name = "MyHttpBindingServiceHttpPost"; postPort.Binding = new XmlQualifiedName("s0:MyHttpBindingServiceHttpPost"); // Create 'HttpAddressBinding' object. HttpAddressBinding postAddressBinding = new HttpAddressBinding(); postAddressBinding.Location = "http://localhost/HttpBinding_ctor/HttpBinding_ctor_Service.cs.asmx"; // Add 'HttpAddressBinding' to 'Port'. postPort.Extensions.Add(postAddressBinding); // </Snippet3> // Add 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.Services[0].Ports.Add(postPort); // Write 'ServiceDescription' as a WSDL file. myDescription.Write("HttpBinding_ctor_Output_CS.wsdl"); Console.WriteLine("WSDL file with name 'HttpBinding_ctor_Output_CS.wsdl' file created Successfully"); }
public static void Main() { try { int myInt = 0; ServiceDescription myServiceDescription = ServiceDescription.Read ("MimeText_Match_MatchColl_9_Input_CS.wsdl"); // Create the 'Binding' object. Binding myBinding = new Binding(); // Initialize 'Name' property of 'Binding' class. myBinding.Name = "MimeText_Match_MatchCollServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName ("s0:MimeText_Match_MatchCollServiceHttpPost"); 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); // <Snippet1> // Create the 'InputBinding' object. InputBinding myInputBinding = new InputBinding(); MimeTextBinding myMimeTextBinding = new MimeTextBinding(); MimeTextMatchCollection myMimeTextMatchCollection; // <Snippet5> // <Snippet4> // <Snippet3> // Get an array instance of 'MimeTextMatch' class. MimeTextMatch[] myMimeTextMatch = new MimeTextMatch[4]; myMimeTextMatchCollection = myMimeTextBinding.Matches; // Initialize properties of 'MimeTextMatch' class. for (myInt = 0; myInt < 4; myInt++) { // Create the 'MimeTextMatch' instance. myMimeTextMatch[myInt] = new MimeTextMatch(); myMimeTextMatch[myInt].Name = "Title"; myMimeTextMatch[myInt].Type = "*/*"; myMimeTextMatch[myInt].IgnoreCase = true; if (true == myMimeTextMatchCollection.Contains(myMimeTextMatch[0])) { myMimeTextMatch[myInt].Name = "Title" + Convert.ToString(myInt); myMimeTextMatch[myInt].Capture = 2; myMimeTextMatch[myInt].Group = 2; myMimeTextMatchCollection.Add(myMimeTextMatch[myInt]); } else { myMimeTextMatchCollection.Add(myMimeTextMatch[myInt]); myMimeTextMatchCollection[myInt].RepeatsString = "2"; } } myMimeTextMatchCollection = myMimeTextBinding.Matches; // Copy collection to 'MimeTextMatch' array instance. myMimeTextMatchCollection.CopyTo(myMimeTextMatch, 0); // </Snippet3> // </Snippet4> // </Snippet5> myInputBinding.Extensions.Add(myMimeTextBinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; // Create the 'OutputBinding' instance. OutputBinding myOutputBinding = new OutputBinding(); // Create the 'MimeTextBinding' instance. MimeTextBinding myMimeTextBinding1 = new MimeTextBinding(); // <Snippet9> // <Snippet8> // <Snippet7> // <Snippet6> // <Snippet2> // Get an instance of 'MimeTextMatchCollection'. MimeTextMatchCollection myMimeTextMatchCollection1 = new MimeTextMatchCollection(); MimeTextMatch[] myMimeTextMatch1 = new MimeTextMatch[5]; myMimeTextMatchCollection1 = myMimeTextBinding1.Matches; for (myInt = 0; myInt < 4; myInt++) { myMimeTextMatch1[myInt] = new MimeTextMatch(); myMimeTextMatch1[myInt].Name = "Title" + Convert.ToString(myInt); if (myInt != 0) { myMimeTextMatch1[myInt].RepeatsString = "7"; } myMimeTextMatchCollection1.Add(myMimeTextMatch1[myInt]); } myMimeTextMatch1[4] = new MimeTextMatch(); // Remove 'MimeTextMatch' instance from collection. myMimeTextMatchCollection1.Remove(myMimeTextMatch1[1]); // Using MimeTextMatchCollection.Item indexer to comapre. if (myMimeTextMatch1[2] == myMimeTextMatchCollection1[1]) { // Check whether 'MimeTextMatch' instance exists. myInt = myMimeTextMatchCollection1.IndexOf(myMimeTextMatch1[2]); // Insert 'MimeTextMatch' instance at a desired position. myMimeTextMatchCollection1.Insert(1, myMimeTextMatch1[myInt]); myMimeTextMatchCollection1[1].RepeatsString = "5"; myMimeTextMatchCollection1.Insert(4, myMimeTextMatch1[myInt]); } // </Snippet2> // </Snippet6> // </Snippet7> // </Snippet8> // </Snippet9> // </Snippet1> myOutputBinding.Extensions.Add(myMimeTextBinding1); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutputBinding; // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutputBinding; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myServiceDescription.Bindings.Add(myBinding); // Write the 'ServiceDescription' as a WSDL file. myServiceDescription.Write("MimeText_Match_MatchColl_9_Output_CS.wsdl"); Console.WriteLine("WSDL file with name 'MimeText_Match_MatchColl_9_Output_CS.wsdl' is" + " created successfully."); } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }
public static void Main() { try { int myInt = 0; ServiceDescription myServiceDescription = ServiceDescription.Read("MimeTextMatch_5_Input_CS.wsdl"); // Create the 'Binding' object. Binding myBinding = new Binding(); // Initialize 'Name' property of 'Binding' class. myBinding.Name = "MimeTextMatchServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:MimeTextMatchServiceHttpPost"); 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' object to 'OperationBinding'. myOperationBinding.Extensions.Add(myHttpOperationBinding); // <Snippet5> // <Snippet4> // <Snippet3> // <Snippet2> // Create an InputBinding. InputBinding myInputBinding = new InputBinding(); MimeTextBinding myMimeTextBinding = new MimeTextBinding(); MimeTextMatchCollection myMimeTextMatchCollection1 = new MimeTextMatchCollection(); MimeTextMatch[] myMimeTextMatch = new MimeTextMatch[3]; myMimeTextMatchCollection1 = myMimeTextBinding.Matches; // Intialize the MimeTextMatch. for (myInt = 0; myInt < 3; myInt++) { // Get a new MimeTextMatch. myMimeTextMatch[myInt] = new MimeTextMatch(); // Assign values to properties of the MimeTextMatch. myMimeTextMatch[myInt].Name = "Title" + Convert.ToString(myInt); myMimeTextMatch[myInt].Type = "*/*"; myMimeTextMatch[myInt].Pattern = "TITLE>(.*?)<"; myMimeTextMatch[myInt].IgnoreCase = true; myMimeTextMatch[myInt].Capture = 2; myMimeTextMatch[myInt].Group = 2; if (myInt != 0) { // Assign the Repeats property if the index is not 0. myMimeTextMatch[myInt].Repeats = 2; } else { // Assign the RepeatsString property if the index is 0. myMimeTextMatch[myInt].RepeatsString = "4"; } // Add the MimeTextMatch to the collection. myMimeTextMatchCollection1.Add(myMimeTextMatch[myInt]); } // </Snippet2> // </Snippet3> // </Snippet4> // </Snippet5> myInputBinding.Extensions.Add(myMimeTextBinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; // Create the 'OutputBinding' instance. OutputBinding myOutput = new OutputBinding(); MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding(); // Initialize 'Part' property of 'MimeXmlBinding' class. postMimeXmlbinding.Part = "Body"; // Add 'MimeXmlBinding' instance to 'OutputBinding' instance. myOutput.Extensions.Add(postMimeXmlbinding); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myServiceDescription.Bindings.Add(myBinding); // Write the 'ServiceDescription' as a WSDL file. myServiceDescription.Write("MimeTextMatch_5_Output_CS.wsdl"); Console.WriteLine("WSDL file with name 'MimeTextMatch_5_Output_CS.wsdl' is" + " created successfully."); } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }