SpringBoot中的肥皂服务连接问题

时间:2019-03-01 18:20:06

标签: java spring-boot web soap wsdl

尝试使用肥皂服务时,出现以下错误:

Could not create message from InputStream: Invalid Content-Type:application/wsdl+xml. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:application/wsdl+xml. Is this an error message instead of a SOAP response?

代码:

String url = "https://www.cpo.com.br/proxy/wsdl/proxyService_p.wsdl";


    SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(
            MessageFactory.newInstance());
    messageFactory.afterPropertiesSet();

    WebServiceTemplate webServiceTemplate = new WebServiceTemplate(messageFactory);
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

    marshaller.setContextPath("br.com.dados_cadastrais.local.entity");
    setMarshaller(marshaller);
    setUnmarshaller(marshaller);
    marshaller.afterPropertiesSet();

    webServiceTemplate.setMarshaller(marshaller);
    webServiceTemplate.afterPropertiesSet();



    CpfRequest cpfRequest = new CpfRequest();
    cpfRequest.setPNumCPF("*");
    cpfRequest.setPNomeOrgao("*");
    cpfRequest.setPLoginUsuario("*");
    cpfRequest.setPNomeAplicacao("*");

    JAXBElement<CpfResponse> response = (JAXBElement<CpfResponse>) webServiceTemplate.marshalSendAndReceive(url, cpfRequest, new SoapActionCallback("http://webservice.cjf.gov.br/wsConsultaCPF"));

    return response.getValue();

我尝试了其他解决方案,例如更改WSDL URL,但未成功。 该服务只能通过特定IP访问,因此您将无法访问其内容。我猜错误出在我的代码中。

0 个答案:

没有答案