Receiving null result from SOAP request

I’m trying to make a soap request to a Brazilian government endpoint and I’m facing some trouble.

They make the following wsdl available: https://mdfe-homologacao.svrs.rs.gov.br/ws/MDFeRecepcaoSinc/MDFeRecepcaoSinc.asmx?wsdl

I then generated the corresponding stub using wsimport tool, which consists on the following:

  • MDFeRecepcaoSinc.java
  • MdfeRecepcaoResult.java
  • MDFeRecepcaoSincSoap12.java (interface)
  • ObjectFactory.java
  • package-info.java

Then, on my Java application, I did the following:

            ObjectFactory of = new ObjectFactory();
            JAXBElement<String> jaxb = of.createMdfeDadosMsg("<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:mdf="http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoSinc"><soap:Header/><soap:Body><mdf:mdfeDadosMsg>?</mdf:mdfeDadosMsg></soap:Body></soap:Envelope>");
            MDFeRecepcaoSinc recepcao = new MDFeRecepcaoSinc();
            MDFeRecepcaoSincSoap12 soap = recepcao.getMDFeRecepcaoSincSoap12(
//                  new AddressingFeature(true),
//                  new MTOMFeature(false),
//                  new RespectBindingFeature(true)
            );
            System.out.println(soap.mdfeRecepcao(jaxb.getValue()).getContent());

Although the only result I’m getting, independent of the body text, is [[retMDFe: null]].

I managed to make it work on SoapUI with this exact same request envelope and it returns a correct xml with a few tags inside retMDFe.

It appears to be connecting to their server from my Java client since the tag retMDFe isn’t present in the WSDL file or any stub I generated, and since I don’t receive the 403 - Forbidden error anymore (configured the system keystore correctly).

Unfortunately, this webservice only allows connections issued with a digital certificate.

I’m suspecting the error may be from the mapping from the endpoint to the MdfeRecepcaoResult class.
I’ve tried a few things:

  • enabling different WebServiceFeatures on the constructor of recepcao.getMDFeRecepcaoSincSoap12, although only MTOMFeature as true returned something different: Client received SOAP Fault from server: Server was unable to process request. ---> Data at the root level is invalid. Line 1, position 1. Please see the server log to find more detail regarding exact cause of the failure.;
  • changing mdfeRecepcao return type from MdfeRecepcaoResult to String, which gave me an empty string;
  • commenting annotations on mdfeRecepcao, which continued to give me the [[retMDFe: null]] response;
  • also tried passing different xml strings directly to soap.mdfeRecepcao() method, but got the same results.

What am I possibly doing wrong here? Thank you for your time!

Edit 1:

  • Declaration of mdfeRecepcao inside MDFeRecepcaoSincSoap12 interface:
    /**
     * 
     * @param mdfeDadosMsg
     * @return
     *     returns br.inf.portalfiscal.mdfe.wsdl.mdferecepcaosinc.MdfeRecepcaoResult
     */
    @WebMethod(action = "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoSinc/mdfeRecepcao")
    @WebResult(name = "mdfeRecepcaoResult", targetNamespace = "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoSinc", partName = "mdfeRecepcaoResult")
    public MdfeRecepcaoResult mdfeRecepcao(
        @WebParam(name = "mdfeDadosMsg", targetNamespace = "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoSinc", partName = "mdfeDadosMsg")
        String mdfeDadosMsg);
  • Declaration of createMdfeDadosMsg inside ObjectFactory class
    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoSinc", name = "mdfeDadosMsg")
    public JAXBElement<String> createMdfeDadosMsg(String value) {
        return new JAXBElement<String>(_MdfeDadosMsg_QNAME, String.class, null, value);
    }

Edit 2:

  • wsimport version: wsimport version "2.2.9"

  • wsimport generated files:

br/inf/portalfiscal/mdfe/wsdl/mdferecepcaosinc/MDFeRecepcaoSinc.java
br/inf/portalfiscal/mdfe/wsdl/mdferecepcaosinc/MDFeRecepcaoSincSoap12.java
br/inf/portalfiscal/mdfe/wsdl/mdferecepcaosinc/MdfeRecepcaoResult.java
br/inf/portalfiscal/mdfe/wsdl/mdferecepcaosinc/ObjectFactory.java
br/inf/portalfiscal/mdfe/wsdl/mdferecepcaosinc/package-info.java

I use the following to produce the stubs: wsimport -extension -keep -verbose MDFeRecepcaoSinc.wsdl
and it only gives a single warning: [WARNING] a porta SOAP "MDFeRecepcaoSincSoap12": usa um bind de SOAP 1.2 não padrão. linha 40 de file:/home/teste-progra/tiago/backup/mdfe/wsimport-test/MDFeRecepcaoSinc.wsdl (which means that the port used by the web service does not use a conventional (or default) bind for SOAP 1.2, and has to do with the following line in the wsdl:

    <wsdl:port name="MDFeRecepcaoSincSoap12" binding="tns:MDFeRecepcaoSincSoap12">

I’m not sure if that’s of any use though, hence the connection is effectively being held on.

New contributor

DevSoloDev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

You are not correctly marshalling the element here.

JAXBElement<String> jaxb = of.createMdfeDadosMsg("<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:mdf="http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoSinc"><soap:Header/><soap:Body><mdf:mdfeDadosMsg>?</mdf:mdfeDadosMsg></soap:Body></soap:Envelope>");

You should send a marshalled object request to the soap WS, something like this :

// Assuming MdfeDadosMsg is a class annotated with JAXB annotations and generated during your wsimport
MdfeDadosMsg requestObject = new MdfeDadosMsg();
//set your required data according to the WSDL for the requestObject.

ObjectFactory of = new ObjectFactory();
JAXBElement<MdfeDadosMsg> jaxb = of.createMdfeDadosMsg(requestObject);

MDFeRecepcaoSinc recepcao = new MDFeRecepcaoSinc();
MDFeRecepcaoSincSoap12 soap = recepcao.getMDFeRecepcaoSincSoap12();
MdfeRecepcaoResult response = soap.mdfeRecepcao(jaxb);

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật