I have to make a SOAP POST request to create an event in a C# application.
The events manager service is available at this endpoint:
https://eu3.provider.com/eTech/services/cxf/v6/BusinessEventManager
This endpoint uses a SOAP 1.2 binding (Document/literal) with MTOM, and offers the following security policies:
•HTTP Basic Auth through a secured channel (https) in Base64.
The method which creates the event is createEvents(BusinessEvent[], WSEntry[])
, and it hasn't username and password attributes.
And now, this is my code:
// Creating the BusinessEvent[] object:
BusinessEventManagerWebReference.businessEvent[] myBusinessEvent = new BusinessEventManagerWebReference.businessEvent[1];
myBusinessEvent[0] = new BusinessEventManagerWebReference.businessEvent();
myBusinessEvent[0].id = "myBusinessEvent";
BusinessEventManagerWebReference.coreData cd = new BusinessEventManagerWebReference.coreData();
cd.creationDate = DateTime.Now;
cd.orderingCustomer = "Cliente";
cd.description = "Descripcion";
BusinessEventManagerWebReference.externalReferentialData externalRFD = new BusinessEventManagerWebReference.externalReferentialData();
externalRFD.customerName = "Nombre Cliente";
externalRFD.equipmentName = "Equipo";
cd.referentialData = externalRFD;
myBusinessEvent[0].coreData = cd;
BusinessEventManagerWebReference.location myLocation = new BusinessEventManagerWebReference.location();
myLocation.address = "Direccion";
myLocation.city = "Ciudad";
myLocation.description = "Direccion";
externalRFD.location = myLocation;
// Creating the WebRequest
WebRequest myRequest = WebRequest.Create("https://eu3.provider.com/eTech/services/cxf/v6/BusinessEventManager");
myRequest.Method = "POST";
string usernamePassword = "myuser" + ":" + "mypassword";
usernamePassword = Convert.ToBase64String(new ASCIIEncoding().GetBytes(usernamePassword));
CredentialCache mycache = new CredentialCache();
myRequest.Credentials = mycache;
myRequest.Headers.Add("Authorization", "Basic " + usernamePassword);
However, at this point I don't know how to combine my WebRequest, my BusinessEvent object and the createEvents method for creating the event... Should I pass the BusinessEvent object as a parameter? Should I convert it to XML format before calling WebRespose()??
Any help please??
Thanks a lot!!