2011-03-15 90 views
1

我已经在WCF中创建了一个简单的Northwind产品REST Web服务/Northwind/Product。我还在我的服务上启用了WCF Web HTTP服务帮助页面,该页面位于/Northwind/Product/help。我有一个“GET”操作,其帮助页面位于:/Northwind/Product/help/operations/Get,这是您的标准WCF帮助页面,显示Xml正文,Json正文,Xml架构和其他Xml架构。非常直截了当,对吧?现在没事了,就到了有趣的东西...WCF Web HTTP服务帮助页面

我有兴趣在XML Schema部分,那就是:

<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:complexType name="Product"> 
    <xs:sequence> 
     <xs:element minOccurs="0" name="CategoryID" nillable="true" type="xs:int" /> 
     <xs:element minOccurs="0" name="Discontinued" type="xs:boolean" /> 
     <xs:element minOccurs="0" name="ProductID" type="xs:int" /> 
     <xs:element minOccurs="0" name="ProductName" nillable="true" type="xs:string" /> 
     <xs:element minOccurs="0" name="QuantityPerUnit" nillable="true" type="xs:string" /> 
     <xs:element minOccurs="0" name="ReorderLevel" nillable="true" type="xs:short" /> 
     <xs:element minOccurs="0" name="SupplierID" nillable="true" type="xs:int" /> 
     <xs:element minOccurs="0" name="UnitPrice" nillable="true" type="xs:decimal" /> 
     <xs:element minOccurs="0" name="UnitsInStock" nillable="true" type="xs:short" /> 
     <xs:element minOccurs="0" name="UnitsOnOrder" nillable="true" type="xs:short" /> 
    </xs:sequence> 
    </xs:complexType> 
    <xs:element name="Product" nillable="true" type="Product" /> 
</xs:schema> 

我是因为数据类型感兴趣。我想知道元素的数据类型。现在,我明白这不是REST的基础。但是,我不希望SOAP对象在这里。我想保持我的服务简单而松散的类型,但仍然需要时了解它们的数据类型。

我的问题是,如何才能公开帮助文件的这一特定部分?如果我不能这样做,我还有什么其他选择可以实现我在这里要做的事情?

回答

1

我不认为有可能既松散打字,同时知道字段背后的类型。

您可以将所有内容作为字符串发送,然后在转换不可能的情况下抛出异常。

似乎没有要在XS标签:可以用来求救信息来源元素标签,http://www.w3schools.com/schema/el_element.asp