.net wsdl.exe 错误:无法从命名空间“...”导入绑定“...”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/77534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
wsdl.exe Error: Unable to import binding '...' from namespace '...'
提问by Glenn Moss
When running wsdl.exe on a WSDL I created, I get this error:
在我创建的 WSDL 上运行 wsdl.exe 时,出现此错误:
Error: Unable to import binding 'SomeBinding' from namespace 'SomeNS'.
- Unable to import operation 'someOperation'.
- These members may not be derived.
错误:无法从命名空间“SomeNS”导入绑定“SomeBinding”。
- 无法导入操作“someOperation”。
- 这些成员可能不是派生的。
I'm using the document-literal style, and to the best of my knowledge I'm following all the rules.
我正在使用文档文字样式,据我所知,我正在遵守所有规则。
To sum it up, I have a valid WSDL, but the tool doesn't like it.
总而言之,我有一个有效的 WSDL,但该工具不喜欢它。
What I'm looking for is if someone has lots of experience with the wsdl.exe tool and knows about some secret gotcha that I don't.
我正在寻找的是,如果有人对 wsdl.exe 工具有很多经验并且知道一些我不知道的秘密问题。
回答by thehhv
I have came across to the same error message. After digging for a while, found out that one can supply xsd files in addition to wsdl file. So included/imported .xsd files in addition to .wsdl at the end of the wsdl command as follows:
我遇到了相同的错误消息。挖了一会,发现除了wsdl文件,还可以提供xsd文件。因此,在 wsdl 命令的末尾除了 .wsdl 之外还包含/导入了 .xsd 文件,如下所示:
wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...
wsdl.exe myWebService.wsdl myXsd1.xsd myType1.xsd myXsd2.xsd ...
Wsdl gave some warnings but it did create an ok service interface.
Wsdl 给出了一些警告,但它确实创建了一个好的服务接口。
回答by mo.
sometimes u have to change ur code. the message part-names should not the same ;)
有时你必须改变你的代码。消息部分名称不应相同;)
<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>
to this:
对此:
<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>
回答by BartoszKP
In my case the problem was different, and is well described here:
在我的情况下,问题是不同的,这里有很好的描述:
Whenever the name of a part is "parameters" .Net assumed doc/lit/wrapped is used and generates the proxy accordingly. If even though the word "parameters" is used the wsdl is not doc/lit/wrapped (as in the last example) .Net may give us some error. Which error? You guessed correctly: "These members may not be derived". Now we can understand what the error means: .Net tries to omit the root element as it thinks doc/lit/wrapped is used. However this element cannot be removed since it is not dummy - it should be actively chosen by the user out of a few derived types.
每当部件的名称是“参数”时,.Net 假定使用 doc/lit/wrapped 并相应地生成代理。如果即使使用了“参数”这个词,wsdl 也不是 doc/lit/wrapped(如上一个例子),.Net 可能会给我们一些错误。哪个错误?你猜对了:“这些成员可能不是派生的”。现在我们可以理解错误的含义:.Net 尝试省略根元素,因为它认为使用了 doc/lit/wrapped。然而,这个元素不能被删除,因为它不是虚拟的——它应该由用户从几个派生类型中主动选择。
The fix is as follows, and worked perfectly for me:
修复如下,对我来说非常有效:
The way to fix it is open the wsdl in a text editor and change the part name from "parameters"to "parameters1". Now .Net will know to generate a doc/lit/bare proxy. This means a new wrapper class will appear as the root parameter in the proxy. While this may be a little more tedious api, this will not have any affect on the wire format and the proxy is fully interoperable.
修复它的方法是在文本编辑器中打开 wsdl 并将部件名称从"parameters"更改为"parameters1"。现在 .Net 将知道生成 doc/lit/bare 代理。这意味着一个新的包装类将作为根参数出现在代理中。虽然这可能有点乏味的 api,但这不会对有线格式产生任何影响,并且代理是完全可互操作的。
(emphasis by me)
(我强调)
回答by Matas Vaitkevicius
@thehhv solution is correct. There's workaround that does not require you to add xsds by hand.
@thehhv 解决方案是正确的。有一种解决方法不需要您xsd手动添加s。
Go to your service then instead of going ?wsdlgo to ?singleWsdl(screenshot below)
然后转到您的服务而不是?wsdl转到?singleWsdl(下面的屏幕截图)


then save page as .wsdlfile (it will offer .svcso change it)
然后将页面另存为.wsdl文件(它将提供.svc因此更改它)
then open Visual studio command promptyou can find it in (Win 7) Start -> All Programs -> Visual studio 2013 -> Visual Studio tools -> VS2013 x64 Native Tools Command Prompt (could be something simmilar)
Then run the following command in Visual studio command prompt(where instead of C:\WebPricingService.wsdl is where you have saved your wsdl, unless it so happens that we think very much alike and choose same file name and location which is worrying)
然后打开Visual studio command prompt你可以在(Win 7)开始 -> 所有程序 -> Visual Studio 2013 -> Visual Studio 工具 -> VS2013 x64 Native Tools Command Prompt(可能是类似的东西)
然后运行以下命令Visual studio command prompt(而不是C:\WebPricingService.wsdl 是您保存 wsdl 的地方,除非碰巧我们认为非常相似并选择相同的文件名和位置,这令人担忧)
wsdl.exe C:\WebPricingService.wsdl
It should give you some warnings as @thehhv said but still generate the client in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\WebPricingService.cs(or wherever it puts it on your machine - check console output where it reads 'Writing file')
它应该像@thehhv 所说的那样给你一些警告,但仍然生成客户端C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\WebPricingService.cs(或它放在你机器上的任何地方 - 检查控制台输出,它读取“写入文件”)


Hope this saves you some time.
希望这可以为您节省一些时间。
回答by Alex Sk
In case someone hits this wall, here is what caused the error in my case:
如果有人撞到这堵墙,这就是导致我的错误的原因:
I have an operation:
我有一个手术:
<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>
which takes an input:
它需要一个输入:
<wsdl:message name="FormatReportRequest">
<wsdl:part name="parameters" element="reporting:FormatReportInput" />
</wsdl:message>
and another operation:
和另一个操作:
<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>
taking an input:
输入:
<wsdl:message name="FormatReportAsyncRequest">
<wsdl:part name="parameters" element="reporting:FormatReportInputAsync" />
</wsdl:message>
And the input elements are instances of two types:
输入元素是两种类型的实例:
<xsd:element name="FormatReportInput" type="reporting:FormatReportInputType"/>
<xsd:element name="FormatReportInputAsync" type="reporting:FormatReportAsyncInputType"/>
Here is the catch - the reporting:FormatReportAsyncInputTypetype extends (derives from) the reporting:FormatReportInputTypetype. That's what seems to confuse the tool and cause the "These members may not be derived." error. You can go around that following teh suggestion in the accepted answer.
这是捕获 -reporting:FormatReportAsyncInputType类型扩展(派生自)reporting:FormatReportInputType类型。这似乎是混淆了工具并导致“这些成员可能无法派生”的原因。错误。您可以在已接受的答案中遵循以下建议。
回答by user2242618
In case you are doing this with UPS Shipping wsdl and you want to swap dev to prod urls when you are building for different regions (debug,dev,prod) etc. You would use the command below to generate a vb or C# file from the Ship.wsdl and then override values in this case Ship.vb file.
如果您使用 UPS Shipping wsdl 执行此操作,并且在为不同区域(debug、dev、prod)等构建时希望将 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

