18.2. Client-Side Java Webservice Client

The execution server that is part of JBoss BPM Suite web tooling comes with a Web Service interface. In addition, JBoss BPM Suite incorporates existing REST and JMS interfaces, as well as client-side Java clients to deal with REST and JMS.
Classes generated by the kie-remote-client module function as a client-side interface for SOAP. The CommandWebServiceClient class referenced in the test code below is generated by the Web Service Description Language (WSDL) in the kie-remote-client jar.
import org.kie.remote.client.api.RemoteRuntimeEngineFactory;
import org.kie.remote.client.jaxb.JaxbCommandsRequest;
import org.kie.remote.client.jaxb.JaxbCommandsResponse;
import org.kie.remote.jaxb.gen.StartProcessCommand;
import org.kie.remote.services.ws.command.generated.CommandWebService;
import org.kie.services.client.serialization.jaxb.impl.JaxbCommandResponse;
    public void runCommandWebService(String user, String password, String processId, String deploymentId, String applicationUrl) throws Exception {

        CommandWebService client = RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder()
                .addDeploymentId(deploymentId)
                .addUserName(user)
                .addPassword(password)
                .addServerUrl(applicationUrl)
                .buildBasicAuthClient();

        // Get a response from the WebService
        StartProcessCommand cmd = new StartProcessCommand();
        cmd.setProcessId(processId);
        JaxbCommandsRequest req = new JaxbCommandsRequest(deploymentId, cmd);
        final JaxbCommandsResponse response = client.execute(req);

        JaxbCommandResponse<?> cmdResp = response.getResponses().get(0);
        JaxbProcessInstanceResponse procInstResp = (JaxbProcessInstanceResponse) cmdResp;
        long procInstId = procInstResp.getId();
    }
The SOAP interface for the JBoss BPM Suite Execution Server is currently available for EAP, EWS, WAS, and AS. This client-side interface incorporates the CommandWebService class and includes the execute operation as depicted below:
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
import org.kie.remote.client.jaxb.JaxbCommandsRequest;
import org.kie.remote.client.jaxb.JaxbCommandsResponse

@WebService(name = "CommandServicePortType", targetNamespace = "http://services.remote.kie.org/6.3.0.1/command")
public interface CommandWebService {

    /**
     * 
     * @param request
     * @return
     *     returns org.kie.remote.client.jaxb.JaxbCommandsResponse
     * @throws CommandWebServiceException
     */
    @WebMethod
    @WebResult(targetNamespace = "")
    @RequestWrapper(localName = "execute", targetNamespace = "http://services.remote.kie.org/6.3.0.1/command", className = "org.kie.remote.services.ws.command.generated.Execute")
    @ResponseWrapper(localName = "executeResponse", targetNamespace = "http://services.remote.kie.org/6.3.0.1/command", className = "org.kie.remote.services.ws.command.generated.ExecuteResponse")
    public JaxbCommandsResponse execute(@WebParam(name = "request", targetNamespace = "") JaxbCommandsRequest request) throws CommandWebServiceException;

}