private void AddMinimum( WSD.ServiceDescription wsdl, string contractName, OperationDescriptionCollection operations, ServiceEndpoint endpoint) { // Absolut minimum in order to provide a WSDL var portType = new WSD.PortType { Name = contractName }; wsdl.PortTypes.Add(portType); var address = new WSD.Soap12AddressBinding { Location = endpoint.Address.ToString() }; var port = new WSD.Port { Name = contractName }; port.Extensions.Add(address); var service = new WSD.Service { Name = wsdl.Name }; service.Ports.Add(port); wsdl.Services.Add(service); }
public Operation () { faults = new OperationFaultCollection (this); messages = new OperationMessageCollection (this); parameterOrder = null; portType = null; extensions = new ServiceDescriptionFormatExtensionCollection (this); }
/// <include file='doc\ServiceDescriptions.uex' path='docs/doc[@for="ServiceDescriptionCollection.GetPortType"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public PortType GetPortType(XmlQualifiedName name) { PortType portType = GetServiceDescription(name).PortTypes[name.Name]; if (portType == null) { throw ItemNotFound(name, "portType"); } return(portType); }
public Operation () { faults = new OperationFaultCollection (this); messages = new OperationMessageCollection (this); #if !NET_2_0 name = String.Empty; #endif parameterOrder = null; portType = null; }
Operation FindOperation(PortType portType, string name) { foreach (Operation oper in portType.Operations) { if (oper.Messages.Input.Name != null) { if (oper.Messages.Input.Name == name) return oper; } else if (oper.Name == name) return oper; } return null; }
internal WsdlContractConversionContext(ContractDescription contract, PortType wsdlPortType) { this.contract = contract; this.wsdlPortType = wsdlPortType; this.wsdlOperations = new Dictionary<OperationDescription, Operation>(); this.operationDescriptions = new Dictionary<Operation, OperationDescription>(); this.wsdlOperationMessages = new Dictionary<MessageDescription, OperationMessage>(); this.messageDescriptions = new Dictionary<OperationMessage, MessageDescription>(); this.wsdlOperationFaults = new Dictionary<FaultDescription, OperationFault>(); this.faultDescriptions = new Dictionary<OperationFault, FaultDescription>(); this.operationBindings = new Dictionary<Operation, Collection<OperationBinding>>(); }
public void TestAddPortType () { const string portTypeName = "testPortType"; PortType p = new PortType (); p.Name = portTypeName; ptc.Add (p); Assert.AreEqual (1, ptc.Count); Assert.AreEqual (p, ptc[portTypeName]); }
/// <include file='doc\ServiceDescriptions.uex' path='docs/doc[@for="ServiceDescriptionCollection.GetPortType"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public PortType GetPortType(XmlQualifiedName name) { ServiceDescription sd = GetServiceDescription(name); PortType portType = null; while (portType == null && sd != null) { portType = sd.PortTypes[name.Name]; sd = sd.Next; } if (portType == null) throw ItemNotFound(name, "message"); return portType; }
public Operation () { faults = new OperationFaultCollection (this); messages = new OperationMessageCollection (this); #if !NET_2_0 name = String.Empty; #endif parameterOrder = null; portType = null; #if NET_2_0 extensions = new ServiceDescriptionFormatExtensionCollection (this); #endif }
public Operation() { faults = new OperationFaultCollection(this); messages = new OperationMessageCollection(this); #if !NET_2_0 name = String.Empty; #endif parameterOrder = null; portType = null; #if NET_2_0 extensions = new ServiceDescriptionFormatExtensionCollection(this); #endif }
internal WsdlContractConversionContext(ContractDescription contract, WsdlNS.PortType wsdlPortType) { _contract = contract; _wsdlPortType = wsdlPortType; _wsdlOperations = new Dictionary <OperationDescription, WsdlNS.Operation>(); _operationDescriptions = new Dictionary <WsdlNS.Operation, OperationDescription>(); _wsdlOperationMessages = new Dictionary <MessageDescription, WsdlNS.OperationMessage>(); _messageDescriptions = new Dictionary <WsdlNS.OperationMessage, MessageDescription>(); _wsdlOperationFaults = new Dictionary <FaultDescription, WsdlNS.OperationFault>(); _faultDescriptions = new Dictionary <WsdlNS.OperationFault, FaultDescription>(); _operationBindings = new Dictionary <WsdlNS.Operation, Collection <WsdlNS.OperationBinding> >(); }
ServiceEndpointCollection ImportWsdlPortType(XmlQualifiedName portTypeQName, WsdlImporter importer) { foreach (WsdlNS.ServiceDescription wsdl in importer.WsdlDocuments) { if (wsdl.TargetNamespace == portTypeQName.Namespace) { WsdlNS.PortType wsdlPortType = wsdl.PortTypes[portTypeQName.Name]; if (wsdlPortType != null) { ServiceEndpointCollection endpoints = importer.ImportEndpoints(wsdlPortType); return(endpoints); } } } return(new ServiceEndpointCollection()); }
public PortType GetPortType(XmlQualifiedName name) { ServiceDescription serviceDescription = this.GetServiceDescription(name); PortType type = null; while ((type == null) && (serviceDescription != null)) { type = serviceDescription.PortTypes[name.Name]; serviceDescription = serviceDescription.Next; } if (type == null) { throw this.ItemNotFound(name, "message"); } return(type); }
public override void Check(ConformanceCheckContext ctx, PortType value) { ArrayList names = new ArrayList(); foreach (Operation o in value.Operations) { if (names.Contains(o.Name)) { ctx.ReportRuleViolation(value, BasicProfileRules.R2304); } else { names.Add(o.Name); } } }
Message FindMessage(ConformanceCheckContext ctx, MessageBinding mb) { PortType pt = ctx.Services.GetPortType(mb.OperationBinding.Binding.Type); foreach (Operation op in pt.Operations) { if (op.IsBoundBy(mb.OperationBinding)) { OperationMessage om; if (mb is InputBinding) { om = op.Messages.Input; } else if (mb is OutputBinding) { om = op.Messages.Output; } else if (mb is FaultBinding) { om = op.Faults [mb.Name]; } else { return(null); } if (om != null) { return(ctx.Services.GetMessage(om.Message)); } else { return(null); } } } return(null); }
public void Remove(PortType portType) { base.List.Remove(portType); }
public int Add(PortType portType) { return(base.List.Add(portType)); }
public int IndexOf(PortType portType) { return(base.List.IndexOf(portType)); }
internal static bool IsSoapBinding(PortType portType, ServiceDescription servDesc) { if (portType.ServiceDescription.Bindings != null && portType.ServiceDescription.Bindings.Count > 0) { foreach (Binding binding in portType.ServiceDescription.Bindings) { // Make sure this is the right binding if (binding.Type.Name == portType.Name) { // If this is the soap12 binding set the style and break; if (binding.Extensions.Find(typeof(Soap12Binding)) != null || binding.Extensions.Find(typeof(SoapBinding)) != null) { return true; } } } } return false; }
internal bool GenerateCode(CodeNamespace codeNamespace, ImportContext importContext, Hashtable exportContext) { bindingCount = 0; anyPorts = false; this.codeNamespace = codeNamespace; Hashtable supportedBindings = new Hashtable(); Hashtable unsupportedBindings = new Hashtable(); // look for ports with bindings foreach (ServiceDescription serviceDescription in ServiceDescriptions) { foreach (Service service in serviceDescription.Services) { foreach (Port port in service.Ports) { Binding binding = ServiceDescriptions.GetBinding(port.Binding); if (supportedBindings.Contains(binding)) { continue; } PortType portType = ServiceDescriptions.GetPortType(binding.Type); MoveToBinding(service, port, binding, portType); if (IsBindingSupported()) { bindingCount++; anyPorts = true; supportedBindings.Add(binding, binding); } else if (binding != null) { unsupportedBindings[binding] = binding; } } } } // no ports, look for bindings if (bindingCount == 0) { foreach (ServiceDescription serviceDescription in ServiceDescriptions) { foreach (Binding binding in serviceDescription.Bindings) { if (unsupportedBindings.Contains(binding)) { continue; } PortType portType = ServiceDescriptions.GetPortType(binding.Type); MoveToBinding(binding, portType); if (IsBindingSupported()) { bindingCount++; } } } } // give up if no bindings if (bindingCount == 0) { // if we generated comments return true so that the comments get written return(codeNamespace.Comments.Count > 0); } this.importContext = importContext; this.exportContext = exportContext; BeginNamespace(); supportedBindings.Clear(); foreach (ServiceDescription serviceDescription in ServiceDescriptions) { if (anyPorts) { foreach (Service service in serviceDescription.Services) { foreach (Port port in service.Ports) { Binding binding = ServiceDescriptions.GetBinding(port.Binding); PortType portType = ServiceDescriptions.GetPortType(binding.Type); MoveToBinding(service, port, binding, portType); if (IsBindingSupported() && !supportedBindings.Contains(binding)) { GenerateClassForBinding(); supportedBindings.Add(binding, binding); } } } } else { foreach (Binding binding in serviceDescription.Bindings) { PortType portType = ServiceDescriptions.GetPortType(binding.Type); MoveToBinding(binding, portType); if (IsBindingSupported()) { GenerateClassForBinding(); } } } } EndNamespace(); return(true); }
/// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="PortTypeCollection.IndexOf"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public int IndexOf(PortType portType) { return List.IndexOf(portType); }
internal OperationCollection(PortType portType) : base(portType) { }
public void ConstructorTest() { const string Url = "http://microsoft.com"; const string OperationName = "TestOperationName"; const string InputMessageName = "TestMessageInputName"; const string OutputMessageName = "TestMessageOutputName"; const string InputMessagePartName = "TestMessageInputPartName"; const string OutputMessagePartName = "TestMessageOutputPartName"; const string XmlSchemaName = "TestXmlSchemaName"; const string XmlSchemaTypeName = "TestXmlSchemaTypeName"; var webRequest = Mock.Create<HttpWebRequest>(); var response = Mock.Create<WebResponse>(); var stream = Mock.Create<Stream>(); var serviceDescription = Mock.Create<ServiceDescription>(); var operation = new Operation { Name = OperationName }; var portType = new PortType { Name = "TestHttpPost" }; var types = new Types(); var xmlSchema = new XmlSchema(); var item = new XmlSchemaElement(); var complexType = new XmlSchemaComplexType(); var sequence = new XmlSchemaSequence(); var xmlSchemaType = new XmlQualifiedName(XmlSchemaTypeName); var childElement = new XmlSchemaElement { Name = XmlSchemaName, SchemaTypeName = xmlSchemaType }; Mock.Arrange(() => WebRequest.Create(Arg.IsAny<Uri>())).Returns(webRequest); Mock.Arrange(() => webRequest.GetResponse()).Returns(response); Mock.Arrange(() => response.GetResponseStream()).Returns(stream); Mock.Arrange(() => ServiceDescription.Read(Arg.IsAny<Stream>())).Returns(serviceDescription); Mock.Arrange(() => serviceDescription.PortTypes).ReturnsCollection(new List<PortType> { portType }); Mock.Arrange(() => portType.Operations).ReturnsCollection(new List<Operation> { operation }); Mock.Arrange(() => operation.Messages.Input.Message.Name).Returns(InputMessageName); Mock.Arrange(() => operation.Messages.Output.Message.Name).Returns(OutputMessageName); Mock.Arrange(() => serviceDescription.Messages[InputMessageName].Parts[0].Element.Name).Returns(InputMessagePartName); Mock.Arrange(() => serviceDescription.Messages[OutputMessageName].Parts[0].Element.Name).Returns(OutputMessagePartName); Mock.Arrange(() => serviceDescription.Types).Returns(types); Mock.Arrange(() => types.Schemas[0]).Returns(xmlSchema); Mock.Arrange(() => xmlSchema.Items).Returns(new XmlSchemaObjectCollection { item }); Mock.Arrange(() => item.Name).Returns(OutputMessagePartName); Mock.Arrange(() => item.SchemaType).Returns(complexType); Mock.Arrange(() => complexType.Particle).Returns(sequence); Mock.Arrange(() => sequence.Items).Returns(new XmlSchemaObjectCollection { childElement }); WebServiceInfo.OpenWsdl(Url); var instance = WebServiceInfo.OpenWsdl(Url); Assert.AreEqual(XmlSchemaTypeName, instance.WebMethods.First().InputParameters.First().Type); }
public ContractDescription ImportContract (PortType wsdlPortType) { foreach (IWsdlImportExtension extension in wsdl_extensions) { extension.BeforeImport (wsdl_documents, xmlschemas, policies); } ContractDescription cd = new ContractDescription (wsdlPortType.Name, wsdlPortType.ServiceDescription.TargetNamespace); foreach (Operation op in wsdlPortType.Operations) { OperationDescription op_descr = new OperationDescription (op.Name, cd); foreach (OperationMessage opmsg in op.Messages) { /* OperationMessageCollection */ MessageDescription msg_descr; MessageDirection dir = MessageDirection.Input; string action = ""; if (opmsg.GetType () == typeof (OperationInput)) dir = MessageDirection.Input; else if (opmsg.GetType () == typeof (OperationOutput)) dir = MessageDirection.Output; /* FIXME: OperationFault--> OperationDescription.Faults ? */ if (opmsg.ExtensibleAttributes != null) { for (int i = 0; i < opmsg.ExtensibleAttributes.Length; i++) { if (opmsg.ExtensibleAttributes [i].LocalName == "Action" && opmsg.ExtensibleAttributes [i].NamespaceURI == "http://www.w3.org/2006/05/addressing/wsdl") /* addressing:Action */ action = opmsg.ExtensibleAttributes [i].Value; /* FIXME: other attributes ? */ } } msg_descr = new MessageDescription (action, dir); /* FIXME: Headers ? */ op_descr.Messages.Add (msg_descr); } cd.Operations.Add (op_descr); } WsdlContractConversionContext context = new WsdlContractConversionContext (cd, wsdlPortType); foreach (IWsdlImportExtension extension in wsdl_extensions) extension.ImportContract (this, context); return cd; }
internal void SetParent (PortType portType) { this.portType = portType; }
protected override bool CanImportOperation (PortType portType, Operation op) { // FIXME: implement return true; }
protected override bool CanImportOperation (PortType portType, Operation op) { foreach (OperationMessage om in op.Messages) { var msg = FindMessage (om); if (msg == null) return false; foreach (MessagePart part in msg.Parts) { if (part.Name == "parameters" && !part.Element.IsEmpty) { var xe = schema_set_in_use.GlobalElements [part.Element] as XmlSchemaElement; if (xe == null || !dc_importer.CanImport (schema_set_in_use, xe)) return false; } else return false; } } return true; }
protected abstract bool CanImportOperation (PortType portType, Operation op);
void ClasifySchemas(ArrayList importInfo) { // I don't like this, but I could not find any other way of clasifying // schemas between encoded and literal. xmlSchemas = new XmlSchemas(); soapSchemas = new XmlSchemas(); foreach (ImportInfo info in importInfo) { foreach (Service service in info.ServiceDescription.Services) { foreach (Port port in service.Ports) { this.iinfo = info; this.port = port; binding = ServiceDescriptions.GetBinding(port.Binding); if (binding == null) { continue; } portType = ServiceDescriptions.GetPortType(binding.Type); if (portType == null) { continue; } foreach (OperationBinding oper in binding.Operations) { operationBinding = oper; operation = FindPortOperation(); if (operation == null) { continue; } foreach (OperationMessage omsg in operation.Messages) { Message msg = ServiceDescriptions.GetMessage(omsg.Message); if (msg == null) { continue; } if (omsg is OperationInput) { inputMessage = msg; } else { outputMessage = msg; } } if (GetMessageEncoding(oper.Input) == SoapBindingUse.Encoded) { AddMessageSchema(soapSchemas, oper.Input, inputMessage); } else { AddMessageSchema(xmlSchemas, oper.Input, inputMessage); } if (oper.Output != null) { if (GetMessageEncoding(oper.Output) == SoapBindingUse.Encoded) { AddMessageSchema(soapSchemas, oper.Output, outputMessage); } else { AddMessageSchema(xmlSchemas, oper.Output, outputMessage); } } } } } } XmlSchemas defaultList = xmlSchemas; if (xmlSchemas.Count == 0 && soapSchemas.Count > 0) { defaultList = soapSchemas; } // Schemas not referenced by any message foreach (XmlSchema sc in Schemas) { if (!soapSchemas.Contains(sc) && !xmlSchemas.Contains(sc)) { if (ImportsEncodedNamespace(sc)) { soapSchemas.Add(sc); } else { defaultList.Add(sc); } } } }
public ServiceEndpointCollection ImportEndpoints ( PortType portType) { throw new NotImplementedException (); }
/// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="PortTypeCollection.Add"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public int Add(PortType portType) { return List.Add(portType); }
/// <summary> /// Parses the action attribute based on rules of Web Services Addressing 1.0 - WSDL Binding specification /// </summary> /// <param name="portType">A Web Service port type collection.</param> /// <param name="operation">A specific port type operation.</param> /// <param name="inAction">A string used to return the action uri.</param> /// <param name="outAction">A string used to return the out action uri.</param> /// <remarks> /// Action rules: /// If portType/operation/Input or output has addressing:Action attribute use it /// else If soap/binding/operation has a soap12:operation element containing a soapAction atribute use it /// else if portType/operation/input has a name attribute - Action = target namespace/port_type_name/input|output name /// else Action = target namespace/port_type_name/message_type_name + Request or Response or Solicit ///</remarks> private void GetAction(PortType portType, Operation operation, string targetNamespace, ref string inAction, ref string outAction) { // If portType/operation/Input or output has addressing:Action attribute use it if (operation.Messages.Input != null && operation.Messages.Input.ExtensibleAttributes != null) { foreach (XmlAttribute attribute in operation.Messages.Input.ExtensibleAttributes) if (attribute.LocalName == "Action" && (attribute.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/08/addressing" || attribute.NamespaceURI == "http://www.w3.org/2006/05/addressing/wsdl")) { inAction = attribute.Value; break; } } if (operation.Messages.Output != null && operation.Messages.Output.ExtensibleAttributes != null) { foreach (XmlAttribute attribute in operation.Messages.Output.ExtensibleAttributes) if (attribute.LocalName == "Action" && (attribute.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/08/addressing" || attribute.NamespaceURI == "http://www.w3.org/2006/05/addressing/wsdl")) { outAction = attribute.Value; break; } } // If in or out action is null then: // If soap/binding/operation has a soap12:operation element containing an Action attribute use it string soapAction = GetSoapAction(portType, operation.Name); inAction = (inAction == null && soapAction != null) ? soapAction : inAction; outAction = (outAction == null && soapAction != null) ? soapAction : outAction; if(!targetNamespace.EndsWith("/")) targetNamespace += "/"; // If in or out action is null then: // if portType/operation/input has a name attribute - Action = target namespace/port type name/input|output name if (inAction == null) { if (operation.Messages.Input != null && operation.Messages.Input.Name != null) inAction = targetNamespace + operation.PortType.Name + "/" + operation.Messages.Input.Name; } if (outAction == null) { if (operation.Messages.Output != null && operation.Messages.Output.Name != null) outAction = targetNamespace + operation.PortType.Name + "/" + operation.Messages.Output.Name; } // If in or out action is null then: // Action = target namespace/port type name/operation name + Request or Response or Solicit if (inAction == null && operation.Messages.Input != null && operation.Messages.Input.Message != null) { int index = operation.Messages.Input.Message.Name.IndexOf(":"); string inMessagetypeName = index == -1 ? operation.Messages.Input.Message.Name : operation.Messages.Input.Message.Name.Substring(index); inAction = targetNamespace + operation.PortType.Name + "/" + operation.Name; // + "Request"; } if (outAction == null && operation.Messages.Output != null && operation.Messages.Output.Message != null) { int index = operation.Messages.Output.Message.Name.IndexOf(":"); string outMessagetypeName = index == -1 ? operation.Messages.Output.Message.Name : operation.Messages.Output.Message.Name.Substring(index); outAction = targetNamespace + operation.PortType.Name + "/" + operation.Name + "Response"; } }
/// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="PortTypeCollection.Remove"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Remove(PortType portType) { List.Remove(portType); }
/// <summary> /// Helper method used to parse a soap bindings element looking for an operation /// with an Action property that defines the soapAction. /// </summary> /// <param name="portType">Service port type collection.</param> /// <returns>Soap action if found.</returns> private string GetSoapAction(PortType portType, string operationName) { string soapAction = null; Binding soapBinding = null; if (portType.ServiceDescription.Bindings != null) { foreach (Binding binding in portType.ServiceDescription.Bindings) { // If this is the soap12 binding break; if (binding.Extensions.Find(typeof(Soap12Binding)) != null) { if (binding.Type.Name == portType.Name) { soapBinding = binding; break; } } } if (soapBinding != null) { foreach (OperationBinding operationBinding in soapBinding.Operations) if (operationBinding.Name == operationName) { Soap12OperationBinding soapActionBinding = (Soap12OperationBinding)operationBinding.Extensions.Find(typeof(Soap12OperationBinding)); if (soapActionBinding != null) { soapAction = soapActionBinding.SoapAction; return soapAction; } } } } return null; }
bool ImportBindingContent(ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo) { serviceDescription = desc; // Look for an unused name int n = 0; string name = binfo.Name; bool found; do { found = false; foreach (Binding bi in desc.Bindings) { if (bi.Name == name) { found = true; n++; name = binfo.Name + n; break; } } }while (found); // Create the binding binding = new Binding(); binding.Name = name; binding.Type = new XmlQualifiedName(binding.Name, binfo.Namespace); #if NET_2_0 if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.EmitConformanceClaims) { XmlDocument doc = new XmlDocument(); XmlElement docElement = doc.CreateElement("wsdl", "documentation", "http://schemas.xmlsoap.org/wsdl/"); XmlElement claimsElement = doc.CreateElement("wsi", "Claim", "http://ws-i.org/schemas/conformanceClaim/"); claimsElement.Attributes.Append(doc.CreateAttribute("conformsTo")).Value = "http://ws-i.org/profiles/basic/1.1"; docElement.AppendChild(claimsElement); binding.DocumentationElement = docElement; } #endif portType = new PortType(); portType.Name = binding.Name; BeginClass(); foreach (SoapExtensionReflector reflector in extensionReflectors) { reflector.ReflectionContext = this; reflector.ReflectDescription(); } foreach (MethodStubInfo method in typeInfo.Methods) { methodStubInfo = method; string metBinding = ReflectMethodBinding(); if (typeInfo.GetBinding(metBinding) != binfo) { continue; } operation = new Operation(); operation.Name = method.OperationName; operation.Documentation = method.MethodAttribute.Description; // FIXME: SOAP 1.1 and SOAP 1.2 should share // the same message definitions. inputMessage = new Message(); inputMessage.Name = method.Name + ProtocolName + "In"; ServiceDescription.Messages.Add(inputMessage); outputMessage = new Message(); outputMessage.Name = method.Name + ProtocolName + "Out"; ServiceDescription.Messages.Add(outputMessage); OperationInput inOp = new OperationInput(); if (method.Name != method.OperationName) { inOp.Name = method.Name; } Operation.Messages.Add(inOp); inOp.Message = new XmlQualifiedName(inputMessage.Name, ServiceDescription.TargetNamespace); OperationOutput outOp = new OperationOutput(); if (method.Name != method.OperationName) { outOp.Name = method.Name; } Operation.Messages.Add(outOp); outOp.Message = new XmlQualifiedName(outputMessage.Name, ServiceDescription.TargetNamespace); portType.Operations.Add(operation); ImportOperationBinding(); if (!ReflectMethod()) { #if NET_2_0 // (It is somewhat hacky) If we don't // add input/output Messages, update // portType/input/@message and // porttype/output/@message. Message dupIn = Parent.MappedMessagesIn [method.MethodInfo]; ServiceDescription.Messages.Remove(inputMessage); inOp.Message = new XmlQualifiedName(dupIn.Name, ServiceDescription.TargetNamespace); Message dupOut = Parent.MappedMessagesOut [method.MethodInfo]; ServiceDescription.Messages.Remove(outputMessage); outOp.Message = new XmlQualifiedName(dupOut.Name, ServiceDescription.TargetNamespace); #endif } foreach (SoapExtensionReflector reflector in extensionReflectors) { reflector.ReflectionContext = this; reflector.ReflectMethod(); } } EndClass(); if (portType.Operations.Count > 0) { desc.Bindings.Add(binding); desc.PortTypes.Add(portType); return(true); } else { return(false); } }
public virtual void Check(ConformanceCheckContext ctx, PortType value) { }
void ReflectBinding(ReflectedBinding reflectedBinding) { string bindingName = reflectedBinding.bindingAttr.Name; string bindingNamespace = reflectedBinding.bindingAttr.Namespace; if (bindingName.Length == 0) { bindingName = Service.Name + ProtocolName; } if (bindingNamespace.Length == 0) { bindingNamespace = ServiceDescription.TargetNamespace; } if (reflectedBinding.bindingAttr.Location.Length > 0) { // If a URL is specified for the WSDL, file, then we just import the // binding from there instead of generating it in this WSDL file. portType = null; binding = null; } else { bindingServiceDescription = GetServiceDescription(bindingNamespace); CodeIdentifiers bindingNames = new CodeIdentifiers(); foreach (Binding b in bindingServiceDescription.Bindings) { bindingNames.AddReserved(b.Name); } bindingName = bindingNames.AddUnique(bindingName, binding); portType = new PortType(); binding = new Binding(); portType.Name = bindingName; binding.Name = bindingName; binding.Type = new XmlQualifiedName(portType.Name, bindingNamespace); bindingServiceDescription.Bindings.Add(binding); bindingServiceDescription.PortTypes.Add(portType); } if (portNames == null) { portNames = new CodeIdentifiers(); foreach (Port p in Service.Ports) { portNames.AddReserved(p.Name); } } port = new Port(); port.Binding = new XmlQualifiedName(bindingName, bindingNamespace); port.Name = portNames.AddUnique(bindingName, port); Service.Ports.Add(port); BeginClass(); foreach (LogicalMethodInfo method in reflectedBinding.methodList) { MoveToMethod(method); operation = new Operation(); operation.Name = method.Name; operation.Documentation = methodAttr.Description; operationBinding = new OperationBinding(); operationBinding.Name = operation.Name; inputMessage = null; outputMessage = null; headerMessages = null; if (ReflectMethod()) { if (inputMessage != null) { bindingServiceDescription.Messages.Add(inputMessage); } if (outputMessage != null) { bindingServiceDescription.Messages.Add(outputMessage); } if (headerMessages != null) { foreach (Message headerMessage in headerMessages) { bindingServiceDescription.Messages.Add(headerMessage); } } binding.Operations.Add(operationBinding); portType.Operations.Add(operation); } } EndClass(); }
internal void SetParent(PortType portType) { this.portType = portType; }
void MoveToBinding(Binding binding, PortType portType) { MoveToBinding(null, null, binding, portType); }
public static System.Web.Services.Description.PortType Senasaport(System.Web.Services.Description.PortType Puertito) { MessageBox.Show(Puertito.Name); return(Puertito); }
public bool Contains(PortType portType) { return(base.List.Contains(portType)); }
public void Insert(int index, PortType portType) { base.List.Insert(index, portType); }
void MoveToBinding(Service service, Port port, Binding binding, PortType portType) { this.service = service; this.port = port; this.portType = portType; this.binding = binding; this.encodedBinding = false; }
void ImportPortBinding(bool multipleBindings) { if (port != null) { if (multipleBindings) { className = binding.Name; } else { className = service.Name; } } else { className = binding.Name; } className = classNames.AddUnique(CodeIdentifier.MakeValid(className), port); className = className.Replace("_x0020_", ""); // MS.NET seems to do this try { portType = ServiceDescriptions.GetPortType(binding.Type); if (portType == null) { throw new Exception("Port type not found: " + binding.Type); } CodeTypeDeclaration codeClass = BeginClass(); codeTypeDeclaration = codeClass; AddCodeType(codeClass, port != null ? port.Documentation : null); codeClass.Attributes = MemberAttributes.Public; if (service != null && service.Documentation != null && service.Documentation != "") { AddComments(codeClass, service.Documentation); } if (Style == ServiceDescriptionImportStyle.Client) { CodeAttributeDeclaration att = new CodeAttributeDeclaration("System.Diagnostics.DebuggerStepThroughAttribute"); AddCustomAttribute(codeClass, att, true); att = new CodeAttributeDeclaration("System.ComponentModel.DesignerCategoryAttribute"); att.Arguments.Add(GetArg("code")); AddCustomAttribute(codeClass, att, true); } else { codeClass.TypeAttributes = System.Reflection.TypeAttributes.Abstract | System.Reflection.TypeAttributes.Public; } if (binding.Operations.Count == 0) { warnings |= ServiceDescriptionImportWarnings.NoMethodsGenerated; return; } foreach (OperationBinding oper in binding.Operations) { operationBinding = oper; operation = FindPortOperation(); if (operation == null) { throw new Exception("Operation " + operationBinding.Name + " not found in portType " + PortType.Name); } inputMessage = null; outputMessage = null; foreach (OperationMessage omsg in operation.Messages) { Message msg = ServiceDescriptions.GetMessage(omsg.Message); if (msg == null) { throw new Exception("Message not found: " + omsg.Message); } if (omsg is OperationInput) { inputMessage = msg; } else { outputMessage = msg; } } CodeMemberMethod method = GenerateMethod(); if (method != null) { methodName = method.Name; if (operation.Documentation != null && operation.Documentation != "") { AddComments(method, operation.Documentation); } #if NET_2_0 if (Style == ServiceDescriptionImportStyle.Client) { AddAsyncMembers(method.Name, method); } #endif } } #if NET_2_0 if (Style == ServiceDescriptionImportStyle.Client) { AddAsyncTypes(); } #endif EndClass(); } catch (InvalidOperationException ex) { warnings |= ServiceDescriptionImportWarnings.NoCodeGenerated; UnsupportedBindingWarning(ex.Message); } }
public override void Check(ConformanceCheckContext ctx, Binding value) { SoapBinding sb = (SoapBinding)value.Extensions.Find(typeof(SoapBinding)); if (sb == null) { return; } if (sb.Transport == null || sb.Transport == "") { ctx.ReportRuleViolation(value, BasicProfileRules.R2701); return; } if (sb.Transport != "http://schemas.xmlsoap.org/soap/http") { ctx.ReportRuleViolation(value, BasicProfileRules.R2702); } LiteralType type = GetLiteralBindingType(value); if (type == LiteralType.NotLiteral) { ctx.ReportRuleViolation(value, BasicProfileRules.R2706); } else if (type == LiteralType.Inconsistent) { ctx.ReportRuleViolation(value, BasicProfileRules.R2705); } // Collect all parts referenced from this type Hashtable parts = new Hashtable(); PortType port = ctx.Services.GetPortType(value.Type); foreach (Operation op in port.Operations) { foreach (OperationMessage om in op.Messages) { Message msg = ctx.Services.GetMessage(om.Message); foreach (MessagePart part in msg.Parts) { parts [part] = part; // do not use Add() - there could be the same MessagePart instance. } } } foreach (OperationBinding ob in value.Operations) { if (ob.Input != null) { CheckMessageBinding(ctx, parts, ob.Input); } if (ob.Output != null) { CheckMessageBinding(ctx, parts, ob.Output); } foreach (FaultBinding fb in ob.Faults) { CheckMessageBinding(ctx, parts, fb); } } if (parts.Count > 0) { ctx.ReportRuleViolation(value, BasicProfileRules.R2209); } // check existence of corresponding operation in portType for each binding operation if (CheckCorrespondingOperationsForBinding(ctx, value, port)) { ctx.ReportRuleViolation(value, BasicProfileRules.R2718); } // check duplicate operation signature. ArrayList sigs = new ArrayList(); foreach (OperationBinding ob in value.Operations) { if (sigs.Contains(ob.Name)) { ctx.ReportRuleViolation(value, BasicProfileRules.R2710); } sigs.Add(ob.Name); } // check namespace declarations. switch (type) { case LiteralType.Document: case LiteralType.Rpc: CheckSoapBindingExtensions(ctx, value, type); break; } }
internal void SetParent(PortType parent) { this.parent = parent; }
bool CheckCorrespondingOperationsForBinding(ConformanceCheckContext ctx, Binding value, PortType port) { if (value.Operations.Count != port.Operations.Count) { return(true); } foreach (OperationBinding b in value.Operations) { Operation op = port.Operations.Find(b.Name); if (op == null) { return(true); } bool msg, bind; // input msg = op.Messages.Input != null; bind = b.Input != null; if (msg != bind) { return(true); } // output msg = op.Messages.Output != null; bind = b.Output != null; if (msg != bind) { return(true); } // faults foreach (FaultBinding fb in b.Faults) { if (op.Messages.Find(fb.Name) == null) { return(true); } } } return(false); }
/// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="PortTypeCollection.Insert"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Insert(int index, PortType portType) { List.Insert(index, portType); }
List<IWsdlExportExtension> ExportContractInternal (ContractDescription contract) { QName qname = new QName (contract.Name, contract.Namespace); if (ExportedContracts.ContainsKey (qname)) throw new ArgumentException (String.Format ( "A ContractDescription with Namespace : {0} and Name : {1} has already been exported.", contract.Namespace, contract.Name)); WSServiceDescription sd = GetServiceDescription (contract.Namespace); List<IWsdlExportExtension> extensions = new List<IWsdlExportExtension> (); foreach (IWsdlExportExtension extn in contract.Behaviors.FindAll<IWsdlExportExtension> ()) extensions.Add (extn); XmlDocument xdoc = new XmlDocument (); PortType ws_port = new PortType (); ws_port.Name = contract.Name; foreach (OperationDescription sm_op in contract.Operations) { Operation ws_op = new Operation (); ws_op.Name = sm_op.Name; foreach (MessageDescription sm_md in sm_op.Messages) { //OperationMessage OperationMessage ws_opmsg; WSMessage ws_msg = new WSMessage (); MessagePart ws_msgpart; if (sm_md.Direction == MessageDirection.Input) { ws_opmsg = new OperationInput (); ws_msg.Name = String.Concat (ws_port.Name, "_", ws_op.Name, "_", "InputMessage"); ws_msgpart = ExportMessageBodyDescription (sm_md.Body, ws_op.Name, sd.TargetNamespace); } else { ws_opmsg = new OperationOutput (); ws_msg.Name = String.Concat (ws_port.Name, "_", ws_op.Name, "_", "OutputMessage"); ws_msgpart = ExportMessageBodyDescription (sm_md.Body, ws_op.Name + "Response", sd.TargetNamespace); } ws_msg.Parts.Add (ws_msgpart); /* FIXME: Faults */ //Action XmlAttribute attr = xdoc.CreateAttribute ("wsaw", "Action", "http://www.w3.org/2006/05/addressing/wsdl"); attr.Value = sm_md.Action; ws_opmsg.ExtensibleAttributes = new XmlAttribute [] { attr }; //FIXME: Set .Input & .Output ws_opmsg.Message = new QName (ws_msg.Name, sd.TargetNamespace); ws_op.Messages.Add (ws_opmsg); sd.Messages.Add (ws_msg); } ws_port.Operations.Add (ws_op); foreach (IWsdlExportExtension extn in sm_op.Behaviors.FindAll<IWsdlExportExtension> ()) extensions.Add (extn); } //Add Imports for <types XmlSchema xs_import = new XmlSchema (); xs_import.TargetNamespace = String.Concat ( contract.Namespace, contract.Namespace.EndsWith ("/") ? "" : "/", "Imports"); foreach (XmlSchema schema in GeneratedXmlSchemas.Schemas ()) { XmlSchemaImport imp = new XmlSchemaImport (); imp.Namespace = schema.TargetNamespace; xs_import.Includes.Add (imp); } sd.Types.Schemas.Add (xs_import); sd.PortTypes.Add (ws_port); ExportedContracts [qname] = contract; WsdlContractConversionContext context = new WsdlContractConversionContext (contract, ws_port); foreach (IWsdlExportExtension extn in extensions) extn.ExportContract (this, context); return extensions; }
/// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="PortTypeCollection.Contains"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public bool Contains(PortType portType) { return List.Contains(portType); }
private void ProcessWsdl() { string wsdlText; string portType; string bindingName; string address; string spnIdentity = null; string upnIdentity = null; string dnsIdentity = null; EndpointIdentity identity = null; string serializer = null; string contractNamespace = null; string bindingNamespace = null; propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Wsdl, out wsdlText); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Contract, out portType); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Binding, out bindingName); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Address, out address); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.SpnIdentity, out spnIdentity); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.UpnIdentity, out upnIdentity); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.DnsIdentity, out dnsIdentity); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Serializer, out serializer); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.BindingNamespace, out bindingNamespace); propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.ContractNamespace, out contractNamespace); if (string.IsNullOrEmpty(wsdlText)) { throw Fx.AssertAndThrow("Wsdl should not be null at this point"); } if (string.IsNullOrEmpty(portType) || string.IsNullOrEmpty(bindingName) || string.IsNullOrEmpty(address)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.ContractBindingAddressCannotBeNull))); } if (!string.IsNullOrEmpty(spnIdentity)) { if ((!string.IsNullOrEmpty(upnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity))) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity))); } identity = EndpointIdentity.CreateSpnIdentity(spnIdentity); } else if (!string.IsNullOrEmpty(upnIdentity)) { if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity))) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity))); } identity = EndpointIdentity.CreateUpnIdentity(upnIdentity); } else if (!string.IsNullOrEmpty(dnsIdentity)) { if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(upnIdentity))) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity))); } identity = EndpointIdentity.CreateDnsIdentity(dnsIdentity); } else { identity = null; } bool removeXmlSerializerImporter = false; if (!String.IsNullOrEmpty(serializer)) { if ("xml" != serializer && "datacontract" != serializer) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorectSerializer))); } if ("xml" == serializer) { useXmlSerializer = true; } else { removeXmlSerializerImporter = true; // specifying datacontract will explicitly remove the Xml importer } // if this parameter is not set we will simply use indigo defaults } TextReader reader = new StringReader(wsdlText); try { try { WsdlNS.ServiceDescription wsdl = WsdlNS.ServiceDescription.Read(reader); if (String.IsNullOrEmpty(contractNamespace)) { contractNamespace = wsdl.TargetNamespace; } if (String.IsNullOrEmpty(bindingNamespace)) { bindingNamespace = wsdl.TargetNamespace; } WsdlNS.ServiceDescriptionCollection wsdlDocs = new WsdlNS.ServiceDescriptionCollection(); wsdlDocs.Add(wsdl); XmlSchemaSet schemas = new XmlSchemaSet(); foreach (XmlSchema schema in wsdl.Types.Schemas) { schemas.Add(schema); } MetadataSet mds = new MetadataSet(WsdlImporter.CreateMetadataDocuments(wsdlDocs, schemas, null)); WsdlImporter importer; if (useXmlSerializer) { importer = CreateXmlSerializerImporter(mds); } else { if (removeXmlSerializerImporter) { importer = CreateDataContractSerializerImporter(mds); } else { importer = new WsdlImporter(mds); } } XmlQualifiedName contractQname = new XmlQualifiedName(portType, contractNamespace); XmlQualifiedName bindingQname = new XmlQualifiedName(bindingName, bindingNamespace); WsdlNS.PortType wsdlPortType = wsdlDocs.GetPortType(contractQname); contractDescription = importer.ImportContract(wsdlPortType); WsdlNS.Binding wsdlBinding = wsdlDocs.GetBinding(bindingQname); Binding binding = importer.ImportBinding(wsdlBinding); EndpointAddress endpointAddress = new EndpointAddress(new Uri(address), identity, (AddressHeaderCollection)null); serviceEndpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress); ComPlusWsdlChannelBuilderTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationWsdlChannelBuilderLoaded, SR.TraceCodeComIntegrationWsdlChannelBuilderLoaded, bindingQname, contractQname, wsdl, contractDescription, binding, wsdl.Types.Schemas); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.FailedImportOfWsdl, e.Message))); } } finally { IDisposable disposee = reader; disposee.Dispose(); } }
/// <include file='doc\ServiceDescription.uex' path='docs/doc[@for="PortTypeCollection.CopyTo"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void CopyTo(PortType[] array, int index) { List.CopyTo(array, index); }
WsdlNS.PortType CreateWsdlPortType(ContractDescription contract) { XmlQualifiedName wsdlPortTypeQName = WsdlNamingHelper.GetPortTypeQName(contract); WsdlNS.ServiceDescription wsdl = GetOrCreateWsdl(wsdlPortTypeQName.Namespace); WsdlNS.PortType wsdlPortType = new WsdlNS.PortType(); wsdlPortType.Name = wsdlPortTypeQName.Name; if (wsdl.PortTypes[wsdlPortType.Name] != null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.DuplicateContractQNameNameOnExport, contract.Name, contract.Namespace))); NetSessionHelper.AddUsingSessionAttributeIfNeeded(wsdlPortType, contract); wsdl.PortTypes.Add(wsdlPortType); return wsdlPortType; }
public void InitializePortType() { portType = new PortType(); }
void ReflectBinding(ReflectedBinding reflectedBinding) { string bindingName = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name); string bindingNamespace = reflectedBinding.bindingAttr.Namespace; if (bindingName.Length == 0) { bindingName = Service.Name + ProtocolName; } if (bindingNamespace.Length == 0) { bindingNamespace = ServiceDescription.TargetNamespace; } WsiProfiles claims = WsiProfiles.None; if (reflectedBinding.bindingAttr.Location.Length > 0) { // If a URL is specified for the WSDL, file, then we just import the // binding from there instead of generating it in this WSDL file. portType = null; binding = null; } else { bindingServiceDescription = GetServiceDescription(bindingNamespace); CodeIdentifiers bindingNames = new CodeIdentifiers(); foreach (Binding b in bindingServiceDescription.Bindings) { bindingNames.AddReserved(b.Name); } bindingName = bindingNames.AddUnique(bindingName, binding); portType = new PortType(); binding = new Binding(); portType.Name = bindingName; binding.Name = bindingName; binding.Type = new XmlQualifiedName(portType.Name, bindingNamespace); claims = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo; if (reflectedBinding.bindingAttr.EmitConformanceClaims && claims != WsiProfiles.None) { ServiceDescription.AddConformanceClaims(binding.GetDocumentationElement(), claims); } bindingServiceDescription.Bindings.Add(binding); bindingServiceDescription.PortTypes.Add(portType); } if (portNames == null) { portNames = new CodeIdentifiers(); foreach (Port p in Service.Ports) { portNames.AddReserved(p.Name); } } port = new Port(); port.Binding = new XmlQualifiedName(bindingName, bindingNamespace); port.Name = portNames.AddUnique(bindingName, port); Service.Ports.Add(port); BeginClass(); if (reflectedBinding.methodList != null && reflectedBinding.methodList.Count > 0) { foreach (LogicalMethodInfo method in reflectedBinding.methodList) { MoveToMethod(method); operation = new Operation(); operation.Name = XmlConvert.EncodeLocalName(method.Name); if (methodAttr.Description != null && methodAttr.Description.Length > 0) { operation.Documentation = methodAttr.Description; } operationBinding = new OperationBinding(); operationBinding.Name = operation.Name; inputMessage = null; outputMessage = null; headerMessages = null; if (ReflectMethod()) { if (inputMessage != null) { bindingServiceDescription.Messages.Add(inputMessage); } if (outputMessage != null) { bindingServiceDescription.Messages.Add(outputMessage); } if (headerMessages != null) { foreach (Message headerMessage in headerMessages) { bindingServiceDescription.Messages.Add(headerMessage); } } binding.Operations.Add(operationBinding); portType.Operations.Add(operation); } } } if (binding != null && claims == WsiProfiles.BasicProfile1_1 && ProtocolName == "Soap") { BasicProfileViolationCollection warnings = new BasicProfileViolationCollection(); WebServicesInteroperability.AnalyzeBinding(binding, bindingServiceDescription, ServiceDescriptions, warnings); if (warnings.Count > 0) { throw new InvalidOperationException(Res.GetString(Res.WebWsiViolation, ServiceType.FullName, warnings.ToString())); } } EndClass(); }
bool ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo) { serviceDescription = desc; // Look for an unused name int n=0; string name = binfo.Name; bool found; do { found = false; foreach (Binding bi in desc.Bindings) if (bi.Name == name) { found = true; n++; name = binfo.Name+n; break; } } while (found); // Create the binding binding = new Binding (); binding.Name = name; binding.Type = new XmlQualifiedName (binding.Name, binfo.Namespace); if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.EmitConformanceClaims) { XmlDocument doc = new XmlDocument (); XmlElement docElement = doc.CreateElement ("wsdl", "documentation", "http://schemas.xmlsoap.org/wsdl/"); XmlElement claimsElement = doc.CreateElement ("wsi", "Claim", "http://ws-i.org/schemas/conformanceClaim/"); claimsElement.Attributes.Append (doc.CreateAttribute ("conformsTo")).Value = "http://ws-i.org/profiles/basic/1.1"; docElement.AppendChild (claimsElement); binding.DocumentationElement = docElement; } portType = new PortType (); portType.Name = binding.Name; BeginClass (); foreach (SoapExtensionReflector reflector in extensionReflectors) { reflector.ReflectionContext = this; reflector.ReflectDescription (); } foreach (MethodStubInfo method in typeInfo.Methods) { methodStubInfo = method; string metBinding = ReflectMethodBinding (); if (typeInfo.GetBinding (metBinding) != binfo) continue; operation = new Operation (); operation.Name = method.OperationName; operation.Documentation = method.MethodAttribute.Description; // FIXME: SOAP 1.1 and SOAP 1.2 should share // the same message definitions. inputMessage = new Message (); inputMessage.Name = method.Name + ProtocolName + "In"; ServiceDescription.Messages.Add (inputMessage); outputMessage = new Message (); outputMessage.Name = method.Name + ProtocolName + "Out"; ServiceDescription.Messages.Add (outputMessage); OperationInput inOp = new OperationInput (); if (method.Name != method.OperationName) inOp.Name = method.Name; Operation.Messages.Add (inOp); inOp.Message = new XmlQualifiedName (inputMessage.Name, ServiceDescription.TargetNamespace); OperationOutput outOp = new OperationOutput (); if (method.Name != method.OperationName) outOp.Name = method.Name; Operation.Messages.Add (outOp); outOp.Message = new XmlQualifiedName (outputMessage.Name, ServiceDescription.TargetNamespace); portType.Operations.Add (operation); ImportOperationBinding (); if (!ReflectMethod ()) { // (It is somewhat hacky) If we don't // add input/output Messages, update // portType/input/@message and // porttype/output/@message. Message dupIn = Parent.MappedMessagesIn [method.MethodInfo]; ServiceDescription.Messages.Remove (inputMessage); inOp.Message = new XmlQualifiedName (dupIn.Name, ServiceDescription.TargetNamespace); Message dupOut = Parent.MappedMessagesOut [method.MethodInfo]; ServiceDescription.Messages.Remove (outputMessage); outOp.Message = new XmlQualifiedName (dupOut.Name, ServiceDescription.TargetNamespace); } foreach (SoapExtensionReflector reflector in extensionReflectors) { reflector.ReflectionContext = this; reflector.ReflectMethod (); } } EndClass (); if (portType.Operations.Count > 0) { desc.Bindings.Add (binding); desc.PortTypes.Add (portType); return true; } else return false; }
internal static bool AnalyzeBinding(Binding binding, ServiceDescription description, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations) { bool flag = false; bool flag2 = false; SoapBinding binding2 = (SoapBinding)binding.Extensions.Find(typeof(SoapBinding)); if ((binding2 == null) || (binding2.GetType() != typeof(SoapBinding))) { return(false); } SoapBindingStyle style = (binding2.Style == SoapBindingStyle.Default) ? SoapBindingStyle.Document : binding2.Style; if (binding2.Transport.Length == 0) { violations.Add("R2701", System.Web.Services.Res.GetString("BindingMissingAttribute", new object[] { binding.Name, description.TargetNamespace, "transport" })); } else if (binding2.Transport != "http://schemas.xmlsoap.org/soap/http") { violations.Add("R2702", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "transport", binding2.Transport })); } PortType portType = descriptions.GetPortType(binding.Type); Hashtable hashtable = new Hashtable(); if (portType != null) { foreach (Operation operation in portType.Operations) { if (operation.Messages.Flow == OperationFlow.Notification) { violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowNotification", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace })); } if (operation.Messages.Flow == OperationFlow.SolicitResponse) { violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowSolicitResponse", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace })); } if (hashtable[operation.Name] != null) { violations.Add("R2304", System.Web.Services.Res.GetString("Operation", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace })); } else { OperationBinding binding3 = null; foreach (OperationBinding binding4 in binding.Operations) { if (operation.IsBoundBy(binding4)) { if (binding3 != null) { violations.Add("R2304", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding3.Name, binding3.Parent.Name, description.TargetNamespace })); } binding3 = binding4; } } if (binding3 == null) { violations.Add("R2718", System.Web.Services.Res.GetString("OperationMissingBinding", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace })); } else { hashtable.Add(operation.Name, operation); } } } } Hashtable wireSignatures = new Hashtable(); SoapBindingStyle style2 = SoapBindingStyle.Default; foreach (OperationBinding binding5 in binding.Operations) { SoapBindingStyle style3 = style; string name = binding5.Name; if (name != null) { if (hashtable[name] == null) { violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace })); } Operation operation2 = FindOperation(portType.Operations, binding5); SoapOperationBinding binding6 = (SoapOperationBinding)binding5.Extensions.Find(typeof(SoapOperationBinding)); if (binding6 != null) { if (style2 == SoapBindingStyle.Default) { style2 = binding6.Style; } flag |= style2 != binding6.Style; style3 = (binding6.Style != SoapBindingStyle.Default) ? binding6.Style : style; } if (binding5.Input != null) { SoapBodyBinding binding7 = FindSoapBodyBinding(true, binding5.Input.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace); if ((binding7 != null) && (binding7.Use != SoapBindingUse.Encoded)) { Message message = (operation2 == null) ? null : ((operation2.Messages.Input == null) ? null : descriptions.GetMessage(operation2.Messages.Input.Message)); if (style3 == SoapBindingStyle.Rpc) { CheckMessageParts(message, binding7.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations); } else { flag2 = flag2 || ((binding7.Parts != null) && (binding7.Parts.Length > 1)); int num = (binding7.Parts == null) ? 0 : binding7.Parts.Length; CheckMessageParts(message, binding7.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations); if (((num == 0) && (message != null)) && (message.Parts.Count > 1)) { violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace })); } } } } if (binding5.Output != null) { SoapBodyBinding binding8 = FindSoapBodyBinding(false, binding5.Output.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace); if ((binding8 != null) && (binding8.Use != SoapBindingUse.Encoded)) { Message message2 = (operation2 == null) ? null : ((operation2.Messages.Output == null) ? null : descriptions.GetMessage(operation2.Messages.Output.Message)); if (style3 == SoapBindingStyle.Rpc) { CheckMessageParts(message2, binding8.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, null, violations); } else { flag2 = flag2 || ((binding8.Parts != null) && (binding8.Parts.Length > 1)); int num2 = (binding8.Parts == null) ? 0 : binding8.Parts.Length; CheckMessageParts(message2, binding8.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, null, violations); if (((num2 == 0) && (message2 != null)) && (message2.Parts.Count > 1)) { violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace })); } } } } foreach (FaultBinding binding9 in binding5.Faults) { foreach (ServiceDescriptionFormatExtension extension in binding9.Extensions) { if (extension is SoapFaultBinding) { SoapFaultBinding item = (SoapFaultBinding)extension; if (item.Use == SoapBindingUse.Encoded) { violations.Add("R2706", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null)); } else { if ((item.Name == null) || (item.Name.Length == 0)) { violations.Add("R2721", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace })); } else if (item.Name != binding9.Name) { violations.Add("R2754", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace })); } if ((item.Namespace != null) && (item.Namespace.Length > 0)) { violations.Add((style3 == SoapBindingStyle.Document) ? "R2716" : "R2726", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null)); } } } } } if (hashtable[binding5.Name] == null) { violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace })); } } } if (flag2) { violations.Add("R2201", System.Web.Services.Res.GetString("BindingMultipleParts", new object[] { binding.Name, description.TargetNamespace, "parts" })); } if (flag) { violations.Add("R2705", System.Web.Services.Res.GetString("Binding", new object[] { binding.Name, description.TargetNamespace })); } return(true); }