Creating a ticket in .net using SOAP

English! place to talk about development, programming and coding
Post Reply
b152341
Znuny newbie
Posts: 1
Joined: 29 May 2013, 14:54
Znuny Version: 3.2.7
Real Name: ryan jenkins
Company: videology

Creating a ticket in .net using SOAP

Post by b152341 »

I cannot find this anywhere :( . I need to implement automated ticket creation into a large project that already exists in .net.

I can create a web service using the GUI (admin/web servies) with the following properties:
-Name: AlertInjest
-Network Transport: HTTP::SOAP
--Namespace: http://[domain]/GenericInterface/webservice
--Max msg lng: 2048
-operation name: CreateAlert
--operation controller: Ticket::CreateTicket.


From there, I was thinking I'd form the soap request as a string and send it as a web request to whatever uri it is supposed to be.

Can someone give me an example of:

-The SOAP string: Necessary soap formatting/fields required in the request to the web service.
-The uri I'm supposed to use. (i.e http://[domain]/otrs/rpc.pl or http://[domain]/otrs/nph-genericinterface.pl/Webservice/AlertInjest)

If you're feeling really generous, an example of creating the webrequest and getting the response would be great.

Anyway.. hope someone can do this, as I haven't seen a single comprehensive writeup on this.
marcmoennikes
Znuny newbie
Posts: 17
Joined: 30 Apr 2012, 15:47
Znuny Version: 3.1.4
Real Name: Marc Moennikes
Company: KKRN

Re: Creating a ticket in .net using SOAP

Post by marcmoennikes »

Hello,

i have similar requirement.
Maybe somebody has an example for .net(c# or vb.net) and using SOAP?

Regards

Marc
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Creating a ticket in .net using SOAP

Post by eandrex »

Hi,

if you dont have a soap lib in your .net project, you can always hardcode the XML input that OTRS is expecting.

Something like this should work

Code: Select all


string xmlarguments = @"<TicketCreate></TicketCreate>"; // see http://otrs.github.io/doc/manual/admin/3.3/en/html/genericinterface.html#genericinterface-connectors

try
{
	HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("http://yourotrsdomain.com/otrs/nph-genericinterface.pl/Webservice/YourWebServiceName"));
	request.Method = "POST";
	using (Stream stream = request.GetRequestStream())
	{
	     using (StreamWriter streamwriter = new StreamWriter(stream))
	     {
	        streamwriter.Write(xmlarguments);
	        streamwriter.Flush();
	     }
	}

	string response = string.Empty;
	using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
	{
		using (Stream stream = response.GetResponseStream())
	         using (StreamReader streamreader = new StreamReader(stream))
	            response = streamreader.ReadToEnd();
	}
	Console.WriteLine(response);
}
catch{}
marcmoennikes
Znuny newbie
Posts: 17
Joined: 30 Apr 2012, 15:47
Znuny Version: 3.1.4
Real Name: Marc Moennikes
Company: KKRN

Re: Creating a ticket in .net using SOAP

Post by marcmoennikes »

Thank you for the example.
I will try this.

Regards

Marc
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

Re: Creating a ticket in .net using SOAP

Post by eandrex »

If you try it, it wont work hahah im sorry :shock: ..

in order to work, you have to make it a valid soap request..and to achieve that, you have to prepend this to your <TicketCreate>

Code: Select all

string request = "<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>";

request += "<TicketCreate>bla bla bla</TicketCreate>";

request += "</soap:Body></soap:Envelope>";


Post Reply