在 .net 核心中使用 java 网络服务的问题

Issue with consuming java web service in .net core

我正在尝试从 Java (JAX-WS) 中创建的 Web 服务导入 WSDL 定义,以便在我的 net core 2.1 应用程序中使用它。按照执行此操作的步骤,我使用了 Connected Services 和 Microsoft WCF Web Service Reference Provider。放置服务的 uri,列出可用的服务,更改默认命名空间并完成其他步骤而没有任何错误。最后,该工具为 Web 服务创建了一个代理引用,但没有模型。

下面是请求的代码片段 class 和生成的界面。

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(WrapperName="SERVICO_ENTRADA", WrapperNamespace="http://caixa.gov.br/sibar/manutencao_cobranca_bancaria/boleto/externo", IsWrapped=true)]
    public partial class INCLUI_BOLETORequest
    {

        public INCLUI_BOLETORequest()
        {
        }
    }


    [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://caixa.gov.br/sibar/manutencao_cobranca_bancaria/boleto/externo", ConfigurationName="GerencialISP.ServicosExternos.CobCaixa.manutencao_cobranca_bancaria")]
    public interface manutencao_cobranca_bancaria
    {

        [System.ServiceModel.OperationContractAttribute(Action="IncluiBoleto", ReplyAction="*")]
        System.Threading.Tasks.Task<GerencialISP.ServicosExternos.CobCaixa.INCLUI_BOLETOResponse> INCLUI_BOLETOAsync(GerencialISP.ServicosExternos.CobCaixa.INCLUI_BOLETORequest request);

    ...

    }

这是 WSDL link:http://barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?wsdl

如您所见,导入模式中的所有模型在生成的代码中都不可用。也尝试使用 svcutil 工具但没有成功。

做错了什么?是否存在生成有效代理的方法,或者我需要通过 Web 请求手动生成?

发生这种情况是因为 WSDL 定义包含 "wrapped" 内容。

您需要(使用来自 .NETFramework 的 "old" svcutil):

  1. 下载 wsdl:svcutil /t:metadata http://barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?wsdl
  2. 生成 类:svcutil *.wsdl *.xsd /language:C# /wrapped

dotnet-svcutil:

  1. 运行 dotnet svcutil http://barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?wsdl -wr