Note that there are some explanatory texts on larger screens.

plurals
  1. POXmlSchemaProviderAttribute and xsd:import
    primarykey
    data
    text
    <p>We're using a custom class that uses XmlSchemaProviderAttribute in order to make it seem like a string. It is declared as follows:</p> <pre><code> [XmlSchemaProvider("GetSchema")] public sealed class CDataWrapper : IXmlSerializable { public static XmlQualifiedName GetSchema(XmlSchemaSet xs) { return XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).QualifiedName; } // implicit to/from string public static implicit operator string(CDataWrapper value) { return value == null ? null : value.Value; } public static implicit operator CDataWrapper(string value) { return value == null ? null : new CDataWrapper { Value = value }; } public System.Xml.Schema.XmlSchema GetSchema() { return null; } // "" =&gt; &lt;Node/&gt; // "Foo" =&gt; &lt;Node&gt;&lt;![CDATA[Foo]]&gt;&lt;/Node&gt; public void WriteXml(XmlWriter writer) { if (!string.IsNullOrEmpty(Value)) { writer.WriteCData(Value); } } // &lt;Node/&gt; =&gt; "" // &lt;Node&gt;&lt;/Node&gt; =&gt; "" // &lt;Node&gt;Foo&lt;/Node&gt; =&gt; "Foo" // &lt;Node&gt;&lt;![CDATA[Foo]]&gt;&lt;/Node&gt; =&gt; "Foo" public void ReadXml(XmlReader reader) { if (reader.IsEmptyElement) { Value = ""; } else { reader.Read(); switch (reader.NodeType) { case XmlNodeType.EndElement: Value = ""; // empty after all... break; case XmlNodeType.Text: case XmlNodeType.CDATA: Value = reader.ReadContentAsString(); break; default: throw new InvalidOperationException("Expected text or CData but was: "+ reader.NodeType); } } } // underlying value public string Value { get; set; } public override string ToString() { return Value; } } </code></pre> <p>The CDataWrapper class is taken <a href="https://stackoverflow.com/questions/1374062/using-cdata-with-wcf-rest-starter-kits">from this question</a>. We're using it since one of our clients (a FLEX client) cannot read leading\trailing spaces correctly. And we're making it seem like a string in the schema, in order not to break the contract with our other clients. This works nicely, usually, but one of our clients is unable to generate a proxy with the schema that WCF creates for the service that uses the above wrapper class. We've traced the reason to this line in our wsdl:</p> <pre><code>&lt;xsd:import schemaLocation="http://my.services.com/service/mex?xsd=xsd4" /&gt; </code></pre> <p>And its content is:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8" ?&gt; - &lt;xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="string" nillable="true" type="xs:string" /&gt; &lt;/xs:schema&gt; </code></pre> <p>The problem is that there is no namespace attribute on the xsd:import element above, and our client's proxy generator can't handle that well.</p> <p>In short, how can we add the namespace attribute to the generated wsdl?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload