public InputStream invokeClientInbound(HttpURLConnection httpConnection) throws IOException {
    // XXX fill this in...
    Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();

    Map<String, Object> httpProperties = new HashMap<String, Object>();
    httpProperties.put(HTTP_RESPONSE_CODE, Integer.valueOf(httpConnection.getResponseCode()));
    httpProperties.put(HTTP_RESPONSE_HEADERS, httpConnection.getHeaderFields());

    prepare(httpProperties, /*request=*/ false);

    if (!invokeInbound(httpConnection.getInputStream(), attachments)) {
      if (getProtocolException() != null) {
        reverseDirection();
        invokeInboundFaultHandlers();

        if (getRuntimeException() != null) throw getRuntimeException();
      } else if (getRuntimeException() != null) {
        closeClient();
        throw getRuntimeException();
      }
    }

    // XXX
    closeClient();
    return finish();
  }
  public void invokeServerOutbound(Source source, OutputStream os) {
    Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();

    Map<String, Object> httpProperties = new HashMap<String, Object>();
    httpProperties.put(HTTP_RESPONSE_CODE, Integer.valueOf(200));
    httpProperties.put(HTTP_RESPONSE_HEADERS, new HashMap<String, List<String>>());

    prepare(httpProperties, /*request=*/ false);

    if (!invokeOutbound(source, attachments)) {
      if (getProtocolException() != null) {
        reverseDirection();
        invokeOutboundFaultHandlers();
      }

      /*
      else if (getRuntimeException() != null) {
        closeServer();
        finish(response.getOutputStream());

        throw getRuntimeException();
      }*/
    }

    // XXX
    closeServer();
    finish(os);
  }
  public InputStream invokeServerInbound(HttpServletRequest request, OutputStream os)
      throws IOException {
    Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();

    Map<String, Object> httpProperties = new HashMap<String, Object>();
    httpProperties.put(HTTP_REQUEST_METHOD, request.getMethod());

    Map<String, List<String>> headers = new HashMap<String, List<String>>();

    Enumeration headerNames = request.getHeaderNames();

    while (headerNames.hasMoreElements()) {
      String name = (String) headerNames.nextElement();
      List<String> values = new ArrayList<String>();

      Enumeration headerValues = request.getHeaders(name);

      while (headerValues.hasMoreElements()) {
        String value = (String) headerValues.nextElement();
        values.add(value);
      }

      headers.put(name, values);
    }

    httpProperties.put(HTTP_REQUEST_HEADERS, headers);

    prepare(httpProperties, /*request=*/ true);

    if (!invokeInbound(request.getInputStream(), attachments)) {
      if (getProtocolException() != null) {
        reverseDirection();
        invokeInboundFaultHandlers();
      } else if (getRuntimeException() == null) uninvokeInbound();

      closeServer();
      finish(os);

      return null;
    }

    return finish();
  }
  public boolean invokeClientOutbound(Source source, OutputStream out) throws ProtocolException {
    // XXX fill this in...
    Map<String, DataHandler> attachments = new HashMap<String, DataHandler>();

    Map<String, Object> httpProperties = new HashMap<String, Object>();
    httpProperties.put(HTTP_REQUEST_METHOD, "POST");
    httpProperties.put(HTTP_REQUEST_HEADERS, new HashMap<String, List<String>>());

    prepare(httpProperties, /*request=*/ true);

    if (!invokeOutbound(source, attachments)) {
      // XXX handle Oneway
      if (getProtocolException() != null) {
        reverseDirection();
        invokeOutboundFaultHandlers();
        closeClient();

        if (getRuntimeException() != null) throw getRuntimeException();

        if (getProtocolException() != null) throw getProtocolException();

        return false;
      } else if (getRuntimeException() != null) {
        closeClient();
        throw getRuntimeException();
      } else {
        uninvokeOutbound();
        closeClient();

        if (getRuntimeException() != null) throw getRuntimeException();

        if (getProtocolException() != null) throw getProtocolException();

        return false;
      }
    }

    finish(out);

    return true;
  }