Search in sources :

Example 1 with SetHeaderResponse

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse in project scout.rt by eclipse.

the class AbstractJaxWsClientTest method testSamePortMultipleTimesSetHeader.

@Test
public void testSamePortMultipleTimesSetHeader() {
    JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    // 1. invoke echo without header
    EchoRequest echoReq = new EchoRequest();
    echoReq.setMessage("test message");
    port.echo(echoReq);
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, null);
    // 2. set header
    final String expectedHeader = "test header value";
    SetHeaderRequest req = new SetHeaderRequest();
    req.setHeaderName(X_SCOUT_JAX_WS_TEST_HEADER);
    req.setHeaderValue(expectedHeader);
    SetHeaderResponse resp = port.setHeader(req);
    assertNotNull(resp);
    assertEquals("ok", resp.getMessage());
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, expectedHeader);
    // 3. invoke echo without header
    echoReq.setMessage("test message");
    port.echo(echoReq);
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, null);
}
Also used : SetHeaderRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest) SetHeaderResponse(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse) EchoRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.EchoRequest) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) Test(org.junit.Test)

Example 2 with SetHeaderResponse

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse in project scout.rt by eclipse.

the class AbstractJaxWsClientTest method testSetupSetHeader.

@Test
public void testSetupSetHeader() {
    final String expectedHeader = "test header value";
    SetHeaderRequest req = new SetHeaderRequest();
    req.setHeaderName(X_SCOUT_JAX_WS_TEST_HEADER);
    req.setHeaderValue(expectedHeader);
    JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    SetHeaderResponse resp = port.setHeader(req);
    assertNotNull(resp);
    assertEquals("ok", resp.getMessage());
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, expectedHeader);
}
Also used : SetHeaderRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest) SetHeaderResponse(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) Test(org.junit.Test)

Example 3 with SetHeaderResponse

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse in project scout.rt by eclipse.

the class JaxWsConsumerTestServiceProvider method setHeader.

@Override
public SetHeaderResponse setHeader(SetHeaderRequest parameters) {
    Assertions.assertNotNull(parameters);
    final String headerName = parameters.getHeaderName();
    final String headerValue = parameters.getHeaderValue();
    LOG.info("set header ['{}'='{}']", headerName, headerValue);
    @SuppressWarnings("unchecked") Map<String, List<String>> httpResonseHeaderMap = (Map<String, List<String>>) m_wsCtx.getMessageContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
    if (httpResonseHeaderMap == null) {
        httpResonseHeaderMap = new HashMap<>();
        m_wsCtx.getMessageContext().put(MessageContext.HTTP_RESPONSE_HEADERS, httpResonseHeaderMap);
    }
    httpResonseHeaderMap.put(headerName, CollectionUtility.arrayList(headerValue));
    SetHeaderResponse resp = new SetHeaderResponse();
    resp.setMessage("ok");
    return resp;
}
Also used : SetHeaderResponse(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SetHeaderResponse (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse)3 JaxWsConsumerTestServicePortType (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType)2 SetHeaderRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 EchoRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.EchoRequest)1