internal static bool Check(SoapFaultBinding soapFaultBinding, FaultBinding faultBinding, WsdlWarningHandler warningHandler) { if (string.IsNullOrEmpty(soapFaultBinding.Name)) { string str = System.ServiceModel.SR.GetString("XsdMissingRequiredAttribute1", new object[] { "name" }); string warning = System.ServiceModel.SR.GetString("IgnoreSoapFaultBinding3", new object[] { faultBinding.OperationBinding.Name, faultBinding.OperationBinding.Binding.ServiceDescription.TargetNamespace, str }); warningHandler(warning); return(false); } return(true); }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } #pragma warning suppress 56506 // Microsoft, these properties cannot be null in this context if (context.Endpoint.Binding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding"); } BindingElementCollection bindingElements = GetBindingElements(context); MessageEncodingBindingElement messageEncodingBindingElement = bindingElements.Find <MessageEncodingBindingElement>(); TextMessageEncodingBindingElement textEncodingBindingElement = messageEncodingBindingElement as TextMessageEncodingBindingElement; if (messageEncodingBindingElement != null) { Type elementType = messageEncodingBindingElement.GetType(); if (elementType != typeof(TextMessageEncodingBindingElement) && elementType != typeof(BinaryMessageEncodingBindingElement) && elementType != typeof(MtomMessageEncodingBindingElement)) { return; } } EnsureMessageEncoding(context, messageEncodingBindingElement); foreach (OperationBinding wsdlOperationBinding in context.WsdlBinding.Operations) { OperationDescription operation = context.GetOperationDescription(wsdlOperationBinding); for (int i = 0; i < operation.Messages.Count; i++) { MessageDescription message = operation.Messages[i]; MessageBinding wsdlMessageBinding = context.GetMessageBinding(message); ImportMessageSoapAction(context.ContractConversionContext, message, wsdlMessageBinding, i != 0 /*isResponse*/); } foreach (FaultDescription fault in operation.Faults) { FaultBinding wsdlFaultBinding = context.GetFaultBinding(fault); if (wsdlFaultBinding != null) { ImportFaultSoapAction(context.ContractConversionContext, fault, wsdlFaultBinding); } } } }
public static void Main() { try { // Input wsdl file. string myInputWsdlFile = "SoapFaultBindingInput_cs.wsdl"; // Output wsdl file. string myOutputWsdlFile = "SoapFaultBindingOutput_cs.wsdl"; // Initialize an instance of a 'ServiceDescription' object. ServiceDescription myServiceDescription = ServiceDescription.Read(myInputWsdlFile); // Get a SOAP binding object with binding name "MyService1Soap". Binding myBinding = myServiceDescription.Bindings["MyService1Soap"]; // Create a new instance of 'SoapFaultBinding' class. SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding(); // Encode fault message using rules specified by 'Encoding' property. mySoapFaultBinding.Use = SoapBindingUse.Encoded; // Set the URI representing the encoding style. mySoapFaultBinding.Encoding = "http://tempuri.org/stockquote"; // Set the URI representing the location of the specification // for encoding of content not defined by 'Encoding' property'. mySoapFaultBinding.Namespace = "http://tempuri.org/stockquote"; // Create a new instance of 'FaultBinding'. FaultBinding myFaultBinding = new FaultBinding(); myFaultBinding.Name = "AddFaultbinding"; myFaultBinding.Extensions.Add(mySoapFaultBinding); // Get existing 'OperationBinding' object. OperationBinding myOperationBinding = myBinding.Operations[0]; myOperationBinding.Faults.Add(myFaultBinding); // Create a new wsdl file. myServiceDescription.Write(myOutputWsdlFile); Console.WriteLine("The new wsdl file created is :" + myOutputWsdlFile); Console.WriteLine("Proxy could be created using command : wsdl " + myOutputWsdlFile); } catch (Exception e) { Console.WriteLine("Error occured : " + e.Message); } }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (context.Endpoint.Binding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding"); } MessageEncodingBindingElement encodingBindingElement = GetBindingElements(context).Find <MessageEncodingBindingElement>(); if (encodingBindingElement != null) { System.Type type = encodingBindingElement.GetType(); if (((type != typeof(TextMessageEncodingBindingElement)) && (type != typeof(BinaryMessageEncodingBindingElement))) && (type != typeof(MtomMessageEncodingBindingElement))) { return; } } EnsureMessageEncoding(context, encodingBindingElement); foreach (OperationBinding binding in context.WsdlBinding.Operations) { OperationDescription operationDescription = context.GetOperationDescription(binding); for (int i = 0; i < operationDescription.Messages.Count; i++) { MessageDescription message = operationDescription.Messages[i]; MessageBinding messageBinding = context.GetMessageBinding(message); ImportMessageSoapAction(context.ContractConversionContext, message, messageBinding, i != 0); } foreach (FaultDescription description3 in operationDescription.Faults) { FaultBinding faultBinding = context.GetFaultBinding(description3); if (faultBinding != null) { ImportFaultSoapAction(context.ContractConversionContext, description3, faultBinding); } } } }
internal static void CreateSoapFaultBinding(string name, WsdlEndpointConversionContext endpointContext, FaultBinding wsdlFaultBinding, bool isEncoded) { XmlElement extension = CreateSoapFaultBinding(GetSoapVersion(endpointContext.WsdlBinding)); extension.Attributes.Append(CreateLocalAttribute("name", name)); extension.Attributes.Append(CreateLocalAttribute("use", isEncoded ? "encoded" : "literal")); wsdlFaultBinding.Extensions.Add(extension); }
private static void ImportFaultSoapAction(WsdlContractConversionContext contractContext, FaultDescription fault, FaultBinding wsdlFaultBinding) { string str = SoapHelper.ReadSoapAction(wsdlFaultBinding.OperationBinding); if (((contractContext != null) && (WsdlImporter.WSAddressingHelper.FindWsaActionAttribute(contractContext.GetOperationFault(fault)) == null)) && (str != null)) { fault.Action = str; } }
public bool Contains(FaultBinding bindingOperationFault) { return(List.Contains(bindingOperationFault)); }
public void Remove(FaultBinding bindingOperationFault) { List.Remove(bindingOperationFault); }
// Methods public int Add(FaultBinding bindingOperationFault) {}
public void CopyTo (FaultBinding[] array, int index) { List.CopyTo (array, index); }
public bool Contains (FaultBinding bindingOperationFault) { return List.Contains (bindingOperationFault); }
public int Add (FaultBinding bindingOperationFault) { Insert (Count, bindingOperationFault); return (Count - 1); }
public void CopyTo(FaultBinding[] array, int index) {}
public void Remove(FaultBinding bindingOperationFault) {}
public bool Contains(FaultBinding bindingOperationFault) {}
public int IndexOf(FaultBinding bindingOperationFault) {}
internal void AddFaultBinding(FaultDescription faultDescription, FaultBinding wsdlFaultBinding) { this.wsdlFaultBindings.Add(faultDescription, wsdlFaultBinding); this.faultDescriptionBindings.Add(wsdlFaultBinding, faultDescription); }
public int IndexOf (FaultBinding bindingOperationFault) { return List.IndexOf (bindingOperationFault); }
public void Insert(int index, FaultBinding bindingOperationFault) { List.Insert(index, bindingOperationFault); }
public void Insert (int index, FaultBinding bindingOperationFault) { List.Insert (index, bindingOperationFault); }
public int Add(FaultBinding bindingOperationFault) { Insert(Count, bindingOperationFault); return(Count - 1); }
public void Remove (FaultBinding bindingOperationFault) { List.Remove (bindingOperationFault); }
public int IndexOf(FaultBinding bindingOperationFault) { return(List.IndexOf(bindingOperationFault)); }
public static void Main() { ServiceDescription myServiceDescription = new ServiceDescription(); myServiceDescription.Name = "StockQuote"; myServiceDescription.TargetNamespace = "http://www.contoso.com/stockquote.wsdl"; // Generate the 'Types' element. XmlSchema myXmlSchema = new XmlSchema(); myXmlSchema.AttributeFormDefault = XmlSchemaForm.Qualified; myXmlSchema.ElementFormDefault = XmlSchemaForm.Qualified; myXmlSchema.TargetNamespace = "http://www.contoso.com/stockquote.wsdl"; //XmlSchemaElement myXmlSchemaElement; XmlSchemaComplexType myXmlSchemaComplexType = new XmlSchemaComplexType(); myXmlSchemaComplexType.Name = "GetTradePriceInputType"; XmlSchemaSequence myXmlSchemaSequence = new XmlSchemaSequence(); myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "tickerSymbol", true, new XmlQualifiedName("s:string"))); myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "time", true, new XmlQualifiedName("s:string"))); myXmlSchemaComplexType.Particle = myXmlSchemaSequence; myXmlSchema.Items.Add(myXmlSchemaComplexType); myXmlSchemaComplexType = new XmlSchemaComplexType(); myXmlSchemaComplexType.Name = "GetTradePriceOutputType"; myXmlSchemaSequence = new XmlSchemaSequence(); myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "result", true, new XmlQualifiedName("s:string"))); myXmlSchemaComplexType.Particle = myXmlSchemaSequence; myXmlSchema.Items.Add(myXmlSchemaComplexType); myXmlSchemaComplexType = new XmlSchemaComplexType(); myXmlSchemaComplexType.Name = "GetTradePriceStringFaultType"; myXmlSchemaSequence = new XmlSchemaSequence(); myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "error", true, new XmlQualifiedName("s:string"))); myXmlSchemaComplexType.Particle = myXmlSchemaSequence; myXmlSchema.Items.Add(myXmlSchemaComplexType); myXmlSchemaComplexType = new XmlSchemaComplexType(); myXmlSchemaComplexType.Name = "GetTradePriceStringIntType"; myXmlSchemaSequence = new XmlSchemaSequence(); myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "error", true, new XmlQualifiedName("s:int"))); myXmlSchemaComplexType.Particle = myXmlSchemaSequence; myXmlSchema.Items.Add(myXmlSchemaComplexType); myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapIn", new XmlQualifiedName("s0:GetTradePriceInputType"))); myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapOut", new XmlQualifiedName("s0:GetTradePriceOutputType"))); myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapStringFault", new XmlQualifiedName("s0:GetTradePriceStringFaultType"))); myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapIntFault", new XmlQualifiedName("s0:GetTradePriceIntFaultType"))); myServiceDescription.Types.Schemas.Add(myXmlSchema); // Generate the 'Message' element. MessageCollection myMessageCollection = myServiceDescription.Messages; myMessageCollection.Add(CreateMessage("GetTradePriceInput", "parameters", "GetTradePriceSoapIn", myServiceDescription.TargetNamespace)); myMessageCollection.Add(CreateMessage("GetTradePriceOutput", "parameters", "GetTradePriceSoapOut", myServiceDescription.TargetNamespace)); myMessageCollection.Add(CreateMessage("GetTradePriceStringFault", "parameters", "GetTradePriceStringSoapFault", myServiceDescription.TargetNamespace)); myMessageCollection.Add(CreateMessage("GetTradePriceIntFault", "parameters", "GetTradePriceIntSoapFault", myServiceDescription.TargetNamespace)); // Generate the 'Port Type' element. PortTypeCollection myPortTypeCollection = myServiceDescription.PortTypes; PortType myPortType = new PortType(); myPortType.Name = "StockQuotePortType"; OperationCollection myOperationCollection = myPortType.Operations; Operation myOperation = new Operation(); myOperation.Name = "GetTradePrice"; OperationMessage myOperationMessage; OperationMessageCollection myOperationMessageCollection = myOperation.Messages; myOperationMessage = (OperationMessage) new OperationInput(); myOperationMessage.Message = new XmlQualifiedName("s0:GetTradePriceInput"); myOperationMessageCollection.Add(myOperationMessage); myOperationMessage = (OperationMessage) new OperationOutput(); myOperationMessage.Message = new XmlQualifiedName("s0:GetTradePriceOutput"); myOperationMessageCollection.Add(myOperationMessage); OperationFault myOperationFault = new OperationFault(); myOperationFault.Name = "ErrorString"; myOperationFault.Message = new XmlQualifiedName("s0:GetTradePriceStringFault"); myOperation.Faults.Add(myOperationFault); myOperationFault = new OperationFault(); myOperationFault.Name = "ErrorInt"; myOperationFault.Message = new XmlQualifiedName("s0:GetTradePriceIntFault"); myOperation.Faults.Add(myOperationFault); myOperationCollection.Add(myOperation); myPortTypeCollection.Add(myPortType); // Generate the 'Binding' element. ServiceDescriptionFormatExtensionCollection myExtensions; BindingCollection myBindingCollection = myServiceDescription.Bindings; Binding myBinding = new Binding(); myBinding.Name = "StockQuoteSoapBinding"; myBinding.Type = new XmlQualifiedName("s0:StockQuotePortType"); myExtensions = myBinding.Extensions; SoapBinding mySoapBinding = new SoapBinding(); mySoapBinding.Style = SoapBindingStyle.Document; mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"; myExtensions.Add(mySoapBinding); OperationBindingCollection myOperationBindingCollection = myBinding.Operations; OperationBinding myOperationBinding = new OperationBinding(); myExtensions = myOperationBinding.Extensions; SoapOperationBinding mySoapBindingOperation = new SoapOperationBinding(); mySoapBindingOperation.SoapAction = "http://www.contoso.com/GetTradePrice"; myExtensions.Add(mySoapBindingOperation); myOperationBinding.Name = "GetTradePrice"; myOperationBinding.Input = new InputBinding(); myExtensions = myOperationBinding.Input.Extensions; SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding(); mySoapBodyBinding.Use = SoapBindingUse.Literal; mySoapBodyBinding.Namespace = "http://www.contoso.com/stockquote"; myExtensions.Add(mySoapBodyBinding); myOperationBinding.Output = new OutputBinding(); myExtensions = myOperationBinding.Output.Extensions; mySoapBodyBinding = new SoapBodyBinding(); mySoapBodyBinding.Use = SoapBindingUse.Literal; mySoapBodyBinding.Namespace = "http://www.contoso.com/stockquote"; myExtensions.Add(mySoapBodyBinding); // <Snippet1> // <Snippet2> // <Snippet3> FaultBindingCollection myFaultBindingCollection = myOperationBinding.Faults; FaultBinding myFaultBinding = new FaultBinding(); myFaultBinding.Name = "ErrorString"; // Associate SOAP fault binding to the fault binding of the operation. myExtensions = myFaultBinding.Extensions; SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding(); mySoapFaultBinding.Use = SoapBindingUse.Literal; mySoapFaultBinding.Namespace = "http://www.contoso.com/stockquote"; myExtensions.Add(mySoapFaultBinding); myFaultBindingCollection.Add(myFaultBinding); // </Snippet3> // </Snippet2> // </Snippet1> myFaultBinding = new FaultBinding(); myFaultBinding.Name = "ErrorInt"; // Associate SOAP fault binding to the fault binding of the operation. myExtensions = myFaultBinding.Extensions; mySoapFaultBinding = new SoapFaultBinding(); mySoapFaultBinding.Use = SoapBindingUse.Literal; mySoapFaultBinding.Namespace = "http://www.contoso.com/stockquote"; myExtensions.Add(mySoapFaultBinding); myFaultBindingCollection.Add(myFaultBinding); myOperationBindingCollection.Add(myOperationBinding); myBindingCollection.Add(myBinding); // Generate the 'Service' element. ServiceCollection myServiceCollection = myServiceDescription.Services; // <Snippet4> Service myService = new Service(); // Add a simple documentation for the service to ease the readability of the generated WSDL file. myService.Documentation = "A Simple Stock Quote Service"; myService.Name = "StockQuoteService"; PortCollection myPortCollection = myService.Ports; Port myPort = new Port(); myPort.Name = "StockQuotePort"; myPort.Binding = new XmlQualifiedName("s0:StockQuoteSoapBinding"); myExtensions = myPort.Extensions; SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding(); mySoapAddressBinding.Location = "http://www.contoso.com/stockquote"; myExtensions.Add(mySoapAddressBinding); myPortCollection.Add(myPort); // </Snippet4> myServiceCollection.Add(myService); // Display the WSDL generated to the console. myServiceDescription.Write(Console.Out); }
public static void Main() { try { // Read the StockQuote.wsdl file as input. ServiceDescription myServiceDescription = ServiceDescription.Read("StockQuote_cs.wsdl"); // <Snippet2> // <Snippet3> // <Snippet4> // <Snippet5> // <Snippet6> // <Snippet7> PortTypeCollection myPortTypeCollection = myServiceDescription.PortTypes; PortType myPortType = myPortTypeCollection[0]; OperationCollection myOperationCollection = myPortType.Operations; Operation myOperation = myOperationCollection[0]; OperationFaultCollection myOperationFaultCollection = myOperation.Faults; // Reverse the operation fault order. if (myOperationFaultCollection.Count > 1) { OperationFault myOperationFault = myOperationFaultCollection[0]; OperationFault[] myOperationFaultArray = new OperationFault[myOperationFaultCollection.Count]; // Copy the operation faults to a temporary array. myOperationFaultCollection.CopyTo(myOperationFaultArray, 0); // Remove all the operation faults from the collection. for (int i = 0; i < myOperationFaultArray.Length; i++) { myOperationFaultCollection.Remove(myOperationFaultArray[i]); } // Insert the operation faults in the reverse order. for (int i = 0, j = (myOperationFaultArray.Length - 1); i < myOperationFaultArray.Length; i++, j--) { myOperationFaultCollection.Insert( i, myOperationFaultArray[j]); } if (myOperationFaultCollection.Contains(myOperationFault) && (myOperationFaultCollection.IndexOf(myOperationFault) == myOperationFaultCollection.Count - 1)) { Console.WriteLine( "Succeeded in reversing the operation faults."); } else { Console.WriteLine("Error while reversing the faults."); } } // </Snippet7> // </Snippet6> // </Snippet5> // </Snippet4> // </Snippet3> // </Snippet2> BindingCollection myBindingCollection = myServiceDescription.Bindings; Binding myBinding = myBindingCollection[0]; OperationBindingCollection myOperationBindingCollection = myBinding.Operations; OperationBinding myOperationBinding = myOperationBindingCollection[0]; FaultBindingCollection myFaultBindingCollection = myOperationBinding.Faults; // Reverse the fault binding order. if (myFaultBindingCollection.Count > 1) { FaultBinding myFaultBinding = myFaultBindingCollection[0]; FaultBinding[] myFaultBindingArray = new FaultBinding[myFaultBindingCollection.Count]; // Copy the fault bindings to a temporary array. myFaultBindingCollection.CopyTo(myFaultBindingArray, 0); // Remove all the fault bindings. for (int i = 0; i < myFaultBindingArray.Length; i++) { myFaultBindingCollection.Remove(myFaultBindingArray[i]); } // Insert the fault bindings in the reverse order. for (int i = 0, j = (myFaultBindingArray.Length - 1); i < myFaultBindingArray.Length; i++, j--) { myFaultBindingCollection.Insert(i, myFaultBindingArray[j]); } // Check whether the first element before the reversal // is now the last element. if (myFaultBindingCollection.Contains(myFaultBinding) && myFaultBindingCollection.IndexOf(myFaultBinding) == (myFaultBindingCollection.Count - 1)) { // Write the WSDL generated to a file. myServiceDescription.Write("StockQuoteOut_cs.wsdl"); Console.WriteLine( "The file StockQuoteOut_cs.wsdl was successfully written."); } else { Console.WriteLine( "An error occurred while reversing the input WSDL file."); } } } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
public int IndexOf(FaultBinding bindingOperationFault) { }
public bool Contains(FaultBinding bindingOperationFault) { }
public void Remove(FaultBinding bindingOperationFault) { }
public static void Main() { // Read the 'StockQuote.wsdl' file as input. ServiceDescription myServiceDescription = ServiceDescription.Read("StockQuote.wsdl"); PortTypeCollection myPortTypeCollection = myServiceDescription.PortTypes; PortType myPortType = myPortTypeCollection[0]; OperationCollection myOperationCollection = myPortType.Operations; Operation myOperation = myOperationCollection[0]; OperationFaultCollection myOperationFaultCollection = myOperation.Faults; // Reverse the operation fault order. if (myOperationFaultCollection.Count > 1) { OperationFault[] myOperationFaultArray = new OperationFault[myOperationFaultCollection.Count]; // Copy the operation fault to a temporary array. myOperationFaultCollection.CopyTo(myOperationFaultArray, 0); // Remove all the operation fault instances in the fault binding collection. for (int i = 0; i < myOperationFaultArray.Length; i++) { myOperationFaultCollection.Remove(myOperationFaultArray[i]); } // Insert the operation fault instance in the reverse order. for (int i = 0, j = (myOperationFaultArray.Length - 1); i < myOperationFaultArray.Length; i++, j--) { myOperationFaultCollection.Insert(i, myOperationFaultArray[j]); } } // <Snippet1> // <Snippet2> // <Snippet3> // <Snippet4> // <Snippet5> // <Snippet6> BindingCollection myBindingCollection = myServiceDescription.Bindings; Binding myBinding = myBindingCollection[0]; OperationBindingCollection myOperationBindingCollection = myBinding.Operations; OperationBinding myOperationBinding = myOperationBindingCollection[0]; FaultBindingCollection myFaultBindingCollection = myOperationBinding.Faults; // Reverse the fault bindings order. if (myFaultBindingCollection.Count > 1) { FaultBinding myFaultBinding = myFaultBindingCollection[0]; FaultBinding[] myFaultBindingArray = new FaultBinding[myFaultBindingCollection.Count]; // Copy the fault bindings to a temporary array. myFaultBindingCollection.CopyTo(myFaultBindingArray, 0); // Remove all the fault binding instances in the fault binding collection. for (int i = 0; i < myFaultBindingArray.Length; i++) { myFaultBindingCollection.Remove(myFaultBindingArray[i]); } // Insert the fault binding instance in the reverse order. for (int i = 0, j = (myFaultBindingArray.Length - 1); i < myFaultBindingArray.Length; i++, j--) { myFaultBindingCollection.Insert(i, myFaultBindingArray[j]); } // Check if the first element in the collection before the reversal is now the last element. if (myFaultBindingCollection.Contains(myFaultBinding) && myFaultBindingCollection.IndexOf(myFaultBinding) == (myFaultBindingCollection.Count - 1)) { // Display the WSDL generated to the console. myServiceDescription.Write(Console.Out); } else { Console.WriteLine("Error while reversing"); } } // </Snippet6> // </Snippet5> // </Snippet4> // </Snippet3> // </Snippet2> // </Snippet1> }
// Methods public int Add(FaultBinding bindingOperationFault) { }
static void Main() { try { ServiceDescription myServiceDescription = ServiceDescription.Read("MathService_input_cs.wsdl"); string myTargetNamespace = myServiceDescription.TargetNamespace; // <Snippet2> // <Snippet3> // Create an OperationBinding for the Add operation. OperationBinding addOperationBinding = new OperationBinding(); string addOperation = "Add"; addOperationBinding.Name = addOperation; // </Snippet3> // <Snippet4> // Create an InputBinding for the Add operation. InputBinding myInputBinding = new InputBinding(); SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding(); mySoapBodyBinding.Use = SoapBindingUse.Literal; myInputBinding.Extensions.Add(mySoapBodyBinding); // Add the InputBinding to the OperationBinding. addOperationBinding.Input = myInputBinding; // </Snippet4> // <Snippet5> // Create an OutputBinding for the Add operation. OutputBinding myOutputBinding = new OutputBinding(); myOutputBinding.Extensions.Add(mySoapBodyBinding); // Add the OutputBinding to the OperationBinding. addOperationBinding.Output = myOutputBinding; // </Snippet5> // <Snippet6> // Create an extensibility element for a SoapOperationBinding. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.Style = SoapBindingStyle.Document; mySoapOperationBinding.SoapAction = myTargetNamespace + addOperation; // Add the extensibility element SoapOperationBinding to // the OperationBinding. addOperationBinding.Extensions.Add(mySoapOperationBinding); // </Snippet6> // </Snippet2> // <Snippet7> ServiceDescriptionFormatExtensionCollection myExtensions; // Get the FaultBindingCollection from the OperationBinding. FaultBindingCollection myFaultBindingCollection = addOperationBinding.Faults; FaultBinding myFaultBinding = new FaultBinding(); myFaultBinding.Name = "ErrorFloat"; // Associate SOAP fault binding to the fault binding of the operation. myExtensions = myFaultBinding.Extensions; SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding(); mySoapFaultBinding.Use = SoapBindingUse.Literal; mySoapFaultBinding.Namespace = myTargetNamespace; myExtensions.Add(mySoapFaultBinding); myFaultBindingCollection.Add(myFaultBinding); // </Snippet7> // Get the BindingCollection from the ServiceDescription. BindingCollection myBindingCollection = myServiceDescription.Bindings; // Get the OperationBindingCollection of SOAP binding // from the BindingCollection. OperationBindingCollection myOperationBindingCollection = myBindingCollection[0].Operations; myOperationBindingCollection.Add(addOperationBinding); Console.WriteLine( "The operations supported by this service are:"); foreach (OperationBinding myOperationBinding in myOperationBindingCollection) { // <Snippet8> Binding myBinding = myOperationBinding.Binding; Console.WriteLine(" Binding : " + myBinding.Name + " :: Name of operation : " + myOperationBinding.Name); // </Snippet8> FaultBindingCollection myFaultBindingCollection1 = myOperationBinding.Faults; foreach (FaultBinding myFaultBinding1 in myFaultBindingCollection1) { Console.WriteLine(" Fault : " + myFaultBinding1.Name); } } // Save the ServiceDescription to an external file. myServiceDescription.Write("MathService_new_cs.wsdl"); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
public ServiceDescription exportWSDL(EA.Repository repository, EA.Element component) { string faultnamespace = "http://www.iag.co.nz/soa/iagiaa/fault"; string iaaNamespace = "http://www.iag.co.nz/soa/iagiaa/v2"; string wsdlNamespace = component.Version; ServiceDescription service = new ServiceDescription(); service.TargetNamespace = wsdlNamespace; service.Name = component.Name; service.Namespaces.Add("iaa", iaaNamespace); service.Namespaces.Add("fault", faultnamespace); service.Namespaces.Add("soa", wsdlNamespace); XmlSchema schema = new XmlSchema(); service.Documentation = component.Notes; { schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.TargetNamespace = component.Version; { XmlSchemaImport si = new XmlSchemaImport(); si.SchemaLocation = "iagiaa_.xsd"; si.Namespace = iaaNamespace; schema.Includes.Add(si); } { XmlSchemaImport si = new XmlSchemaImport(); si.SchemaLocation = "iagiaa_fault.xsd"; si.Namespace = faultnamespace; schema.Includes.Add(si); } service.Types.Schemas.Add(schema); } Message faultMessage = new Message(); { faultMessage.Name = "ErrorInfo"; service.Messages.Add(faultMessage); MessagePart mp = new MessagePart(); mp.Name = "ErrorInfo"; XmlQualifiedName qn = new XmlQualifiedName("ErrorInfo", faultnamespace); mp.Element = qn; faultMessage.Parts.Add(mp); } Binding binding = new Binding(); service.Bindings.Add(binding); binding.Name = component.Name; binding.Type = new XmlQualifiedName(component.Name, wsdlNamespace); Soap12Binding soapBinding = new Soap12Binding(); binding.Extensions.Add(soapBinding); soapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"; PortType portType = new PortType(); portType.Name = component.Name; service.PortTypes.Add(portType); foreach (EA.Method m in component.Methods) { { } { Message inMessage = new Message(); inMessage.Name = m.Name + "SoapIn"; service.Messages.Add(inMessage); MessagePart mp = new MessagePart(); mp.Name = "Header"; XmlQualifiedName qn = new XmlQualifiedName("ApplicationContext", iaaNamespace); mp.Element = qn; inMessage.Parts.Add(mp); MessagePart ip = new MessagePart(); ip.Name = m.Name + "Part"; XmlQualifiedName iqn = new XmlQualifiedName(m.Name, wsdlNamespace); ip.Element = iqn; inMessage.Parts.Add(ip); } { Message outMessage = new Message(); outMessage.Name = m.Name + "SoapOut"; service.Messages.Add(outMessage); MessagePart ip = new MessagePart(); ip.Name = m.Name + "ResponsePart"; XmlQualifiedName iqn = new XmlQualifiedName(m.Name + "Response", wsdlNamespace); ip.Element = iqn; outMessage.Parts.Add(ip); } { Operation operation = new Operation(); portType.Operations.Add(operation); operation.Name = m.Name; OperationInput oi = new OperationInput(); oi.Message = new XmlQualifiedName(component.Name + "SoapIn", component.Version); operation.Messages.Add(oi); OperationOutput oo = new OperationOutput(); oo.Message = new XmlQualifiedName(component.Name + "SoapOut", component.Version); operation.Messages.Add(oo); OperationFault of = new OperationFault(); of.Name = faultMessage.Name; of.Message = new XmlQualifiedName("ErrorInfo", component.Version); operation.Faults.Add(of); } { OperationBinding opBinding = new OperationBinding(); binding.Operations.Add(opBinding); opBinding.Input = new InputBinding(); opBinding.Output = new OutputBinding(); FaultBinding faultBinding = new FaultBinding(); opBinding.Faults.Add(faultBinding); SoapHeaderBinding headerBinding = new SoapHeaderBinding(); opBinding.Input.Extensions.Add(headerBinding); headerBinding.Message = new XmlQualifiedName(m.Name + "SoapIn", wsdlNamespace); headerBinding.Part = "Header"; headerBinding.Use = SoapBindingUse.Literal; SoapBodyBinding bodyBinding = new SoapBodyBinding(); opBinding.Input.Extensions.Add(bodyBinding); bodyBinding.PartsString = m.Name + "Part"; SoapBodyBinding outBinding = new SoapBodyBinding(); opBinding.Output.Extensions.Add(outBinding); outBinding.Use = SoapBindingUse.Literal; faultBinding.Name = "ErrorResponseType"; SoapFaultBinding soapFaultBinding = new SoapFaultBinding(); faultBinding.Extensions.Add(soapFaultBinding); soapFaultBinding.Use = SoapBindingUse.Literal; } } return(service); }
static void ImportFaultSoapAction(WsdlContractConversionContext contractContext, FaultDescription fault, FaultBinding wsdlFaultBinding) { string soapAction = SoapHelper.ReadSoapAction(wsdlFaultBinding.OperationBinding); if (contractContext != null) { OperationFault wsdlOperationFault = contractContext.GetOperationFault(fault); string wsaAction = WsdlImporter.WSAddressingHelper.FindWsaActionAttribute(wsdlOperationFault); if (wsaAction == null && soapAction != null) { fault.Action = soapAction; } // } else { // } }
public static void Main() { try { // Input wsdl file. string myInputWsdlFile = "SoapFaultInput_cs.wsdl"; // Output wsdl file. string myOutputWsdlFile = "SoapFaultOutput_cs.wsdl"; // Initialize an instance of a 'ServiceDescription' object. ServiceDescription myServiceDescription = ServiceDescription.Read(myInputWsdlFile); // Get a SOAP binding object with binding name "MyService1Soap". Binding myBinding = myServiceDescription.Bindings["MyService1Soap"]; // Create the 'OperationBinding' object for the 'SOAP' protocol. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "Add"; // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.SoapAction = "http://tempuri.org/Add"; mySoapOperationBinding.Style = SoapBindingStyle.Document; // Add the 'SoapOperationBinding' object to 'OperationBinding' object. myOperationBinding.Extensions.Add(mySoapOperationBinding); // <Snippet1> // Create the 'InputBinding' object for the 'SOAP' protocol. InputBinding myInput = new InputBinding(); SoapBodyBinding mySoapBinding1 = new SoapBodyBinding(); mySoapBinding1.PartsString = "parameters"; mySoapBinding1.Use = SoapBindingUse.Literal; myInput.Extensions.Add(mySoapBinding1); // Assign the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInput; // Create the 'OutputBinding' object' for the 'SOAP' protocol.. OutputBinding myOutput = new OutputBinding(); myOutput.Extensions.Add(mySoapBinding1); // Assign the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // </Snippet1> // <Snippet2> // <Snippet3> // <Snippet4> // <Snippet5> // Create a new instance of 'SoapFaultBinding' class. SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding(); // Encode fault message using rules specified by 'Encoding' property. mySoapFaultBinding.Use = SoapBindingUse.Encoded; // Set the URI representing the encoding style. mySoapFaultBinding.Encoding = "http://tempuri.org/stockquote"; // Set the URI representing the location of the specification // for encoding of content not defined by 'Encoding' property'. mySoapFaultBinding.Namespace = "http://tempuri.org/stockquote"; // Create a new instance of 'FaultBinding'. FaultBinding myFaultBinding = new FaultBinding(); myFaultBinding.Name = "AddFaultbinding"; myFaultBinding.Extensions.Add(mySoapFaultBinding); // Get existing 'OperationBinding' object. myOperationBinding.Faults.Add(myFaultBinding); myBinding.Operations.Add(myOperationBinding); // </Snippet5> // </Snippet4> // </Snippet3> // </Snippet2> // Create a new wsdl file. myServiceDescription.Write(myOutputWsdlFile); Console.WriteLine("The new wsdl file created is :" + myOutputWsdlFile); Console.WriteLine("Proxy could be created using command : wsdl " + myOutputWsdlFile); } catch (Exception e) { Console.WriteLine("Error occurred : " + e.Message); } }
public FaultDescription GetFaultDescription(FaultBinding faultBinding) { return(this.faultDescriptionBindings[faultBinding]); }
private static void ImportFaultSoapAction(WsdlContractConversionContext contractContext, FaultDescription fault, FaultBinding wsdlFaultBinding) { string soapAction = SoapHelper.ReadSoapAction(wsdlFaultBinding.OperationBinding); if (contractContext != null) { OperationFault wsdlOperationFault = contractContext.GetOperationFault(fault); string wsaAction = WsdlImporter.WSAddressingHelper.FindWsaActionAttribute(wsdlOperationFault); if (wsaAction == null && soapAction != null) { fault.Action = soapAction; } //CONSIDER, hsomu: If WS-Addressing action was found, we should verify that it is the same as the SOAP action // (for the request message). } else { //CONSIDER, hsomu: verify SOAP action matches referenced contract.operation.message } }