【问题标题】:wsdl.exe Error: Unable to import binding '...' from namespace '...'wsdl.exe 错误:无法从命名空间“...”导入绑定“...”
【发布时间】:2010-09-09 19:17:11
【问题描述】:

在我创建的 WSDL 上运行 wsdl.exe 时,出现以下错误:

错误:无法从命名空间“SomeNS”导入绑定“SomeBinding”。

  • 无法导入操作“someOperation”。
  • 这些成员可能无法派生。

我使用的是文档文字样式,据我所知,我正在遵守所有规则。

总而言之,我有一个有效的 WSDL,但该工具不喜欢它。

我正在寻找的是是否有人对 wsdl.exe 工具有丰富的经验并且知道一些我不知道的秘密问题。

【问题讨论】:

标签: .net soap wsdl


【解决方案1】:

我遇到了同样的错误信息。挖了一会,发现除了wsdl文件外,还可以提供xsd文件。因此在 wsdl 命令的末尾除了 .wsdl 之外还包含/导入了 .xsd 文件,如下所示:

wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...

Wsdl 给出了一些警告,但它确实创建了一个正常的服务接口。

【讨论】:

    【解决方案2】:

    有时您必须更改您的代码。 消息部分名称不应该相同;)

    <wsdl:message name="AnfrageRisikoAnfrageL">
        <wsdl:part name="parameters" element="his1_0:typeIn"/>
    </wsdl:message>
    <wsdl:message name="AnfrageRisikoAntwortL">
        <wsdl:part name="parameters" element="his1_0:typeOut"/>
    </wsdl:message>
    

    到这里:

    <wsdl:message name="AnfrageRisikoAnfrageL">
        <wsdl:part name="in" element="his1_0:typeIn"/>
    </wsdl:message>
    <wsdl:message name="AnfrageRisikoAntwortL">
        <wsdl:part name="out" element="his1_0:typeOut"/>
    </wsdl:message>
    

    【讨论】:

    • 那是我的情况。谢谢。
    【解决方案3】:

    在我的情况下,问题有所不同,并且很好地描述了here

    只要零件的名称是“参数”,.Net 就假定使用 doc/lit/wrapped 并相应地生成代理。如果即使使用了“参数”一词,wsdl 也不是 doc/lit/wrapped(如上一个示例所示),.Net 可能会给我们一些错误。哪个错误?你猜对了:“这些成员可能不是派生出来的”。现在我们可以理解错误的含义:.Net 尝试省略根元素,因为它认为使用了 doc/lit/wrapped。然而,这个元素不能被删除,因为它不是虚拟的——它应该由用户从几个派生类型中主动选择。

    修复如下,对我来说效果很好:

    修复它的方法是在文本编辑器中打开 wsdl 并将部件名称从 "parameters" 更改为 "parameters1"。现在 .Net 将知道生成一个 doc/lit/bare 代理。这意味着一个新的包装类将作为根参数出现在代理中。虽然这可能是一个更乏味的 api,但这不会对有线格式产生任何影响,并且代理是完全可互操作的。

    (我强调)

    【讨论】:

    • 很好的解释,不敢相信这是我多年开发后第一次遇到这个问题。
    【解决方案4】:

    @thehhv 解决方案是正确的。有一种解决方法不需要您手动添加xsds。

    转到您的服务而不是 ?wsdl 转到 ?singleWsdl(下面的屏幕截图)

    然后将页面另存为.wsdl 文件(它将提供.svc 所以更改它)

    然后打开 Visual studio command prompt 你可以在 (Win 7) 开始 -> 所有程序 -> Visual Studio 2013 -> Visual Studio 工具 -> VS2013 x64 Native Tools 命令提示符中找到它(可能是类似的东西)
    然后在Visual studio command prompt 中运行以下命令(而不是 C:\WebPricingService.wsdl 是您保存 wsdl 的位置,除非碰巧我们认为非常相似并选择相同的文件名和位置,这令人担忧)

    wsdl.exe C:\WebPricingService.wsdl
    

    它应该像@thehhv 所说的那样给你一些警告,但仍然在C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\WebPricingService.cs 中生成客户端(或者它放在你机器上的任何地方 - 检查控制台输出,它读取“正在写入文件”)

    希望这可以为您节省一些时间。

    【讨论】:

      【解决方案5】:

      如果有人撞到了这堵墙,这就是导致我的错误的原因:

      我有一个手术:

      <wsdl:operation name="FormatReport">
        <wsdl:documentation>Runs a report, which is returned as the response</wsdl:documentation>
        <wsdl:input message="FormatReportRequest" />
        <wsdl:output message="FormatReportResponse" />
      </wsdl:operation>
      

      接受输入:

      <wsdl:message name="FormatReportRequest">
        <wsdl:part name="parameters" element="reporting:FormatReportInput" />
      </wsdl:message>
      

      还有另一个操作:

      <wsdl:operation name="FormatReportAsync">
        <wsdl:documentation>Creates and submits an Async Report Job to be executed asynchronously by the Async Report Windows Service.</wsdl:documentation>
        <wsdl:input message="FormatReportAsyncRequest" />
        <wsdl:output message="FormatReportAsyncResponse" />
      </wsdl:operation>
      

      接受输入:

        <wsdl:message name="FormatReportAsyncRequest">
          <wsdl:part name="parameters" element="reporting:FormatReportInputAsync" />
        </wsdl:message>
      

      输入元素是两种类型的实例:

      <xsd:element name="FormatReportInput" type="reporting:FormatReportInputType"/>
      <xsd:element name="FormatReportInputAsync" type="reporting:FormatReportAsyncInputType"/>
      

      这里有一个问题——reporting:FormatReportAsyncInputType 类型扩展(派生自)reporting:FormatReportInputType 类型。这似乎使工具混淆并导致“这些成员可能无法派生”。错误。您可以在接受的答案中绕过以下建议。

      【讨论】:

        【解决方案6】:

        如果您使用 UPS Shipping wsdl 执行此操作,并且您希望在为不同区域(调试、开发、产品)等进行构建时将 dev 交换为 prod url。您可以使用以下命令生成 vb 或 C#从 Ship.wsdl 文件,然后在这种情况下覆盖 Ship.vb 文件中的值。

        WSDL /Language:VB /out:"C:\wsdl\Ship.vb" "C:\wsdl\Ship.wsdl"  C:\wsdl\UPSSecurity.xsd  C:\wsdl\ShipWebServiceSchema.xsd  C:\wsdl\IFWS.xsd  C:\wsdl\common.xsd
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-03-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-08-26
          • 1970-01-01
          • 1970-01-01
          • 2016-04-11
          相关资源
          最近更新 更多