У меня есть клиент Java Soap, который отправляет запросы XML со службой и методом на удаленный сервер, но он ненормально медленный и не может быть использован профессионально.
Есть ли способ ускорить его или есть более быстрый способ делать запросы на мыло?
Спасибо за ваши ответы. Вот выдержка из моего мыльного клиента.
private SOAPMessage makeMessage(String nodeName, String xmlStr, boolean asResponse) throws Exception {
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPMessage message = msgFactory.createMessage();
SOAPPart part = message.getSOAPPart();
SOAPEnvelope envelope = part.getEnvelope();
envelope.addNamespaceDeclaration("xsi", "http://www.w3.org/1999/XMLSchema-instance");
envelope.addNamespaceDeclaration("xsd", "http://www.w3.org/1999/XMLSchema");
SOAPBody body = envelope.getBody();
SOAPElement element = body.addChildElement(envelope.createName("ns1:" + this.method + (asResponse ? "Response" : "")));
element.addAttribute(envelope.createName("xmlns:ns1"), "urn:" + this.service);
element.addAttribute(envelope.createName("ns1"), "http://schemas.xmlsoap.org/soap/encoding");
SOAPElement ele2 = element.addChildElement(envelope.createName(nodeName));
ele2.addAttribute(envelope.createName("xsi:type"), "xsd:string");
ele2.addTextNode(xmlStr);
if (!asResponse) message.saveChanges();
return message;
}
private boolean sendRequest() throws Exception {
try {
SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
SOAPConnection con = conFactory.createConnection();
URL endpoint = new URL(this.getURI());
SOAPMessage message = this.makeMessage("msgstr", this.request.toString(), false);
SOAPMessage retval = con.call(message, endpoint);
//extraction du XML en String lisible du message SOAP
this.response = extractXML(retval);
} catch (Exception e) {
this.response = e.getMessage();
}
return true;
}