简体   繁体   中英

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. Following the steps to do this, I used the Connected Services and Microsoft WCF Web Service Reference Provider. Put the uri of service, listed the services available, changed the default namespace and done the others steps without any errors. At the end the tool created a proxy reference for the web service, but with no models.

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

As you can see, all models in the imported schemas aren't available in the generated code. Tried with svcutil tool too without success.

Doing something wrong? Exists a way to generate a valid proxy or I need to do it manually with web requests?

This happened because WSDL definition contains "wrapped" content.

You need (with "old" svcutil from .NETFramework):

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

or with dotnet-svcutil :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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