我有一个 xml 文件,我正在尝试使用 Visual Studio 中的 XSD.exe 工具创建一个类文件。这是 XML 文件:
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<PayloadManifest xmlns="http://www.starstandards.org/webservices/2005/10/transport">
<manifest contentID="Content0" namespaceURI="?" element="?" relatedID="?" version="?" />
</PayloadManifest>
<wsa:Action>http://www.starstandards.org/webservices/2005/10/transport/operations/ProcessMessageResponse</wsa:Action>
<wsa:MessageID>urn:uuid:b56c3b11-d4a7-4372-9e6a-7498aa2aeb06</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:71089910-41d4-4104-bbd7-2b3ac7cece0f</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-abc8d6ea-d75d-42a2-b042-87309692c2bb">
<wsu:Created>2012-06-27T19:14:43Z</wsu:Created>
<wsu:Expires>2012-06-27T19:19:43Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
<ProcessMessageResponse xmlns="http://www.starstandards.org/webservices/2005/10/transport">
<payload>
<content id="Content0">
<VehicleSaleGroupsTable xmlns="">
<VehicleSaleGroupRecord xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CompanyNumber>ZE7</CompanyNumber>
<FranchiseType>N</FranchiseType>
<FranchiseCode>NC</FranchiseCode>
<FranchiseDescription>NEW CAR</FranchiseDescription>
<Manufacturer />
<UsedSaleAccount />
<UsedInventoryAccount />
</VehicleSaleGroupRecord>
<VehicleSaleGroupRecord xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CompanyNumber>ZE7</CompanyNumber>
<FranchiseType>N</FranchiseType>
<FranchiseCode>NT</FranchiseCode>
<FranchiseDescription>NEW TRUCK</FranchiseDescription>
<Manufacturer />
<UsedSaleAccount />
<UsedInventoryAccount />
</VehicleSaleGroupRecord>
<VehicleSaleGroupRecord xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CompanyNumber>ZE7</CompanyNumber>
<FranchiseType>U</FranchiseType>
<FranchiseCode>UC</FranchiseCode>
<FranchiseDescription>USED CAR</FranchiseDescription>
<Manufacturer />
<UsedSaleAccount>USALE</UsedSaleAccount>
<UsedInventoryAccount>UINV</UsedInventoryAccount>
</VehicleSaleGroupRecord>
<VehicleSaleGroupRecord xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CompanyNumber>ZE7</CompanyNumber>
<FranchiseType>U</FranchiseType>
<FranchiseCode>UT</FranchiseCode>
<FranchiseDescription>USED TRUCK</FranchiseDescription>
<Manufacturer />
<UsedSaleAccount>USALE</UsedSaleAccount>
<UsedInventoryAccount>UINV</UsedInventoryAccount>
</VehicleSaleGroupRecord>
</VehicleSaleGroupsTable>
</content>
</payload>
</ProcessMessageResponse>
</soap:Body>
</soap:Envelope>
我打开 Visual Studio 命令行程序并输入以下内容:
C:\xml2xsd\xsd myXML.xml
它生成了 5 个 xsd 文件,然后我输入了以下内容:
C:\xml2xsd\xsd /c myXML.xsd
我收到以下消息,没有创建类文件:
Microsoft (R) Xml Schemas/DataTypes 支持实用程序 [Microsoft (R) .NET Framework,版本 2.0.50727.3038] 版权所有 (C) Microsoft Corporation。版权所有。架构验证警告:未声明“http://www.starstandards.org/webservices/2005/10/transport:ProcessMessageResponse”元素。第 25 行,第 16 位。模式验证警告:未声明“http://schemas.xmlsoap.org/ws/2004/08/addressing:Action”元素。第 13 行,第 16 位。模式验证警告:未声明“http://schemas.xmlsoap.org/ws/2004/08/addressing:MessageID”元素。第 14 行,第 16 位。模式验证警告:未声明“http://schemas.xmlsoap.org/ws/2004/08/addressing:RelatesTo”元素。第 15 行,第 16 位。模式验证警告:'http://schemas.xmlsoap. org/ws/2004/08/addressing:To' 元素未声明。第 16 行,第 16 位。模式验证警告:未声明“http://www.starstandards.org/webservices/2005/10/transport:PayloadManifest”元素。第 17 行,第 16 位。模式验证警告:未声明“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd:Security”元素. 第 18 行,第 16 位。
警告:无法验证架构。类生成可能会失败或可能产生不正确的结果。
错误:为模式“myxmlRESfile”生成类时出错。- 缺少元素“http://schemas.xmlsoap.org/ws/2004/08/addressing:Action”。
如果您需要更多帮助,请输入“xsd /?”。
任何帮助将不胜感激生成这些类文件。我以前从未使用过这个工具。
谢谢!