通过xsd.exe生成xml到C#代码,无法生成代码

时间:2018-02-06 09:54:22

标签: c# xml soap xsd

我有以下xml用于Soap Message请求。下面的XML是向服务器发送Soap请求。我喜欢在我的.Net应用程序中生成源代码以向服务器发送请求。

<s:Envelope
  xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SendMessage
      xmlns="http://www.localdomain.com/system/xsd/user-text-messaging/v3_1">
      <SendMessageRequest>
        <ClientIds>
          <ClientId>1900072003</ClientId>
          <ClientId>1900072004</ClientId>
          <ClientId>1900072005</ClientId>
        </ClientIds>
        <Message>Test message</Message>
        <DisplayDurationInSeconds>10</DisplayDurationInSeconds>
        <SequenceNumber>12</SequenceNumber>
      </SendMessageRequest>
    </SendMessage>
  </s:Body>
</s:Envelope>

我尝试使用xsd.exe并生成C#源文件但是它遇到如下错误。

C:\Users\zaung\source\repos\ComposingXxml\ComposingXxml>xsd SendMessage.xml
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\Users\zaung\source\repos\ComposingXxml\ComposingXxml\SendMessage.xsd'.

C:\Users\zaung\source\repos\ComposingXxml\ComposingXxml>xsd SendMessage.xsd /c /order
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: The 'http://www.localdomain.com/system/xsd/user-text-messaging/v3_1:SendMessage' element is not declared. Line 10, position 16.

Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.

Error: Error generating classes for schema 'SendMessage'.
  - The element 'http://www.localdomain.com/system/xsd/user-text-messaging/v3_1:SendMessage' is missing.

If you would like more help, please type "xsd /?".

0 个答案:

没有答案