简体   繁体   English

在.NET Core中使用Java Web服务的问题

[英]Issue with consuming java web service in .net core

I'm trying to import a WSDL definition from a web service made in Java (JAX-WS) for consume it in my net core 2.1 app. 我试图从用Java(JAX-WS)制成的Web服务中导入WSDL定义,以便在我的net core 2.1应用程序中使用它。 Following the steps to do this, I used the Connected Services and Microsoft WCF Web Service Reference Provider. 按照执行此操作的步骤,我使用了Connected Services和Microsoft WCF Web服务参考提供程序。 Put the uri of service, listed the services available, changed the default namespace and done the others steps without any errors. 放置服务uri,列出可用的服务,更改默认名称空间,并完成其他步骤,而不会出现任何错误。 At the end the tool created a proxy reference for the web service, but with no models. 最后,该工具为Web服务创建了代理引用,但是没有模型。

Bellow a code snippet of the request class and the interface generated. 下面是请求类和所生成接口的代码片段。

    [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);

    ...

    }

Here is the WSDL link: http://barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?wsdl 这是WSDL链接: http : //barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?wsdl

As you can see, all models in the imported schemas aren't available in the generated code. 如您所见,导入的架构中的所有模型在生成的代码中均不可用。 Tried with svcutil tool too without success. 尝试使用svcutil工具也没有成功。

Doing something wrong? 做错什么了吗? Exists a way to generate a valid proxy or I need to do it manually with web requests? 是否存在一种生成有效代理的方法,或者我需要通过Web请求手动进行处理?

This happened because WSDL definition contains "wrapped" content. 发生这种情况是因为WSDL定义包含“包装”内容。

You need (with "old" svcutil from .NETFramework): 您需要(使用.NETFramework中的“旧” svcutil):

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

or with dotnet-svcutil : 或使用dotnet-svcutil

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM