org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive()方法的一些代码示例,展示了WebServiceTemplate.sendAndReceive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebServiceTemplate.sendAndReceive()方法的具体详情如下:
包路径:org.springframework.ws.client.core.WebServiceTemplate
类名称:WebServiceTemplate
方法名:sendAndReceive

WebServiceTemplate.sendAndReceive介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-integration

@Override
protected Object doHandle(String uri, final Message<?> requestMessage,
    final WebServiceMessageCallback requestCallback) {
  Object requestPayload = requestMessage.getPayload();
  Result responseResultInstance = null;
  if (requestPayload instanceof String) {
    responseResultInstance = new StringResult();
  }
  else if (requestPayload instanceof Document) {
    responseResultInstance = new DOMResult();
  }
  return getWebServiceTemplate()
      .sendAndReceive(uri,
          new SimpleRequestMessageCallback(requestCallback, requestMessage),
          new SimpleResponseMessageExtractor(responseResultInstance));
}

代码示例来源:origin: spring-projects/spring-integration

@Test
@SuppressWarnings("unchecked")
public void jmsUri() {
  AbstractEndpoint endpoint = this.context.getBean("gatewayWithJmsUri", AbstractEndpoint.class);
  assertEquals(EventDrivenConsumer.class, endpoint.getClass());
  MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
  assertNull(TestUtils.getPropertyValue(handler, "destinationProvider"));
  assertFalse(TestUtils.getPropertyValue(handler, "encodeUri", Boolean.class));
  WebServiceTemplate webServiceTemplate = TestUtils.getPropertyValue(handler, "webServiceTemplate",
      WebServiceTemplate.class);
  webServiceTemplate = spy(webServiceTemplate);
  doReturn(null).when(webServiceTemplate).sendAndReceive(anyString(),
      any(WebServiceMessageCallback.class),
      ArgumentMatchers.<WebServiceMessageExtractor<Object>>any());
  new DirectFieldAccessor(handler).setPropertyValue("webServiceTemplate", webServiceTemplate);
  handler.handleMessage(new GenericMessage<String>("foo"));
  verify(webServiceTemplate).sendAndReceive(eq("jms:wsQueue"),
      any(WebServiceMessageCallback.class),
      ArgumentMatchers.<WebServiceMessageExtractor<Object>>any());
}

代码示例来源:origin: spring-projects/spring-integration

@Test
@SuppressWarnings("unchecked")
public void testHttpUriVariables() {
  WebServiceTemplate webServiceTemplate = TestUtils.getPropertyValue(this.httpOutboundGateway,
      "webServiceTemplate", WebServiceTemplate.class);
  webServiceTemplate = Mockito.spy(webServiceTemplate);
  final AtomicReference<String> uri = new AtomicReference<>();
  doAnswer(invocation -> {
    uri.set(invocation.getArgument(0));
    throw new WebServiceIOException("intentional");
  }).when(webServiceTemplate)
      .sendAndReceive(Mockito.anyString(),
          Mockito.any(WebServiceMessageCallback.class),
          (WebServiceMessageExtractor<Object>) Mockito.any(WebServiceMessageExtractor.class));
  new DirectFieldAccessor(this.httpOutboundGateway).setPropertyValue("webServiceTemplate", webServiceTemplate);
  Message<?> message = MessageBuilder.withPayload("<spring/>")
      .setHeader("x", "integration")
      .setHeader("param", "test1 & test2")
      .build();
  try {
    this.inputHttp.send(message);
  }
  catch (MessageHandlingException e) {
    // expected
    assertThat(e.getCause(), Matchers.is(Matchers.instanceOf(WebServiceIOException.class))); // offline
  }
  assertEquals("http://localhost/spring-integration?param=test1%20&%20test2", uri.get());
}

代码示例来源:origin: org.springframework.ws/org.springframework.ws

public Object marshalSendAndReceive(String uri,
                  final Object requestPayload,
                  final WebServiceMessageCallback requestCallback) {
  return sendAndReceive(uri, new WebServiceMessageCallback() {
    public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
      if (requestPayload != null) {
        Marshaller marshaller = getMarshaller();
        if (marshaller == null) {
          throw new IllegalStateException(
              "No marshaller registered. Check configuration of WebServiceTemplate.");
        }
        MarshallingUtils.marshal(marshaller, requestPayload, request);
        if (requestCallback != null) {
          requestCallback.doWithMessage(request);
        }
      }
    }
  }, new WebServiceMessageExtractor<Object>() {
    public Object extractData(WebServiceMessage response) throws IOException {
      Unmarshaller unmarshaller = getUnmarshaller();
      if (unmarshaller == null) {
        throw new IllegalStateException(
            "No unmarshaller registered. Check configuration of WebServiceTemplate.");
      }
      return MarshallingUtils.unmarshal(unmarshaller, response);
    }
  });
}

代码示例来源:origin: spring-projects/spring-ws

@Override
public <T> T sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageExtractor<T> responseExtractor) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseExtractor);
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

@Override
public boolean sendAndReceive(String uri,
               WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  Assert.notNull(responseCallback, "responseCallback must not be null");
  Boolean result = sendAndReceive(uri, requestCallback,
      new WebServiceMessageCallbackMessageExtractor(responseCallback));
  return result != null && result;
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

@Override
public <T> T sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageExtractor<T> responseExtractor) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseExtractor);
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

@Override
public boolean sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseCallback);
}

代码示例来源:origin: org.springframework.ws/org.springframework.ws

public boolean sendAndReceive(String uri,
               WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  Assert.notNull(responseCallback, "responseCallback must not be null");
  Boolean result = sendAndReceive(uri, requestCallback,
      new WebServiceMessageCallbackMessageExtractor(responseCallback));
  return result != null && result;
}

代码示例来源:origin: spring-projects/spring-ws

@Override
public boolean sendAndReceive(String uri,
               WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  Assert.notNull(responseCallback, "responseCallback must not be null");
  Boolean result = sendAndReceive(uri, requestCallback,
      new WebServiceMessageCallbackMessageExtractor(responseCallback));
  return result != null && result;
}

代码示例来源:origin: org.springframework.ws/org.springframework.ws

public <T> T sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageExtractor<T> responseExtractor) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseExtractor);
}

代码示例来源:origin: spring-projects/spring-ws

@Override
public boolean sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseCallback);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public <T> T sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageExtractor<T> responseExtractor) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseExtractor);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public boolean sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseCallback);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public boolean sendAndReceive(String uri,
               WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  Assert.notNull(responseCallback, "responseCallback must not be null");
  Boolean result = sendAndReceive(uri, requestCallback,
      new WebServiceMessageCallbackMessageExtractor(responseCallback));
  return result != null && result;
}

代码示例来源:origin: org.springframework.ws/org.springframework.ws

public boolean sendAndReceive(WebServiceMessageCallback requestCallback,
               WebServiceMessageCallback responseCallback) {
  return sendAndReceive(getDefaultUri(), requestCallback, responseCallback);
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

private <T> T doSendAndReceive(String uri,
                final Transformer transformer,
                final Source requestPayload,
                final WebServiceMessageCallback requestCallback,
                final SourceExtractor<T> responseExtractor) {
  Assert.notNull(responseExtractor, "responseExtractor must not be null");
  return sendAndReceive(uri, new WebServiceMessageCallback() {
    public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
      transformer.transform(requestPayload, message.getPayloadResult());
      if (requestCallback != null) {
        requestCallback.doWithMessage(message);
      }
    }
  }, new SourceExtractorMessageExtractor<T>(responseExtractor));
}

代码示例来源:origin: apache/servicemix-bundles

private <T> T doSendAndReceive(String uri,
                final Transformer transformer,
                final Source requestPayload,
                final WebServiceMessageCallback requestCallback,
                final SourceExtractor<T> responseExtractor) {
  Assert.notNull(responseExtractor, "responseExtractor must not be null");
  return sendAndReceive(uri, new WebServiceMessageCallback() {
    public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
      transformer.transform(requestPayload, message.getPayloadResult());
      if (requestCallback != null) {
        requestCallback.doWithMessage(message);
      }
    }
  }, new SourceExtractorMessageExtractor<T>(responseExtractor));
}

代码示例来源:origin: spring-projects/spring-ws

private <T> T doSendAndReceive(String uri,
                final Transformer transformer,
                final Source requestPayload,
                final WebServiceMessageCallback requestCallback,
                final SourceExtractor<T> responseExtractor) {
  Assert.notNull(responseExtractor, "responseExtractor must not be null");
  return sendAndReceive(uri, new WebServiceMessageCallback() {
    public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
      transformer.transform(requestPayload, message.getPayloadResult());
      if (requestCallback != null) {
        requestCallback.doWithMessage(message);
      }
    }
  }, new SourceExtractorMessageExtractor<T>(responseExtractor));
}

代码示例来源:origin: org.springframework.ws/org.springframework.ws

private <T> T doSendAndReceive(String uri,
                final Transformer transformer,
                final Source requestPayload,
                final WebServiceMessageCallback requestCallback,
                final SourceExtractor<T> responseExtractor) {
  Assert.notNull(responseExtractor, "responseExtractor must not be null");
  return sendAndReceive(uri, new WebServiceMessageCallback() {
    public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
      transformer.transform(requestPayload, message.getPayloadResult());
      if (requestCallback != null) {
        requestCallback.doWithMessage(message);
      }
    }
  }, new SourceExtractorMessageExtractor<T>(responseExtractor));
}

相关文章

WebServiceTemplate类方法