我面临着一种情况,我必须在数据类型上实现IXmlSerializable,我将通过WCF服务发送该数据类型。但是,当我尝试在xsd中标记基类时,服务引用不能再刷新,并且我为“找不到”编写xsd的类型。下面是xsd:
<xs:schema
xmlns:tnsg="http://schemas.datacontract.org/2004/07/MyNS"
elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/MyNS"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:base="http://schemas.datacontract.org/2004/07/BaseNS">
<xs:complexType name="MyType">
<xs:extension base="base:BaseType">
<xs:sequence>
<xs:element name="BProperties">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="BInfo" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AProperties">
<xs:complexType >
<xs:sequence>
<xs:element minOccurs="0" name="AStuff" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexType>
<xs:element name="MyType" nillable="true" type="MyType" />
</xs:schema>"下面是C#:
public static XmlQualifiedName GetMySchema(XmlSchemaSet xs)
{
XmlSchema s = XmlSchema.Read(new StringReader(xsd), (sender, eargs) => { });
xs.Add(s);
return new XmlQualifiedName("MyType", "http://schemas.datacontract.org/2004/07/MyNS");
}我想我需要以某种方式导入BaseType?
编辑:我试过了
var baseschemes = xs.Schemas("http://schemas.datacontract.org/2004/07/MyBase");
foreach (XmlSchema item in baseschemes)
{
s.Includes.Add(item);
}它添加了一个模式(不出所料),但没有任何变化!
发布于 2011-03-30 21:05:48
问题是您当前的WSDL没有告诉客户机在哪里可以找到targetNamespace为"http://schemas.datacontract.org/2004/07/BaseNS"“的模式。您应该在WSDL中包含另一个包含此名称空间的完整模式的元素,或者提供一个引用静态XSD的元素。
https://stackoverflow.com/questions/5486404
复制相似问题