Java Soap клиент работает слишком медленно - PullRequest
0 голосов
/ 18 января 2019

У меня есть клиент 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;
}

1 Ответ

0 голосов
/ 13 августа 2019

Вы должны включить всю информацию трассировки / журнала инфраструктуры, которую вы используете для клиента, чтобы увидеть, в чем проблема.

Если вы используете jax-w, простой способ будет:

System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");

См: Отслеживание XML-запроса / ответов с помощью JAX-WS

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...