Search code examples
c#wcfprocessmaker

Processmaker Web Service in C#


I have web service

http://sandbox3.processmaker.com/sysworkflow/en/neoclassic/services/wsdl2

The implementation in php for login

<?PHP
    /*webservice connection NOTE: Replace this WebAddress with your instance*/
    $client = new SoapClient('http://sandbox3.processmaker.com/sysworkflow/en/neoclassic/services/wsdl2');
    $params = array(array('userid'=>'admin', 'password'=>'processmaker'));
    $result = $client->__SoapCall('login', $params);

    /*webservice validate connection: begin*/
    if($result->status_code == 0){
        p("Connection Successful!");
        p("Session ID: " . $result->message);
        $session = $result->message;
?>

I need to call this web service in C#

I create project, click on Project Name and Add Service Reference

Named SR_Processmaker

I use below code to get sessionId

using Processmaker_Webservice.SR_Processmaker;
string userId = "1234567892";
                string password = "123456789";
                loginRequest login = new loginRequest(userId,password);

In login just userId, and password.

XML is

<xs:schema elementFormDefault="qualified" targetNamespace="http://www.processmaker.com">
<xs:element name="login">
<xs:complexType>
<xs:sequence>
<xs:element name="userid" type="xs:string"/>
<xs:element name="password" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="loginResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="status_code" type="xs:integer"/>
<xs:element name="message" type="xs:string"/>
<xs:element name="version" type="xs:string"/>
<xs:element name="timestamp" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Any one who use web service of processmaker please help me. I am new and needs your help.

Advance thanks.


Solution

  • You actually didn't invoke the service yet. So what's missing is the equivalent to that PHP line: $result = $client->__SoapCall('login', $params);

    So you'll need to instantiate a service client and hand over the loginRequest:

    string userId = "1234567892";
    string password = "123456789";
    var loginRequest = new loginRequest(userId, password);
    
    var proxy = new ProcessMakerServiceSoapClient();
    var loginResult = proxy.loginAsync(loginRequest);
    var result = loginResult.Result;
    
    proxy.Close();