I am consuming a SOAP webservice from our ticket system OTRS. So the Webservice is not really under my control. The request works just fine, but i am never getting an answer in my Code. The answer is always null. (var response = client.SessionCreate(session);) The strange thing is, that wireshark and the webservice console of that ticket system are saying that i should receive a valid answer. Since i am very new to this webservice stuff so i have absolutely no idea where to start in this case. So here is a description of that i did. Any suggestion is really appreciated.
First i created a normal C# project and added the WSDL file which can be found only on the GitHub site website of the OTRS project. I added it as a Service Reference and than added my C# code which looks like this.
// For Debug System.Net.ServicePointManager.Expect100Continue = false; Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
try { OTRS.OTRS_Error err = new OTRS.OTRS_Error(); OTRS.GenericTicketConnector_PortTypeClient client = new OTRS.GenericTicketConnector_PortTypeClient("GenericTicketConnector_Port"); OTRS.SessionCreate session = new OTRS.SessionCreate(); session.Item = "someUserNameGoesHere"; session.ItemElementName = OTRS.ItemChoiceType8.UserLogin; session.Password = "SomePasswordGoesHere"; var response = client.SessionCreate(session); Console.WriteLine(response.SessionID); Console.WriteLine(response.Error); } catch (Exception exep) { Console.WriteLine(exep.Message); Console.WriteLine(exep.InnerException); } finally { Console.ReadLine(); } Incoming message at serverside
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> <a:Action s:mustUnderstand="1">http://www.otrs.org/TicketConnector/SessionCreate</a:Action> <a:MessageID>urn:uuid:14750529-3de2-4618-8db4-8ac18b681c18</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">http://SomeServer/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector</a:To> </s:Header> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SessionCreate xmlns="http://www.otrs.org/TicketConnector/"> <UserLogin xmlns="">someUserName</UserLogin> <Password xmlns="">somePassword</Password> </SessionCreate> </s:Body> Outgoing message at serverside
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <SessionCreateResponse xmlns="http://www.otrs.org/TicketConnector/"> <SessionID>SomeSessionID</SessionID> </SessionCreateResponse> </soap:Body> </soap:Envelope> Wireshark HTTP/XML package going from the server to my client
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <SessionCreateResponse xmlns="http://www.otrs.org/TicketConnector/"> <SessionID>SomeSessionID</SessionID> </SessionCreateResponse> </soap:Body> </soap:Envelope> Refernce.cs https://gist.github.com/HansVader/1ba3847d918ee15ef16703c8ada6c9bf
WSDL https://gist.github.com/HansVader/dd849e49f4a1584397cd21b0e430b301
I currently only need the SessionnCreate and TicketUpdate function. The other operations are irrelevant at this point in time. Please let me know if you need any other informations.
No comments:
Post a Comment