I have a small application written in c# consuming a webservice which returns a list of companies.
I would like to use the same in PB in order to integrate the web service consumption with my business requirements. The only problem that I have faced is how to add the message header. Below is the C# code, appreciate converting it to PB script
private void button1_Click(object sender, EventArgs e)
{
//token variable to be used in soap header
string token = "";
//API key to be used in soap header
string API_KEY = "xxx_xxxx_XX@";
//My webService client
AmanUnionWebService.AmanUnionServiceClient client = new AmanUnionWebService.AmanUnionServiceClient();
try
{
using (new OperationContextScope(client.InnerChannel))
{
//add a soap header for API Key
MessageHeader ApiMessageHeader = MessageHeader.CreateHeader("API_KEY", "http://tempuri.org", API_KEY);
System.ServiceModel.OperationContext.Current.OutgoingMessageHeaders.Add(ApiMessageHeader);
string userName = "username";
string passWord = "Pasword.";
string Provider = "provider";
//calls the authenticate user
//if the authentication is successful it will assign the token variable the appropriate value
client.AUEAuthenticateUser(userName, passWord, Provider, ref token);
//add a soap header for authentication key
//I add my token to the soap header
MessageHeader AuthMessageHeader = MessageHeader.CreateHeader("AUTH_TOKEN", "http://tempuri.org", token);
System.ServiceModel.OperationContext.Current.OutgoingMessageHeaders.Add(AuthMessageHeader);
label1.Text = null;
DateTime date = DateTime.Today;
DataSet companySearchResults = client.AUEGetSearchResults("SAL", "LE", -1 );
if (companySearchResults.Tables.Count > 0)
{
dataGridView1.DataSource = companySearchResults.Tables[0];
dataGridView1.Refresh();
}
}
}
catch (Exception ex)
{
var message = ex.InnerException.Message;
label1.Text = message;
}
}