public static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("MathService_Input_cs.wsdl"); PortTypeCollection myPortTypeCollection = myDescription.PortTypes; // Get the OperationCollection for SOAP protocol. OperationCollection myOperationCollection = myPortTypeCollection[0].Operations; // Get the OperationMessageCollection for the Add operation. OperationMessageCollection myOperationMessageCollection = myOperationCollection[0].Messages; // Indicate that the endpoint or service receives no // transmissions (None). Console.WriteLine("myOperationMessageCollection does not " + "contain any operation messages."); DisplayOperationFlowDescription(myOperationMessageCollection.Flow); Console.WriteLine(); // Indicate that the endpoint or service receives a message (OneWay). OperationMessage myInputOperationMessage = (OperationMessage) new OperationInput(); XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("AddSoapIn", myDescription.TargetNamespace); myInputOperationMessage.Message = myXmlQualifiedName; myOperationMessageCollection.Add(myInputOperationMessage); Console.WriteLine("myOperationMessageCollection contains " + "only input operation messages."); DisplayOperationFlowDescription(myOperationMessageCollection.Flow); Console.WriteLine(); myOperationMessageCollection.Remove(myInputOperationMessage); // Indicate that an endpoint or service sends a message (Notification). OperationMessage myOutputOperationMessage = (OperationMessage) new OperationOutput(); XmlQualifiedName myXmlQualifiedName1 = new XmlQualifiedName ("AddSoapOut", myDescription.TargetNamespace); myOutputOperationMessage.Message = myXmlQualifiedName1; myOperationMessageCollection.Add(myOutputOperationMessage); Console.WriteLine("myOperationMessageCollection contains " + "only output operation messages."); DisplayOperationFlowDescription(myOperationMessageCollection.Flow); Console.WriteLine(); // Indicate that an endpoint or service sends a message, then // receives a correlated message (SolicitResponse). myOperationMessageCollection.Add(myInputOperationMessage); Console.WriteLine("'myOperationMessageCollection' contains " + "an output operation message first, then " + "an input operation message."); DisplayOperationFlowDescription(myOperationMessageCollection.Flow); Console.WriteLine(); // Indicate that an endpoint or service receives a message, // then sends a correlated message (RequestResponse). myOperationMessageCollection.Remove(myInputOperationMessage); myOperationMessageCollection.Insert(0, myInputOperationMessage); Console.WriteLine("myOperationMessageCollection contains " + "an input operation message first, then " + "an output operation message."); DisplayOperationFlowDescription(myOperationMessageCollection.Flow); Console.WriteLine(); myDescription.Write("MathService_new_cs.wsdl"); Console.WriteLine( "The file MathService_new_cs.wsdl was successfully written."); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("MathService_input_cs.wsdl"); PortTypeCollection myPortTypeCollection = myDescription.PortTypes; // Get the OperationCollection for the SOAP protocol. OperationCollection myOperationCollection = myPortTypeCollection[0].Operations; // Get the OperationMessageCollection for the Add operation. OperationMessageCollection myOperationMessageCollection = myOperationCollection[0].Messages; // Display the Flow, Input, and Output properties. DisplayFlowInputOutput(myOperationMessageCollection, "Start"); // <Snippet2> // <Snippet4> // Get the operation message for the Add operation. OperationMessage myOperationMessage = myOperationMessageCollection[0]; OperationMessage myInputOperationMessage = (OperationMessage) new OperationInput(); XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName( "AddSoapIn", myDescription.TargetNamespace); myInputOperationMessage.Message = myXmlQualifiedName; // <Snippet3> OperationMessage[] myCollection = new OperationMessage[myOperationMessageCollection.Count]; myOperationMessageCollection.CopyTo(myCollection, 0); Console.WriteLine("Operation name(s) :"); for (int i = 0; i < myCollection.Length; i++) { Console.WriteLine(" " + myCollection[i].Operation.Name); } // </Snippet3> // Add the OperationMessage to the collection. myOperationMessageCollection.Add(myInputOperationMessage); // </Snippet4> DisplayFlowInputOutput(myOperationMessageCollection, "Add"); // <Snippet5> // <Snippet6> if (myOperationMessageCollection.Contains(myOperationMessage) == true) { int myIndex = myOperationMessageCollection.IndexOf(myOperationMessage); Console.WriteLine(" The index of the Add operation " + "message in the collection is : " + myIndex); } // </Snippet6> // </Snippet5> // </Snippet2> // <Snippet7> // <Snippet8> myOperationMessageCollection.Remove(myInputOperationMessage); // Display Flow, Input, and Output after removing. DisplayFlowInputOutput(myOperationMessageCollection, "Remove"); // Insert the message at index 0 in the collection. myOperationMessageCollection.Insert(0, myInputOperationMessage); // Display Flow, Input, and Output after inserting. DisplayFlowInputOutput(myOperationMessageCollection, "Insert"); // </Snippet8> // </Snippet7> myDescription.Write("MathService_new_cs.wsdl"); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }