Недопустимый тип содержимого:текст/html — SOAP-клиент

#spring-boot #soap

Вопрос:

Я внедряю soap-клиент с помощью spring boot. В настоящее время я могу протестировать его на почтальоне, и он отлично работает. Однако, когда я пытаюсь отправить запрос на одно и то же из spring, я получаю недопустимый тип содержимого — текст/html, подробности которого я опубликую ниже

От почтальона введите описание изображения здесь

Теперь это wsdl и сервер https://xpartner.net.pl/soap2.wsdl
https://xpartner.net.pl/wsdlSoapServ2.php

Теперь в файле spring boot pom у меня есть плагин следующего вида

     <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.14.0</version>
        <executions>
            <execution>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <schemaLanguage>WSDL</schemaLanguage>
            <generatePackage>com.autokonto.pl.xpartner</generatePackage>
            <schemas>
                <schema>
                    <url>https://xpartner.net.pl/soap2.wsdl</url>
                </schema>
            </schemas>
        </configuration>
    </plugin>
 

И настроить

 @Configuration
public class XpartnerConfig {

    @Bean
    public Jaxb2Marshaller marshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setContextPath("com.autokonto.pl.xpartner");
        return marshaller;
    }

    @Bean
    public XpartnerClient xpartnerClient(Jaxb2Marshaller marshaller) {
        XpartnerClient client = new XpartnerClient();
        client.setDefaultUri("https://xpartner.net.pl/soap2.wsdl");
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);
        return client;
    }
}
 

One question here is the
client.setDefaultUri(«https://xpartner.net.pl/soap2.wsdl»);
the uri required is the wsdl ?
or soap server. anyways i tried using both

Client looks like this

 @Slf4j
public class XpartnerClient extends WebServiceGatewaySupport {

    public LoginResultClass login(JAXBElement<LoginDataClass> loginDataClass) {
        LoginResultClass response = (LoginResultClass) getWebServiceTemplate().marshalSendAndReceive(loginDataClass);
        return response;
    }
}
 

Which is eventually called from the service

looks like this

 @Slf4j
@Service
@RequiredArgsConstructor
public class XpartnerApiService {

    private final static javax.xml.namespace.QName _LOGIN_DATA_CLASS_QNAME = new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/encoding/", "loginDataClass");

    @Value("${xpartner.login}")
    private String login;
    @Value("${xpartner.password}")
    private String password;

    LoginResultClass loginResultClass;

    private final XpartnerClient xpartnerClient;

    @PostConstruct
    void login() {
        log.info("log in xpartnerClient");
        ObjectFactory objectFactory = new ObjectFactory();

        LoginDataClass data = objectFactory.createLoginDataClass();
        data.setLogin(login);
        data.setPass(password);

        JAXBElement<LoginDataClass> jaxbLoginDataClass = createLoginDataClass(data);

        this.loginResultClass = xpartnerClient.login(jaxbLoginDataClass);
        log.info("LOGGING RESULT"   loginResultClass.isLoginResult());
    }

    @XmlElementDecl(namespace = "http://schemas.xmlsoap.org/soap/encoding", name = "loginDataClass")
    public JAXBElement<LoginDataClass> createLoginDataClass(LoginDataClass value) {
        return new JAXBElement<LoginDataClass>(_LOGIN_DATA_CLASS_QNAME, LoginDataClass.class, null, value);
    }
 

}

Finally the erro i get is

  Error creating bean with name 'xpartnerApiService': Invocation of init method failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.3.5.jar:5.3.5]
 

How can i fix this, is there a way to state that i need content-type to be text/xml

My understanding is that the error comes the request sent but not sure why.

 From the logs i have found why im getting this error. its because the request created looks like this 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:loginDataClass xmlns:ns2="https://xpartner.net.pl/xpartner" xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns4="https://xpartner.net.pl/xpartner/">
<ns2:login>46084_0</ns2:login>
<ns2:pass>a6jCVzeJ3mCpNJ8</ns2:pass>
</ns3:loginDataClass>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 

so it returns html with an error that says

 Procedure 'loginDataClass' not present in /var/www/www.xpartner.net.pl/www/wsdlSoapServ2.php on line
 

how can i change the request to look like this

 <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <login xmlns="https://xpartner.net.pl/xpartner/">
            <obj>
            <login>dsdsdff</login>
            <pass>sccccsccccc</pass>
            </obj>
        </login>
    </Body>
</Envelope>