0
try {
        SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory
                .newInstance();
        SOAPConnection connection = soapConnFactory.createConnection();

        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();

        SOAPPart soapPart = message.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();

        envelope.addNamespaceDeclaration("xsd",
                "http://www.w3.org/2001/XMLSchema");
        envelope.addNamespaceDeclaration("xsi",
                "http://www.w3.org/2001/XMLSchema-instance");
        envelope.addNamespaceDeclaration("enc",
                "http://schemas.xmlsoap.org/soap/encoding/");
        envelope.addNamespaceDeclaration("env",
                "http://schemas.xmlsoap.org/soap/envelop/");

        SOAPBody body = message.getSOAPBody();
        SOAPHeader header = message.getSOAPHeader();

        SOAPElement headerElement = header
                .addChildElement("locale", "", "");
        headerElement.addTextNode("ru");

        SOAPElement bodyElement = body.addChildElement("GetClientInfo");
        bodyElement.setPrefix("ns0");
        bodyElement.setAttribute("SOAP-ENV:encodingStyle",
                "http://schemas.xmlsoap.org/soap/encoding/");

        SOAPElement paramsElement = bodyElement.addChildElement("params");
        paramsElement.addChildElement("Login").addTextNode("Login");

        message.saveChanges();

        System.out.println("\nREQUEST:\n");
        message.writeTo(System.out);
        System.out.println();

        String destination = "https://api.direct.yandex.ru/wsdl/v4/";
        SOAPMessage reply = connection.call(message, destination);

        reply.writeTo(System.out);

        connection.close();
    } catch (Exception e) {

    }

Ошибка: SEVERE: SAAJ0008: Bad Response; Not Allowed Что нужно делать?

1 ответ 1

1

Посмотреть какой получается request, сравнить с примером: Протокол SOAP

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.