Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF AddServiceReference causing custom tool error, not producing proxy
    text
    copied!<p>A problem with "Add Service Reference", and actually with SvcUtil over all its features. In order to reproduce you just need to add an OperationContract with argument or returning the following class :</p> <pre><code>[XmlSchemaProvider("MySchema")] public class MyStructure : IXmlSerializable { private XmlElement e; private static void Func(object o, ValidationEventArgs args) { } public static XmlQualifiedName MySchema(XmlSchemaSet xs) { //xs.XmlResolver = new XmlUrlResolver(); XmlSchema s = XmlSchema.Read(new XmlTextReader(new StringReader("&lt;?xml version=\"1.0\"?&gt;&lt;xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"&gt;&lt;xs:complexType name=\"MyStructure\"&gt;&lt;xs:sequence&gt;&lt;xs:any /&gt;&lt;/xs:sequence&gt;&lt;/xs:complexType&gt;&lt;/xs:schema&gt;")), null); xs.Add(s); return new XmlQualifiedName("MyStructure"); } #region IXmlSerializable Members public System.Xml.Schema.XmlSchema GetSchema() { throw new NotImplementedException(); } public void ReadXml(XmlReader reader) { XmlDocument doc = new XmlDocument(); e = (XmlElement)doc.ReadNode(reader); } public void WriteXml(XmlWriter writer) { e.WriteTo(writer); } #endregion } </code></pre> <p>The result is that when you use AddWebReference or AddSerivceReference without a reference to the class library containing the MyStructure type, everything will be fine ad you will get an xmlElement representation at the auto created proxy.</p> <p>However, when you have a reference you will get the following warning :</p> <p>================</p> <p>Warning 1 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Referenced type 'ServiceLibrary.MyStructure, ServiceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' with data contract name 'MyStructure' in namespace '' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types. XPath to Error Source: //wsdl:definitions[@targetNamespace='<a href="http://tempuri.org/" rel="nofollow noreferrer">http://tempuri.org/</a>']/wsdl:portType[@name='IService1'] \Projects\WCFSample\WCFExample\TestAddReference\Service References\ServiceReference1\Reference.svcmap 1 1 TestAddReference</p> <p>======================</p> <p>And no proxy will be generated for you.</p> <p>Now, the internet is full with descriptions of this when you have a generic DataContract, and/or using IsReference attribute.</p> <p>This is a much serious problem, since any non-typed data will do this problem. Could not find any way to solve the problem. What if I want to know the type at the client side, by sharing the class library of the contracts ?</p>
 

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