Illustrative examples of consuming Y2 Web Services
Contents
- Changes in the document 5
- Introduction 6
- PHP 7
Installing the environment 7
WSDL Cache 7
Basic authentication 8
Code 8
Execution of the script 8
Response 8
NTLM authentication 9
Setup 9
Code 9
Execution of the script 9
Response 10
Complex case (AddNewCustomer) 10
Arrays 10
Dates 10
Enum 10
Non ASCII characters 11
Troubleshooting 11 - C# 12
Installing the environment 12
Prerequisites 12
Create a new project 12
Import a file 13
Basic authentication 14
Code 14
Running the program 15
Response 15
NTLM authentication 15
Code 15
Running the program 16
Response 16
Complex case (AddNewCustomer) 16
Arrays 16
Dates 16
Enum 16
Non ASCII characters 17
Troubleshooting 17 - Python 19
Installing the environment 19
Install a package 19
Basic authentication 20
Code 20
Execution of the script 21
Response 21
NTLM authentication 21
Setup 21
Code 21
Execution of the script 22
Response 22
Complex case (AddNewCutomer) 23
Arrays 23
Dates 23
Enum 23
Non ASCII characters 23
Troubleshooting 23 - Ruby 25
Installing the environment 25
Basic authentication 26
Code 26
Execution of the script 26
Response 26
Note 27
NTLM authentication 27
Prerequisites 27
Code 28
Execution of the script 28
Response 28
Note 29
Complex case (AddNewCustomer) 29
Arrays 29
Dates 29
Enum 29
Non ASCII characters 29
Troubleshooting 29 - Java 31
Installing the environment 31
Prerequisites 31
Install Apache 31
Install Axis2 32
Create a new project 33
Create a Web Service client 35
Import a file 37
Basic authentication 38
Code 38
Running the program 39
Response 39
NTLM authentication 39
Prerequisites 39
Code 40
Running the program 41
Response 41
Complex case (AddNewCustomer) 41
Arrays 41
Dates 41
Enum 41
Non ASCII characters 41
Troubleshooting 42 - JavaScript 45
Installing the environment 45
Disclaimer 45
Basic authentication 46
Code 46
Execution of the script 47
Response 47
NTLM authentication 48
Setup 48
Code 48
Execution of the script 49
Note 49
Response 49
Complex case (AddNewCustomer) 50
Arrays 50
Dates 50
Enum 50
Non ASCII characters 50
Troubleshooting 51 - Authentication cookie 52
Introduction 52
Sample of a PHP script 52
CookieSoap 52
Code 52
1.Changes in the document
Date Author Type of change
12/24/2014 Alexis BEVILLARD Creation
1/19/2015 Yan PEUILLON Summary review
2/13/2017 Thomas SEBBANE PHP environment review : Add prerequisite PHP version minimum
PHP NTLM authentication : Update files to remove hacks
2/16/2017 Thomas SEBBANE PHP environment review : Add wsdl cache configuration for production and test mode
4/12/2017 Thomas SEBBANE Add JavaScript samples
2.Introduction
In the sample programs of this documentation, you will find:
DatabaseId = “DATABASE”
“DATABASE” represents the FolderId associated with the database to use when consuming the Web Service; this identifier will be sent in the SOAP request.
Parameters of the HelloWorld method
These programs are provided as examples. In production, the code may be different. Cegid may not be liable for their use.
3.PHP
Installing the environment
-Download PHP for Windows and copy it to C:\php
oNote : requires a PHP version >= 5.6.25
-Configure php.ini:
oCopy C:\php\php.ini-production to C:\php\php.ini
oUncomment these lines in php.ini:
Lines Why
; extension_dir = “ext” Enables the loading of extensions
; extension=php_openssl.dll Enables the SSL support
; extension=php_soap.dll Enables SOAP support (cf. SoapClient class)
WSDL Cache
In production mode
-Change value of the line in php.ini:
Lines Why
soap.wsdl_cache_enabled=1 Enable WSDL cache
Test and debug mode
-Change value of the line in php.ini:
Lines Why
soap.wsdl_cache_enabled=0 Disable WSDL cache
Important: In production mode, make sure to set soap.wsdl_cache_enabled=1 to enable cache.
Basic authentication
Code
Script used to consume the Web Service with a Basic authentication (CBR).
Sample of code and description:
Code Info
<?php $url = "http://localhost/CBR_12.1/WorkerProcessService.svc"; $client = new SoapClient( $url . "?singleWsdl", array( "location" => $url, "login" => "DOMAIN\\USERNAME", "password" => "PASSWORD" ) ); $request = new StdClass(); $request->text = "ttt"; $request->clientContext = new StdClass(); $request->clientContext->DatabaseId = "DATABASE"; $resu = $client->HelloWorld($request); print_r( $resu ); ?>URL of the Web Service
Create the client
Link to the WSDL file
Database name, identifier and password
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:ns1=“http://www.cegid.fr/Retail/1.0”>
SOAP-ENV:Body
ns1:HelloWorld
ns1:textttt</ns1:text>
ns1:clientContext
ns1:DatabaseIdDATABASE</ns1:DatabaseId>
</ns1:clientContext>
ns1:HelloWorld
SOAP-ENV:Body
</SOAP-ENV:Envelope>
Execution of the script
Open a command prompt, access the directory storing the script and enter this line:
C:\php\php.exe –f basic_auth.php
Response
The program displays the response from the Web Service, specifying the type of authentication used: Basic (CBR)
stdClass Object
(
[HelloWorldResult] => Now: (2014-11-12T11:26:43.2069451)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (ttt)
DataBaseId: (DATABASE)
ErpIdentity: (CEG) (CEGID) (DOMAIN)
Current Identity: (DOMAIN\CEGID) (CBR)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
)
NTLM authentication
Setup
SoapClientAuth is a class that replaces SoapClient by integrating the NTLM authentication.
-Download SoapClientAuth to the same directory than the script.
-Enable the php curl extension
Lines Why
;extension=php_curl.dll Enables the curl extension
Code
Script used to consume the Web Service with NTLM authentication (CBR).
Sample of code and description:
Code Info
Include SoapClientAuth
URL of the Web Service
Create the client
Link to the WSDL file
Name of the Windows domain, identifier and password
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:ns1=“http://www.cegid.fr/Retail/1.0”>
SOAP-ENV:Body
ns1:HelloWorld
ns1:textttt</ns1:text>
ns1:clientContext
ns1:DatabaseIdDATABASE</ns1:DatabaseId>
</ns1:clientContext>
ns1:HelloWorld
SOAP-ENV:Body
</SOAP-ENV:Envelope>
Execution of the script
Open a command prompt, access the directory storing the script and enter this line:
C:\php\php.exe –f ntlm_auth.php
Response
The program displays the response from the Web Service, specifying the type of authentication used: NTLM
stdClass Object
(
[HelloWorldResult] => Now: (2014-11-12T11:43:23.0514559)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (ttt)
DataBaseId: (DATABASE)
ErpIdentity: (BEV) (BEVILLARD) (DOMAIN)
Current Identity: (DOMAIN\BEVILLARD) (NTLM)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
)
Complex case (AddNewCustomer)
How can you create more complex types? See example with AddNewCustomer:
Arrays
Create each cell and create an array with array();
$UserDefinedBoolean1 = new StdClass();
$UserDefinedBoolean1->Id = 1;
$UserDefinedBoolean1->Value = true;
$UserDefinedBoolean2 = new StdClass();
$UserDefinedBoolean2->Id = 2;
$UserDefinedBoolean2->Value = false;
$UserDefinedBoolean3 = new StdClass();
$UserDefinedBoolean3->Id = 3;
$UserDefinedBoolean3->Value = true;
r e q u e s t − > c u s t o m e r D a t a − > U s e r D e f i n e d B o o l e a n s = a r r a y ( request->customerData->UserDefinedBooleans = array( request−>customerData−>UserDefinedBooleans=array(UserDefinedBoolean1, $UserDefinedBoolean2, $UserDefinedBoolean3);
Dates
Create a DateTime object, specify the date and time, then convert the object into a character string with $date->format
$UserDefinedDate1 = new StdClass();
$UserDefinedDate1->Id = 1;
$date = new Datetime(null, new DateTimeZone(“UTC”));
$date->SetDate(1970, 01, 01);
$date->SetTime(18, 00, 00);
$UserDefinedDate1->Value = $date->format(“Y-m-d\TH:i:s”);
Enum
There is no Enum in PHP, so go directly to the constant value
$request->customerData->AddressData->CountryIdType = “Internal”;
Non ASCII characters
Do not forget to save the script with UTF-8 encoding.
$UserDefinedText2->Value = “漢字”;
Troubleshooting
Traces enable the recovery of the XML input in order to process the case in SoapUI again, for example, and the XML output to get the entire error message. This paragraph describes how to activate the traces.
To enable the display of the traces, first place the “soapDebug.php” file in the same directory as the script.
Then include “soapDebug.php” by adding the following line to the beginning of the script.
include(‘soapDebug.php’);
And add this line after having called the Web Service:
soapDebug($client);
where $client is an instance of SoapClient
Do not forget to catch the exception that may be launched by $client, because if an error occurs the program will abort and the traces will not be displayed.
When the script is run, you will get the XML request as well as the XML response.
Script and example of traces:
4.C#
Installing the environment
Prerequisites
Download and install Visual Studio
Create a new project
To create a project, go to “File / New / Project”.
Select “Console Application” from Visual C#; enter the project name and click on OK.
In the Solution Explorer, right-click on the project name and “Add Service Reference…”
Specify the URL of the WSDL in field “Address” and click on “Go”.
Select the Web Service and specify a name in field “Namespace” and click on OK.
Import a file
This paragraph explains how to import a file in Visual Studio in order to use the sample files about the consumption of Web Services.
To add a file click on “Project / Add Existing Item…”
Please notice:
Visual Studio creates a Program.cs file containing a “main” function.
You must delete the program for the project to compile with the imported file.
Basic authentication
Code
Source code used to consume the Web Service with a Basic authentication (CBR).
Sample of code and description:
Code Info
static void Main(string[] args)
{
var bhb = new BasicHttpBinding(
BasicHttpSecurityMode.TransportCredentialOnly
);
var auth = HttpClientCredentialType.Basic;
bhb.Security.Transport.ClientCredentialType = auth;
var service = new WorkerProcessServiceClient(
bhb,
new EndpointAddress(
http://localhost/CBR_12.1/WorkerProcessService.svc
)
);
service.ClientCredentials.UserName.UserName = “DOMAIN\USERNAME”;
service.ClientCredentials.UserName.Password = “PASSWORD”;
var text = “ttt”;
var clientContext = new RetailContext();
clientContext.DatabaseId = “DATABASE”;
var result = service.HelloWorld(text, clientContext);
Console.WriteLine(result);
Console.ReadLine();
}
For HTTPS connections:
Transport
For HTTP connections:
TransportCredentialOnly
BASIC authentication type
URL of the Web Service
Database name, identifier and password
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”>
<s:Body>
DATABASE
</s:Body>
</s:Envelope>
Running the program
To launch the program, click on (or press key F5)
Response
The program displays the response from the Web Service, specifying the type of authentication used: Basic (CBR)
Now: (2014-11-13T09:40:07.7248033)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (ttt)
DataBaseId: (DATABASE)
ErpIdentity: (CEG) (CEGID) (DOMAIN)
Current Identity: (DOMAIN\CEGID) (CBR)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
NTLM authentication
Code
Source code used to consume the Web Service with a NTLM authentication.
Sample of code and description:
Code Info
static void Main(string[] args)
{
var bhb = new BasicHttpBinding(
BasicHttpSecurityMode.TransportCredentialOnly
);
var auth = HttpClientCredentialType.Ntlm;
bhb.Security.Transport.ClientCredentialType = auth;
var service = new WorkerProcessServiceClient(
bhb,
new EndpointAddress(
http://localhost/CBR_12.1/WorkerProcessService.svc
)
);
service.ClientCredentials.UserName.UserName = “DOMAIN\USERNAME”;
service.ClientCredentials.UserName.Password = “PASSWORD”;
var text = “ttt”;
var clientContext = new RetailContext();
clientContext.DatabaseId = “DATABASE”;
var result = service.HelloWorld(text, clientContext);
Console.WriteLine(result);
Console.ReadLine();
}
For HTTPS connections:
Transport
For HTTP connections:
TransportCredentialOnly
NTLM authentication type
URL of the Web Service
Name of the Windows domain, identifier and password
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”>
<s:Body>
DATABASE
</s:Body>
</s:Envelope>
Running the program
To launch the program, click on (or press key F5)
Response
The program displays the response from the Web Service, specifying the type of authentication used: NTLM
Now: (2014-11-13T09:43:30.5495957)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (ttt)
DataBaseId: (DATABASE)
ErpIdentity: (BEV) (BEVILLARD) (DOMAIN)
Current Identity: (DOMAIN\BEVILLARD) (NTLM)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
Complex case (AddNewCustomer)
How can you to create more complex types? See example with AddNewCustomer:
Arrays
Create a list of several items (in this example UserDefinedBoolean). And call the ToArray() method to create an array from the list.
List userDefinedBooleanList = new List()
{
new UserDefinedBoolean(){ Id = UserDefinedId._1, Value = true },
new UserDefinedBoolean(){ Id = UserDefinedId._2, Value = false },
new UserDefinedBoolean(){ Id = UserDefinedId._3, Value = true }
};
customerData.UserDefinedBooleans = userDefinedBooleanList.ToArray();
Dates
Create a DateTime object by specifying the year, month, day, hour, minutes and seconds.
Value = new DateTime(1970, 01, 01, 18, 00, 00)
Enum
The proxy generates enum types from the WSDL.
customerData.AddressData.CountryIdType = CountryIdType.Internal;
Non ASCII characters
Do not forget to save the script with UTF-8 encoding; Visual Studio does it by default.
Value = “漢字”
Troubleshooting
Traces enable the recovery of the XML input in order to process the case in SoapUI again, for example, and the XML output to get the entire error message. This paragraph describes how to activate the traces.
To enable the display of traces, you must add the following lines in the app.config file of the project.
<system.diagnostics>
</system.diagnostics>
<system.serviceModel>
</system.serviceModel>
When running the program, file “messages.svclog” containing the XML request and the response is created in C:\logs\
Example of traces:
The “.svclog” extension is associated with an MS tool to view the WCF log: Microsoft Service Trace Viewer
Request
Reply
5.Python
Installing the environment
Download and install Python 2.7
Install these two packages (see how to install a package):
-setuptools (1.4.2)
-suds (0.4)
With the suds proxy, you can create a client with this function:
client = suds.client.Client(url, username=username, password=password)
And get information about the client by using simply:
print client
This returns with the WorkerProcessService Web Service the following result:
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913
Service ( WorkerProcessService ) tns=“http://tempuri.org/”
Prefixes (4)
ns0 = “http://schemas.microsoft.com/2003/10/Serialization/”
ns1 = “http://schemas.microsoft.com/2003/10/Serialization/Arrays”
ns2 = “http://www.cegid.fr/Retail/1.0”
ns3 = “http://www.cegid.fr/fault”
Ports (1):
(BasicHttpBinding_IWorkerProcessService)
Methods (2):
HelloWorld(xs:string text, ns2:RetailContext clientContext, )
Ping(xs:string input, ns2:RetailContext clientContext, )
Types (8):
ns1:ArrayOfstring
ns3:BusinessFaultDetail
ns3:CbpFaultDetail
ns2:PingReply
ns2:RetailContext
ns0:char
ns0:duration
ns0:guid
Here, the HelloWorld method uses as parameter a character string and a RetailContext object; to create the latter, you may use:
clientContext = client.factory.create(‘ns2:RetailContext’)
Install a package
Extract the package (in the example, setuptools is extracted to C:)
From menu Start, go to Accessories
Then right-click on Command prompt and select Run as administrator.
Once the command prompt window displays, position to the directory of the package and run the following command:
C:\Python27\python.exe setup.py install
Basic authentication
Code
Script used to consume the Web Service with a Basic authentication (CBR).
Sample of code and description:
Code Info
import suds
url = ‘http://localhost/CBR_12.1/WorkerProcessService.svc?wsdl’
username = “DOMAIN\USER”
password = “PASSWORD”
client = suds.client.Client(url, username=username, password=password)
clientContext = client.factory.create(‘ns2:RetailContext’)
text = “test”
clientContext.DatabaseId = “DATABASE”
response = client.service.HelloWorld(text, clientContext)
print response Include the suds library
Link to the WSDL file
Database name, identifier and password
Create the client
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns0=http://www.cegid.fr/Retail/1.0 xmlns:ns1=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”>
SOAP-ENV:Header/
ns1:Body
ns0:HelloWorld
ns0:texttest</ns0:text>
ns0:clientContext
ns0:DatabaseIdDATABASE</ns0:DatabaseId>
</ns0:clientContext>
</ns0:HelloWorld>
</ns1:Body>
</SOAP-ENV:Envelope>
Execution of the script
Open a command prompt, access the directory storing the script and enter this line:
C:\Python27\python.exe basic_auth.py
Response
The program displays the response from the Web Service, specifying the type of authentication used: Basic (CBR)
Now: (2014-11-14T13:36:33.8244203)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (test)
DataBaseId: (DATABASE)
ErpIdentity: (CEG) (CEGID) (DOMAIN)
Current Identity: (DOMAIN\CEGID) (CBR)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
NTLM authentication
Setup
Install the python-ntlm package
Code
Script used to consume the Web Service with a Basic authentication (CBR).
Sample of code and description:
Code Info
import suds
url = ‘http://localhost/CBR_12.1/WorkerProcessService.svc?wsdl’
username = “DOMAIN\USER”
password = “PASSWORD”
ntlm = suds.transport.https.WindowsHttpAuthenticated(
username=username,
password=password
)
client = suds.client.Client(url, transport=ntlm)
clientContext = client.factory.create(‘ns2:RetailContext’)
text = “test”
clientContext.DatabaseId = “DATABASE”
response = client.service.HelloWorld(text, clientContext)
print response Include the suds library
Link to the WSDL file
Name of the Windows domain, identifier and password
The proxy uses by default the Basic authentication. Here, the NTLM authentication will be forced.
Create the client
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns0=http://www.cegid.fr/Retail/1.0 xmlns:ns1=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”>
SOAP-ENV:Header/
ns1:Body
ns0:HelloWorld
ns0:texttest</ns0:text>
ns0:clientContext
ns0:DatabaseIdDATABASE</ns0:DatabaseId>
</ns0:clientContext>
</ns0:HelloWorld>
</ns1:Body>
</SOAP-ENV:Envelope>
Execution of the script
Open a command prompt, access the directory storing the script and enter this line:
C:\Python27\python.exe ntlm_auth.py
Response
The program displays the response from the Web Service, specifying the type of authentication used: NTLM
Now: (2014-11-17T09:31:05.1207254)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (test)
DataBaseId: (DATABASE)
ErpIdentity: (BEV) (BEVILLARD) (DOMAIN)
Current Identity: (DOMAIN\BEVILLARD) (NTLM)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
Complex case (AddNewCutomer)
How can you create more complex types? See example with AddNewCustomer:
Arrays
Create each of the cells and add them to the array
UserDefinedBoolean1 = client.factory.create(‘ns2:UserDefinedBoolean’)
UserDefinedBoolean1.Id = 1
UserDefinedBoolean1.Value = True
UserDefinedBoolean2 = client.factory.create(‘ns2:UserDefinedBoolean’)
UserDefinedBoolean2.Id = 2
UserDefinedBoolean2.Value = False
UserDefinedBoolean3 = client.factory.create(‘ns2:UserDefinedBoolean’)
UserDefinedBoolean3.Id = 3
UserDefinedBoolean3.Value = True
customerData.UserDefinedBooleans.UserDefinedBoolean.append(UserDefinedBoolean1)
customerData.UserDefinedBooleans.UserDefinedBoolean.append(UserDefinedBoolean2)
customerData.UserDefinedBooleans.UserDefinedBoolean.append(UserDefinedBoolean3)
Dates
Import the DateTime library and specify a date with the datetime method.
UserDefinedDate1.Value = datetime.datetime(1970, 01, 01, 18, 00, 00)
Enum
There is no Enum in Python, so go directly to the constant value
customerData.AddressData.CountryIdType = “Internal”
Non ASCII characters
Do not forget to save the script with UTF-8 encoding. Character strings with non ASCII characters must be declared with UTF-8 encoding and the response of the program must be encoded in UTF-8 too.
UserDefinedText2.Value = unicode(“漢字”, “utf-8”)
print response.encode(“utf-8”)
Troubleshooting
Traces enable the recovery of the XML input in order to process the case in SoapUI again, for example, and the XML output to get the entire error message. This paragraph describes how to activate the traces.
Therefore, you must first import the “logging” library into the script:
import logging
And add these two lines:
logging.basicConfig(level=logging.INFO)
logging.getLogger(‘suds.client’).setLevel(logging.DEBUG)
When the script is run, you will get the XML request as well as the XML response.
Script and example of traces:
6.Ruby
Installing the environment
Download and install Ruby
Do not forget to tick the checkbox “Add Ruby executables to your PATH”
From menu Start, go to Accessories
Then right-click on Command prompt and select Run as administrator.
Enter the following command:
gem install savon
Basic authentication
Code
Script used to consume the Web Service with a Basic authentication (CBR).
Sample of code and description:
Code Info
require ‘savon’
client = Savon.client do
wsdl “http://localhost/CBR_12.1/WorkerProcessService.svc?wsdl”
basic_auth(
“DOMAIN\USERNAME”,
“PASSWORD”
)
namespace “http://www.cegid.fr/Retail/1.0”
end
message ={
“wsdl:text”=>“test”,
“wsdl:clientContext”=>{
“wsdl:DatabaseId”=>“DATABASE”
}
}
response = client.call(:hello_world, message: message)
puts response.to_xml.gsub(" ", “”) Include the savon library
Create the client
Link to the WSDL file
Database name, identifier and password
Namespace of the Web Service
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:wsdl=“http://www.cegid.fr/Retail/1.0” xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/”>
env:Body
wsdl:HelloWorld
wsdl:texttest</wsdl:text>
wsdl:clientContext
wsdl:DatabaseIdDATABASE</wsdl:DatabaseId>
</wsdl:clientContext>
</wsdl:HelloWorld>
</env:Body>
</env:Envelope>
Execution of the script
Open a command prompt, access the directory storing the script and enter this line:
ruby basic_auth.rb
Response
The program displays the response from the Web Service, specifying the type of authentication used: Basic (CBR)
<s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”><s:Body>Now: (2014-11-17T11:10:34.6394072)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (test)
DataBaseId: (DATABASE)
ErpIdentity: (CEG) (CEGID) (DOMAIN)
Current Identity: (DOMAIN\CEGID) (CBR)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)</s:Body></s:Envelope>
Note
The various fields of the XML message are in an array of the response sent by client.call
For example, to display the character string returned by HelloWorld, you will use:
puts response.body[:hello_world_response][:hello_world_result]
You can display the whole content of the array with:
puts response.body
NTLM authentication
Prerequisites
Open the command prompt window and enter the following command:
gem install rubyntlm –v 0.3.2
When the script is running, Ruby may abort when creating the client (because of the authentication); the following message will display:
C:/Ruby21/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi/adapter/net_http.rb:94:in negotiate_ntlm_auth': undefined method
include?’ for nil:NilClass (NoMethodError)
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi/adapter/net_http.rb:75:in block in do_request' from C:/Ruby21/lib/ruby/2.1.0/net/http.rb:853:in
start’
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi/adapter/net_http.rb:74:in do_request' from C:/Ruby21/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi/adapter/net_http.rb:41:in
request’
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi.rb:159:in request' from C:/Ruby21/lib/ruby/gems/2.1.0/gems/httpi-2.2.7/lib/httpi.rb:125:in
get’
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/wasabi-3.3.0/lib/wasabi/resolver.rb:43:in load_from_remote' from C:/Ruby21/lib/ruby/gems/2.1.0/gems/wasabi-3.3.0/lib/wasabi/resolver.rb:33:in
resolve’
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/wasabi-3.3.0/lib/wasabi/document.rb:142:in xml' from C:/Ruby21/lib/ruby/gems/2.1.0/gems/wasabi-3.3.0/lib/wasabi/document.rb:160:in
parse’
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/wasabi-3.3.0/lib/wasabi/document.rb:147:in parser' from C:/Ruby21/lib/ruby/gems/2.1.0/gems/wasabi-3.3.0/lib/wasabi/document.rb:64:in
soap_actions’
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/operation.rb:21:in ensure_exists!' from C:/Ruby21/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/operation.rb:14:in
create’
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/client.rb:32:in operation' from C:/Ruby21/lib/ruby/gems/2.1.0/gems/savon-2.7.2/lib/savon/client.rb:36:in
call’
from test_ntlm.rb:16:in `’
To fix this issue, the NTLM authentication must be forced by deleting/commenting these lines in the net_http.rb file:
if nego_auth_response.headers[‘www-authenticate’].include? ‘Negotiate’
auth_method = ‘Negotiate’
elsif nego_auth_response.headers[‘www-authenticate’].include? ‘NTLM’
auth_method = ‘NTLM’
else
auth_method = ‘NTLM’
HTTPI.logger.debug ‘Server does not support NTLM/Negotiate. Trying NTLM anyway’
end
Add the following line instead:
auth_method = ‘NTLM’
The net_http.rb is located in “C:\Ruby21\lib\ruby\gems\2.1.0\gems\httpi-2.2.7\lib\httpi\adapter”
Code
Script used to consume the Web Service with NTLM authentication (CBR).
Sample of code and description:
Code Info
require ‘savon’
client = Savon.client do
wsdl “http://localhost/CBR_12.1/WorkerProcessService.svc?wsdl”
ntlm(
“USERNAME”,
“PASSWORD”,
“DOMAIN”
)
namespace “http://www.cegid.fr/Retail/1.0”
end
message ={
“wsdl:text”=>“test”,
“wsdl:clientContext”=>{
“wsdl:DatabaseId”=>“DATABASE”
}
}
response = client.call(:hello_world, message: message)
puts response.to_xml.gsub(" ", “”) Include the savon library
Create the client
Link to the WSDL file
Identifier, password and Windows domain name
Namespace of the Web Service
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:wsdl=“http://www.cegid.fr/Retail/1.0” xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/”>
env:Body
wsdl:HelloWorld
wsdl:texttest</wsdl:text>
wsdl:clientContext
wsdl:DatabaseIdDATABASE</wsdl:DatabaseId>
</wsdl:clientContext>
</wsdl:HelloWorld>
</env:Body>
</env:Envelope>
Execution of the script
Open a command prompt, access the directory storing the script and enter this line:
ruby ntlm_auth.rb
Response
The program displays the response from the Web Service, specifying the type of authentication used: NTLM
<s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”><s:Body>Now: (2014-11-17T11:42:45.5620494)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (test)
DataBaseId: (DATABASE)
ErpIdentity: (BEV) (BEVILLARD) (DOMAIN)
Current Identity: (DOMAIN\BEVILLARD) (NTLM)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)</s:Body></s:Envelope>
Note
The various fields of the XML message are in an array of the response sent by client.call
For example, to display the character string returned by HelloWorld, you will use:
puts response.body[:hello_world_response][:hello_world_result]
You can display the whole content of the array with:
puts response.body
Complex case (AddNewCustomer)
How can you create more complex types? See example with AddNewCustomer:
Arrays
Create an array and populate each cell.
“wsdl:UserDefinedBoolean”=>[
{
“wsdl:Id”=>1,
“wsdl:Value”=>true
},
{
“wsdl:Id”=>2,
“wsdl:Value”=>false
},
{
“wsdl:Id”=>3,
“wsdl:Value”=>true
}
]
Dates
Create a DateTime object, specify the date and time and convert the object into a character string by the means of the strftime() method.
“wsdl:Value”=>DateTime.new(1970, 01, 01, 18, 00, 00).strftime("%Y-%m-%dT%H:%M:%S")
Enum
There is no Enum in Ruby, so go directly to the constant value
“wsdl:CountryIdType”=>“Internal”
Non ASCII characters
Do not forget to save the script with UTF-8 encoding.
“wsdl:Value”=>“漢字”
Troubleshooting
Traces enable the recovery of the XML input in order to process the case in SoapUI again, for example, and the XML output to get the entire error message. This paragraph describes how to activate the traces.
To enable the display of the traces, the following two parameters must be added when creating the client.
-log true
-pretty_print_xml true
This will result in:
client = Savon.client do
wsdl “http://localhost/CBR_12.1/WorkerProcessService.svc?wsdl”
basic_auth(“DOMAIN\USERNAME”, “PASSWORD”)
namespace “http://www.cegid.fr/Retail/1.0”
log true
pretty_print_xml true
end
When the script is run, you will get the XML request as well as the XML response.
Script and example of traces:
7.Java
Installing the environment
Prerequisites
-Download and install Eclipse (Kepler)
-Download Apache Tomcat v7.0.56 and extract the content from the archive
-Download Axis 2 and extract the content from the archive
Install Apache
Apache is a HTTP server required for the use of Axis2
Open Eclipse
Go to Windows/Preferences
In the menu on the left, select Server/Runtime Environment and click on Add.
Select Apache Tomcat v7.0 and Next
Click on Browse and specify the installation directory for Apache Tomcat (the folder extracted from the archive) and click on Finish
Install Axis2
Axis2 is an API used to develop/consume SOAP Web Services.
Once again go to Windows/Preferences, select Web Services/Axis2 Preferences.
Click on Browse and specify the installation directory for Axis2 (the folder extracted from the archive)
Then, click on OK
Create a new project
Go to File/New/Other…
Under Web, click on Dynamic Web Project and on Next
Specify the name of the project
Select Apache Tomcat v7.0 for Target runtime, and 2.5 for Dynamic web module version
Click on Modify…
Tick option Axis2 Web Services and click on OK
Then click on Finish
If Eclipse prompts you to open the Java EE mode, click on Yes
Create a Web Service client
Right-click on the project in the Project Explorer and click on New/Other…
Select Web Service Client and click on Next
Specify the link to the WSDL file in Service definition
Check that under Configuration, you will find Tomcat Server v7.0 as Server runtime and Apache Axis as Web service runtime. Otherwise, click on one of them, and select the right configuration:
Server runtime
Web service runtime
Click on Finish
Import a file
This paragraph explains how to import a file in Eclipse in order to use the sample files about the consumption of Web Services.
In the Package Explorer, develop the project as well as Java Resources, right-click on src and click on Import…
Under General, select File System and click on Next
Click on Browse… and select the folder containing the file to import
The content of the directory will appear, tick the checkbox next to the file to import and click on “Finish”
Basic authentication
Code
Source code used to consume the Web Service with a Basic authentication (CBR).
Sample of code and description:
Code Info
public static void main(String[] args) throws Exception {
WorkerProcessServiceLocator ws = new WorkerProcessServiceLocator();
BasicHttpBinding_IWorkerProcessServiceStub stub = (BasicHttpBinding_IWorkerProcessServiceStub)ws.getBasicHttpBinding_IWorkerProcessService();
stub.setUsername("DOMAIN\\USERNAME");
stub.setPassword("PASSWORD");
String text = "test";
RetailContext clientContext = new RetailContext();
clientContext.setDatabaseId("DATABASE");
String response = stub.helloWorld(text, clientContext);
System.out.println(response);
}
Create the client
Database name, identifier and password
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
soapenv:Body
DATABASE
</soapenv:Body>
</soapenv:Envelope>
Running the program
To launch the program, click on (or press key F11)
If Eclipse prompts you to launch the program, select Java Application
Response
The program displays the response from the Web Service, specifying the type of authentication used: Basic (CBR)
Now: (2014-11-17T16:11:24.9651397)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (test)
DataBaseId: (DATABASE)
ErpIdentity: (CEG) (CEGID) (DOMAIN)
Current Identity: (DOMAIN\CEGID) (CBR)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
NTLM authentication
Prerequisites
Right-click on the project and select Properties
In Java Build Path, click on Add External JARs… in tab Libraries
And add the following two files:
Then import this file in all sources of the project:
Code
Source code used to consume the Web Service with NTLM authentication.
Sample of code and description:
Code Info
public static void main(String[] args) throws Exception {
WorkerProcessServiceLocator ws = new WorkerProcessServiceLocator(
getEngineConfiguration()
);
BasicHttpBinding_IWorkerProcessServiceStub stub = (BasicHttpBinding_IWorkerProcessServiceStub)ws.getBasicHttpBinding_IWorkerProcessService();
AuthPolicy.registerAuthScheme(
AuthPolicy.NTLM,
JCIFS_NTLMScheme.class
);
stub.setUsername("DOMAIN\\USERNAME");
stub.setPassword("PASSWORD");
String text = "test";
RetailContext clientContext = new RetailContext();
clientContext.setDatabaseId("DATABASE");
String response = stub.helloWorld(text, clientContext);
System.out.println(response);
} Prepare the implementation of an authentication type other than Basic used by default.
Create the client
NTLM authentication type
Name of the Windows domain, identifier and password
Prepare the request
Call the HelloWorld method
Display the result
The created request corresponds to the following XML:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
soapenv:Body
DATABASE
</soapenv:Body>
</soapenv:Envelope>
Running the program
To launch the program, click on (or press key F11)
If Eclipse prompts you to launch the program, select Java Application
Response
The program displays the response from the Web Service, specifying the type of authentication used: NTLM
Now: (2014-11-17T17:07:19.9467202)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\CBR 12.1)
InputText: (test)
DataBaseId: (DATABASE)
ErpIdentity: (BEV) (BEVILLARD) (DOMAIN)
Current Identity: (DOMAIN\BEVILLARD) (NTLM)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (12.1.0.1057)
Complex case (AddNewCustomer)
How can you create more complex types? See example with AddNewCustomer:
Arrays
Create an array and populate each cell.
UserDefinedBoolean[] userDefinedBooleans = new UserDefinedBoolean[] {
new UserDefinedBoolean(UserDefinedId.value1, true),
new UserDefinedBoolean(UserDefinedId.value2, false),
new UserDefinedBoolean(UserDefinedId.value3, true)
};
customerData.setUserDefinedBooleans(userDefinedBooleans);
Dates
Create a Calendar object by the means of Calendar.getInstance() and specify the date and time by the means of the set(); method.
Please notice, the month is an enum and starts with 0 (January = 0, February = 1 … December = 11)
Calendar date = Calendar.getInstance();
date.set(1970, Calendar.JANUARY, 01, 18, 00, 00);
Enum
The proxy generates enum types from the WSDL.
addressData.setCountryIdType(CountryIdType.Internal);
Non ASCII characters
Do not forget to save the script with UTF-8 encoding; Eclipse does it by default.
new UserDefinedText(UserDefinedId.value2, “漢字”)
Troubleshooting
Traces enable the recovery of the XML input in order to process the case in SoapUI again, for example, and the XML output to get the entire error message. This paragraph describes how to activate the traces.
To enable the display of the traces, a server must be created from Eclipse that will act as a TCP/IP monitor.
In the Window/Preferences, select Run/Debug and TCP/IP Monitor.
Then click on Add.
Specify the same parameter as on the illustration below, and replace “localhost” by the name of the Web Service domain; then click on OK.
Click on the monitor just created, click on Start to launch, and then on OK.
You must now create a Web Servicve client and specify the port of the monitor (9081) in the URL
Display the TCP/IP Monitor view via Window/Show view/Other…
And under Debug, select TCP/IP Monitor
Then you just have to consume the Web Service from Eclipse to get the traces in the TCP/IP Monitor window.
Example of traces:
8.JavaScript
Installing the environment
-Use your current browser or install (Google Chrome)
-Original sources to use soap access service from JavaScript are available here: JavaScriptSoapClient
-We use ObjTree to build the xml request, original sources are available here: ObjTree
Disclaimer
Do not use original sources of soapclient and objtree because they doesn’t support our api configuration. (Forced domain namespace, json tree with pluralization)
We have edited soapclient.js and objtree.js to make it work with our api
-We added the ability to force namespace and hidden action in wsdl
-We added a new parser to generate XML data from Json
-We commented all unused sources from original file
You can use our scripts instead:
Note: These scripts are examples. In production, the code may be different. Cegid may not be liable for them use.
Basic authentication
Code
Script used to consume the Web Service with a Basic authentication.
Sample of code and description:
Code Info
Include objtree script
Prepare the request
Database name, identifier and password
URL of the Web Service, authentication method
Call the HelloWorld method
Display results in console and text
The created request corresponds to the following XML:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>
soap:Body
CBR_AUTO
</soap:Body>
</soap:Envelope>
Execution of the script
Open index.hml, the result of the request is displayed in text, you can also show console to display result
Response
The program displays the response from the Web Service, specifying the type of authentication used: Basic
Now: (2017-04-10T16:48:07.8361055)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\Y2 14.0)
InputText: (ttt)
DataBaseId: (DATABASE)
ErpIdentity: (USR) (USER) (DOMAIN)
Current Identity: (DOMAIN\USER) (Basic)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (14.0.0.800)
NTLM authentication
Setup
To use, NTLM authentication
-Download Ntlm.js to the same directory than other scripts.
-Include it your script folder by adding this line and defining the path of Ntlm.js in your html file
Code
Script used to consume the Web Service with NTLM authentication (CBR).
Sample of code and description:
Code Info
Include objtree script
Include Ntlm script
Prepare the request
Database name, identifier and password
URL of the Web Service, authentication method
Call the HelloWorld method
Display results in console and text
The created request corresponds to the following XML:
<soap:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>
soap:Body
CBR_AUTO
</soap:Body>
</soap:Envelope>
Execution of the script
Open index.hml, the result of the request is displayed in text, you can also show console to display result
Note
You might have 2 errors in your console browser
This is completely normal and these are not errors, according to NTLM scheme for HTTP
Ntlm.js execute multiple requests to authenticate with server
Response
The program displays the response from the Web Service, specifying the type of authentication used: NTLM
Now: (2017-04-14T10:08:03.9517845)
ApplicationBase: (C:\inetpub\wwwroot\Cegid Retail\Y2 14.0)
InputText: (ttt)
DataBaseId: (CBR_AUTO)
ErpIdentity: (USR) (username) (DOMAIN)
Current Identity: (DOMAIN\USERNAME) (NTLM)
CurrentCulture: (fr-FR)
CurrentUICulture: (fr-FR)
CBR Version: (14.0.0.808)
Complex case (AddNewCustomer)
How can you create more complex types? See example with AddNewCustomer:
Parameters can be passed by a json tree
Arrays
Create an array with a json array;
JSON parameter XML result
UserDefinedBooleans: {
UserDefinedBoolean: [
{ Id: 1, Value: true },
{ Id: 2, Value: false },
{ Id: 3, Value: true }
]
}
1
true
2
false
3
true
Dates
To create a DateTime, specify the date and time, then convert it to ISO String to format to DateTime
var date = new Date().toISOString();
JSON parameter XML result
UserDefinedDates: {
UserDefinedDate: [
{ Id: 1, Value: date },
{ Id: 2, Value: date },
{ Id: 3, Value: date }
]
}
1
2017-04-12T12:41:29.127Z
2
2017-04-12T12:41:29.127Z
3
2017-04-12T12:41:29.127Z
Enum
There is no need to enum in JSON, so go directly to the constant value
{ customerData: { AddressData: { CountryIdType: "Internal" } } };
Non ASCII characters
Do not forget to save the script with UTF-8 encoding.
{ Id: 2, Value: “漢字” }
Troubleshooting
Traces are available in the console of your browser, you can also use Fiddler to debug.
9.Authentication cookie
Introduction
To avoid authenticating each time you call the Web Service you can implement a mechanism based on cookies used for the Basic HTTP. This system optimizes the WS/HTTP flow.
Therefore, you will prompt the resource without authentication, but with the cookie. If the server responds 401 (Unauthorized), you will prompt the resource again but WITH authentication and the new authentication cookie will be stored for future calls.
Header of the request with authentication:
POST /CBR_12.1/WorkerProcessService.svc HTTP/1.1
Host: localhost
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.6.3
Content-Type: text/xml; charset=utf-8
SOAPAction: “http://www.cegid.fr/Retail/1.0/ICbrBasicWebServiceInterface/HelloWorld”
Content-Length: 354
Authorization: Basic U1RBR0VfQUxFWElTXENFR0lEOkNFR0lE
Header of the request with the cookie:
POST /CBR_12.1/WorkerProcessService.svc HTTP/1.1
Host: localhost
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.6.3
Content-Type: text/xml; charset=utf-8
SOAPAction: “http://www.cegid.fr/Retail/1.0/ICbrBasicWebServiceInterface/HelloWorld”
Content-Length: 354
Cookie: CbrAuth=6I2djBiRTyfhRrW/4+yUvwwF/64p/zHCiJ3ZeEWYA3YW0WqJElsHgs/KORav60mFznmPXk0JUjSQeIWEcqCVFTbyufwnVp6WhaCih71ZILw=;
Sample of a PHP script
CookieSoap
You will use the CookieSoap.php file that contains the functions used to read and write in the file that stores the cookie.
The file contains two functions:
WriteCookie() that stores the value passed as parameter in a “cookie” file.
ReadCookie() that returns the value contained in a “cookie” file.
The file containing the authentication cookie is named “cookie” and is created in the same directory as the script. To change the name and the path of the file, you just have to change the value of the $filename variable in the CookieSoap.php file.
Code
Test of the HelloWorld method of the WorkerProcessService Web Service with the use of the authentication cookie.
Sample of code and description:
Code Info
<?php include('CookieSoap.php'); $url = "http://localhost/CBR_12.1/WorkerProcessService.svc?singleWsdl"; $client = new SoapClient($url); $request = new StdClass(); $request->text = "test"; $request->clientContext = new StdClass(); $request->clientContext->DatabaseId = "DATABASE"; $client->__setCookie("CbrAuth", ReadCookie()); try { $resu = $client->HelloWorld($request); } catch (Exception $e) { if ($e->getMessage() == "Unauthorized") { $client = new SoapClient($url, array( "login" => "DOMAIN\\USERNAME", "password" => "PASSWORD" ) ); } $resu = $client->HelloWorld($request); WriteCookie($client->_cookies["CbrAuth"][0]); } print_r($resu); ?>Include CookieSoap
Link to the WSDL file
Create the client
Prepare the request
Recover the cookie
Call the HelloWorld method
If the server responds 401, you will create a client with authentication
Database name, identifier and password
Call the HelloWorld method
Store the authentication cookie
Display the result