0

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!!

Rachel-Abc
  • 11
  • 2
  • Do you have access to WSDL? You can create a proxy and code against that. – CodingYoshi Jan 21 '18 at 12:25
  • If you don't have access to the wsdl and can't do it through standard channels you should check out the answer to this similar question https://stackoverflow.com/questions/4791794/client-to-send-soap-request-and-received-response – Mark Davies Jan 21 '18 at 12:47
  • I have access to WSDL. It's a local file. But I just don't know how to use the WSDL and put the Authentication in the Header simultaneously... It's suposed the createevents() method is the method that makes the POST, isn't it?? I'm a little bit confused... : ((( – Rachel-Abc Jan 21 '18 at 14:59

0 Answers0