.Net Core 3.1 导入 WSDL 错误 - 如何解决? [英] .Net Core 3.1 importing WSDL Errors - How to work around?

查看:90
本文介绍了.Net Core 3.1 导入 WSDL 错误 - 如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些服务器代码从 .Net 4.7 迁移到 .Net Core 3.1,以便我们可以在 Linux 主机上运行.

I am trying to migrate some server code from .Net 4.7 to .Net Core 3.1 so we can run on a Linux host.

有两个使用 SOAP 的连接服务.一个已移植零更改,但其他在使用 WSDL 文件导入时出错:

There are two connected services using SOAP. One has ported with zero changes but other has errors when importing using the WSDL file:

http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php?wsdl

我不是 SOAP 专家,只使用过通过导入 WSDL 文件生成的代码,所以这些错误对我来说意义不大.

I'm not a SOAP expert and have only ever used the code generated by importing WSDL files so the errors don't mean a lot to me.

无法导入 wsdl:port详细信息:导入 wsdl:port 所依赖的 wsdl:binding 时出错.到 wsdl:binding 的 XPath: wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpPost']错误源的 XPath://wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:service[@name='IndividualService']/wsdl:port[@name='IndividualServiceHttpPost']无法导入 wsdl:binding详细信息:未处理命名空间http://schemas.xmlsoap.org/wsdl/http/"中所需的 WSDL 扩展元素binding".错误源的 XPath://wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpPost']无法导入 wsdl:port详细信息:导入 wsdl:port 所依赖的 wsdl:binding 时出错.xPath 到 wsdl:binding://wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpGet']错误源的 XPath://wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:service[@name='IndividualService']/wsdl:port[@name='IndividualServiceHttpGet']无法导入 wsdl:binding详细信息:未处理命名空间http://schemas.xmlsoap.org/wsdl/http/"中所需的 WSDL 扩展元素binding".错误源的 XPath://wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpGet']

Cannot import wsdl:port Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpPost'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:service[@name='IndividualService']/wsdl:port[@name='IndividualServiceHttpPost'] Cannot import wsdl:binding Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpPost'] Cannot import wsdl:port Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpGet'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:service[@name='IndividualService']/wsdl:port[@name='IndividualServiceHttpGet'] Cannot import wsdl:binding Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://uat.risc.enexusrental.co.uk']/wsdl:binding[@name='IndividualServiceHttpGet']

为了简化调试,我创建了简单的命令行应用程序,一个用于 .Net 4.7,另一个用于 Core 3.1.

To simplify debugging I created simple command line apps, one for .Net 4.7 and the other Core 3.1.

导入非常适合 .Net 4.7,我可以调用该服务(如预期).

Importing worked perfectly for the .Net 4.7 and I can call the service (as expected).

为 Core 3.1 导入会出现上述错误,并且在调用客户端初始化时返回错误:

Importing for Core 3.1 gives the errors as above and when calling the client initialization it returns an error of:

Client.Channel = 'Client.Channel' 引发了类型为System.ServiceModel.CommunicationObjectFaultedException"的异常

Client.Channel = 'Client.Channel' threw an exception of type 'System.ServiceModel.CommunicationObjectFaultedException'

我在手动使用 svcutil.exe 导入时遇到相同的错误.

I get the same errors when importing using svcutil.exe manually.

谷歌搜索 3 天后,我不再继续,因为每个问题似乎都不同,而且没有一个解决方案有效.

After 3 days Googling I am no further on as each problem seems to be different and none of the solutions work.

有人愿意解释这些错误的实际含义吗(我不是 SOAP 专家),如果可能的话,我需要做些什么来解决这些错误?

Would someone be kind enough to explain what these errors actually mean (I'm not a SOAP expert) and, if possible, what I sort of things I need to do to work around them?

推荐答案

将 WSDL 下载到文件并通过删除相应的 wsdl:binding 手动删除不受支持的 GET 和 POST 绑定wsdl:port 元素.然后,您可以使用工具(dotnet-svcutil 或 Visual Studio/IDE)生成客户端代码(服务参考).

Download the WSDL to a file and remove the unsupported GET and POST bindings manually by removing the corresponding wsdl:binding and wsdl:port elements. You can then use the tools (dotnet-svcutil or Visual Studio / IDEs) to generate the client code (Service Reference).

    --- a/service.wsdl
    +++ b/service.wsdl
    @@ -286,37 +286,6 @@
           </wsdl:output>
         </wsdl:operation>
       </wsdl:binding>
    -  <wsdl:binding name="IndividualServiceHttpGet" type="tns:IndividualServiceHttpGet">
    -    <http:binding verb="GET" />
    -    <wsdl:operation name="SearchByLastNameAndDateOfBirth">
    -      <http:operation location="/SearchByLastNameAndDateOfBirth" />
    -      <wsdl:input>
    -        <http:urlEncoded />
    -      </wsdl:input>
    -      <wsdl:output>
    -        <mime:mimeXml part="Body" />
    -      </wsdl:output>
    -    </wsdl:operation>
    -    <wsdl:operation name="SearchByDrivingLicenceNumber">
    -      <http:operation location="/SearchByDrivingLicenceNumber" />
    -      <wsdl:input>
    -        <http:urlEncoded />
    -      </wsdl:input>
    -      <wsdl:output>
    -        <mime:mimeXml part="Body" />
    -      </wsdl:output>
    -    </wsdl:operation>
    -    <wsdl:operation name="Get">
    -      <http:operation location="/Get" />
    -      <wsdl:input>
    -        <http:urlEncoded />
    -      </wsdl:input>
    -      <wsdl:output>
    -        <mime:mimeXml part="Body" />
    -      </wsdl:output>
    -    </wsdl:operation>
    -  </wsdl:binding>
    -  <wsdl:binding name="IndividualServiceHttpPost" type="tns:IndividualServiceHttpPost">
         <http:binding verb="POST" />
         <wsdl:operation name="SearchByLastNameAndDateOfBirth">
           <http:operation location="/SearchByLastNameAndDateOfBirth" />
    @@ -354,11 +323,5 @@
         <wsdl:port name="IndividualServiceSoap12" binding="tns:IndividualServiceSoap12">
           <soap12:address location="http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php" />
         </wsdl:port>
    -    <wsdl:port name="IndividualServiceHttpGet" binding="tns:IndividualServiceHttpGet">
    -      <http:address location="http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php" />
    -    </wsdl:port>
    -    <wsdl:port name="IndividualServiceHttpPost" binding="tns:IndividualServiceHttpPost">
    -      <http:address location="http://uat.risc.enexusrental.co.uk/SOAP/IndividualService.php" />
    -    </wsdl:port>
       </wsdl:service>
     </wsdl:definitions>

这篇关于.Net Core 3.1 导入 WSDL 错误 - 如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆