private static SoapBinding CreateSoapBinding(EnvelopeVersion version, Binding wsdlBinding) { SoapBinding extension = null; if (version == EnvelopeVersion.Soap12) { extension = new Soap12Binding(); } else if (version == EnvelopeVersion.Soap11) { extension = new SoapBinding(); } wsdlBinding.Extensions.Add(extension); return(extension); }
private static object GetSoapBinding(System.ServiceModel.Channels.Binding binding) { if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap11) { SoapBinding soapBinding = new SoapBinding(); soapBinding.Transport = GetTransport(binding); soapBinding.Style = SoapBindingStyle.Document; return(soapBinding); } else if (binding.MessageVersion.Envelope == EnvelopeVersion.Soap12) { Soap12Binding soapBinding = new Soap12Binding(); soapBinding.Transport = GetTransport(binding); soapBinding.Style = SoapBindingStyle.Document; return(soapBinding); } return(null); }
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); }