In Camunda Connect a Connectors class exists which automatically detectsevery connector in the classpath. It can be used to get the SOAP connectorinstance by its connector ID, which is soap-http-connector.

  1. SoapHttpConnector soap = Connectors.getConnector(SoapHttpConnector.ID);

The SOAP connector extends the Camunda Connect HTTP connector which usesthe Apache HTTP client in the default implementation. To read about default and custom client configuration,please see the corresponding section in the HTTP connector docs.

Request

Creating a Request

The SOAP HTTP connector can be used to create a new request, set a URL, content typeand payload.

  1. connector.createRequest()
  2. .url("http://camunda.org/soap")
  3. .soapAction("doIt")
  4. .contentType("application/soap+xml")
  5. .payload(soap_envelope)
  6. .execute();

Adding HTTP Headers to a Request

To add own headers to the HTTP request the method header isavailable.

  1. connector.createRequest()
  2. .url("http://camunda.org/soap")
  3. .soapAction("doIt")
  4. .contentType("application/soap+xml")
  5. .header("Accept", "application/xml")
  6. .payload(soap_envelope)
  7. .execute();

Using the Generic API

Besides the configuration methods also a generic API exists toset parameters of a request. The following parameters areavailable:

Parameter Description
method Sets the HTTP method of the request
url Sets the URL of the request
headers Contains a map of the configured HTTP headers of the request
payload Sets the payload of the request

This can be used as follows:

  1. HttpRequest request = http.createRequest();
  2. request.setRequestParameter("method", "GET");
  3. request.setRequestParameter("url", "http://camunda.org");
  4. request.setRequestParameter("payload", "hello world!");

Response

A response contains the status code, response headers and body.

  1. Integer statusCode = response.getStatusCode();
  2. String contentTypeHeader = response.getHeader("Content-Type");
  3. String body = response.getResponse();

After the response was processed it should be closed.

  1. response.close()

Using the Generic API

Besides the response methods a generic API is providedto gather the response parameters. The following parametersare available:

Parameter Description
statusCode Contains the status code of the response
headers Contains a map with the HTTP headers of the response
response Contains the response body

This can be used as follows:

  1. response.getResponseParameter("statusCode");
  2. response.getResponseParameter("headers");
  3. response.getResponseParameter("response");

原文: https://docs.camunda.org/manual/7.9/reference/connect/soap-connector/