【问题标题】:Issue with consuming java web service in .net core在 .net 核心中使用 Java Web 服务的问题
【发布时间】:2018-11-21 03:38:17
【问题描述】:

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

下面是请求类的代码sn-p和生成的接口。

    [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 链接:http://barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?wsdl

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

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

【问题讨论】:

    标签: c# .net web-services .net-core wsdl


    【解决方案1】:

    发生这种情况是因为 WSDL 定义包含“包装”的内容。

    您需要(使用 .NETFramework 中的“旧”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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-12
      • 2017-01-08
      • 1970-01-01
      • 2012-07-24
      相关资源
      最近更新 更多