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
.
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.
connector.createRequest()
.url("http://camunda.org/soap")
.soapAction("doIt")
.contentType("application/soap+xml")
.payload(soap_envelope)
.execute();
Adding HTTP Headers to a Request
To add own headers to the HTTP request the method header
isavailable.
connector.createRequest()
.url("http://camunda.org/soap")
.soapAction("doIt")
.contentType("application/soap+xml")
.header("Accept", "application/xml")
.payload(soap_envelope)
.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:
HttpRequest request = http.createRequest();
request.setRequestParameter("method", "GET");
request.setRequestParameter("url", "http://camunda.org");
request.setRequestParameter("payload", "hello world!");
Response
A response contains the status code, response headers and body.
Integer statusCode = response.getStatusCode();
String contentTypeHeader = response.getHeader("Content-Type");
String body = response.getResponse();
After the response was processed it should be closed.
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:
response.getResponseParameter("statusCode");
response.getResponseParameter("headers");
response.getResponseParameter("response");
原文: https://docs.camunda.org/manual/7.9/reference/connect/soap-connector/